Overte C++ Documentation
SoundEffect.h
1 //
2 // Created by Anthony J. Thibault on 2017-01-30
3 // Copyright 2013-2017 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 
9 #ifndef hifi_SoundEffect_h
10 #define hifi_SoundEffect_h
11 
12 #include <QObject>
13 #include <QQuickItem>
14 
15 #include <SoundCache.h>
16 #include <AudioInjectorManager.h>
17 
18 // SoundEffect object, exposed to qml only, not interface JavaScript.
19 // This is used to play spatial sound effects on tablets/web entities from within QML.
20 
21 class SoundEffect : public QQuickItem {
22  Q_OBJECT
23  Q_PROPERTY(QUrl source READ getSource WRITE setSource)
24  Q_PROPERTY(float volume READ getVolume WRITE setVolume)
25 public:
26 
27  virtual ~SoundEffect();
28 
29  QUrl getSource() const;
30  void setSource(QUrl url);
31 
32  float getVolume() const;
33  void setVolume(float volume);
34 
35  Q_INVOKABLE void play(const QVariant& position);
36 protected:
37  QUrl _url;
38  float _volume { 1.0f };
39  SharedSoundPointer _sound;
40  AudioInjectorPointer _injector;
41 };
42 
43 #endif // hifi_SoundEffect_h