You.i Engine
YiSoundInstance.h
Go to the documentation of this file.
1 // ©️ You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_SOUND_INSTANCE_H_
3 #define _YI_SOUND_INSTANCE_H_
4 
5 #include <audio/YiAudioStream.h>
6 #include <signal/YiSignal.h>
7 #include <thread/YiMutex.h>
8 
9 class CYIAssetSound;
10 
22 {
23 public:
25  CYISoundInstance(const std::shared_ptr<CYIAssetSound> &pAssetSound);
26 
27  virtual ~CYISoundInstance();
28 
32  void Play();
33 
37  void Pause();
38 
42  void Stop();
43 
47  bool IsPlaying() const;
48 
52  void SetAsset(const std::shared_ptr<CYIAssetSound> &pAssetSound);
53 
57  void SetLooping(bool bShouldLoop);
58 
62  bool IsLooping() const;
63 
68  void SetVolume(float fVolume);
69 
73  float GetVolume() const;
74 
75  virtual bool Process(CYIAudioEngine *pAudioEngine, float *pData, uint32_t uFrameCount) override;
76 
78 
79 private:
80  std::shared_ptr<CYIAssetSound> m_pAssetSound;
81 
82  mutable CYIMutex m_mutex;
83  bool m_bPlaying;
84  bool m_bShouldLoop;
85  uint32_t m_uOffset;
86  float m_fVolume;
87 };
88 
91 #endif // _YI_SOUND_INSTANCE_H_
virtual ~CYISoundInstance()
CYISignal PlaybackCompleted
Definition: YiSoundInstance.h:77
Definition: YiMutex.h:110
Object representing a sound instance.
Definition: YiSoundInstance.h:21
virtual bool Process(CYIAudioEngine *pAudioEngine, float *pData, uint32_t uFrameCount) override
void SetLooping(bool bShouldLoop)
void SetVolume(float fVolume)
float GetVolume() const
Asset representing sound PCM data.
Definition: YiAssetSound.h:17
Base audio stream class that can process raw audio PCM.
Definition: YiAudioStream.h:22
void SetAsset(const std::shared_ptr< CYIAssetSound > &pAssetSound)
Object responsible for processing audio streams and output to the platform.
Definition: YiAudioEngine.h:30
bool IsLooping() const
Signals and slots are a thread-safe and flexible communication framework that will allow various obje...
Definition: YiSignal.h:164
bool IsPlaying() const