From de55a5dfe692e8868cdda345d87873ff50da17dc Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 1 Feb 2017 18:47:50 -0800 Subject: [PATCH] tablet-ui: reduced volume of button click --- interface/resources/qml/hifi/tablet/TabletRoot.qml | 1 + libraries/script-engine/src/SoundEffect.cpp | 9 +++++++++ libraries/script-engine/src/SoundEffect.h | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index ded91a5eff..cfda92e774 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -20,6 +20,7 @@ Item { SoundEffect { id: buttonClickSound + volume: 0.1 source: "../../../sounds/Gamemaster-Audio-button-click.wav" } diff --git a/libraries/script-engine/src/SoundEffect.cpp b/libraries/script-engine/src/SoundEffect.cpp index 6833bb1f31..1c78ae84bf 100644 --- a/libraries/script-engine/src/SoundEffect.cpp +++ b/libraries/script-engine/src/SoundEffect.cpp @@ -23,10 +23,19 @@ void SoundEffect::setSource(QUrl url) { _sound = DependencyManager::get()->getSound(_url); } +float SoundEffect::getVolume() const { + return _volume; +} + +void SoundEffect::setVolume(float volume) { + _volume = volume; +} + void SoundEffect::play(QVariant position) { AudioInjectorOptions options; options.position = vec3FromVariant(position); options.localOnly = true; + options.volume = _volume; if (_injector) { _injector->setOptions(options); _injector->restart(); diff --git a/libraries/script-engine/src/SoundEffect.h b/libraries/script-engine/src/SoundEffect.h index 5d2a5095c1..656f98dd8d 100644 --- a/libraries/script-engine/src/SoundEffect.h +++ b/libraries/script-engine/src/SoundEffect.h @@ -22,6 +22,7 @@ class AudioInjector; class SoundEffect : public QQuickItem { Q_OBJECT Q_PROPERTY(QUrl source READ getSource WRITE setSource) + Q_PROPERTY(float volume READ getVolume WRITE setVolume) public: virtual ~SoundEffect(); @@ -29,9 +30,13 @@ public: QUrl getSource() const; void setSource(QUrl url); + float getVolume() const; + void setVolume(float volume); + Q_INVOKABLE void play(QVariant position); protected: QUrl _url; + float _volume { 1.0f }; SharedSoundPointer _sound; AudioInjector* _injector { nullptr }; };