TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
tb_audio_controller.hpp
1 
10 #ifndef TurtleBrains_AudioController_hpp
11 #define TurtleBrains_AudioController_hpp
12 
13 #include <turtle_brains/core/tb_configuration.hpp>
14 #if defined(tb_with_audio)
15 
16 #include <turtle_brains/core/tb_resource_handle.hpp>
17 #include <turtle_brains/core/tb_types.hpp>
18 
19 namespace tbImplementation { class AudioHandleSaver { }; }
20 
21 namespace TurtleBrains
22 {
23  namespace Audio
24  {
25 
31 
35  AudioHandle InvalidAudio(void);
36 
41  typedef tbCore::uint32 AudioChannel;
42 
47  constexpr AudioChannel InvalidChannel(void) { return 0; }
48 
53  class AudioController
54  {
55  public:
62  explicit AudioController(const AudioHandle& audioHandle = InvalidAudio());
63 
67  AudioController(const AudioController& other);
68 
74  ~AudioController(void);
75 
83  void Play(const bool isLooping = false);
84 
89  void Pause(void);
90 
95  void Stop(void);
96 
101  void StopLooping(void);
102 
108  float GetPitch(void) const;
109 
114  void SetPitch(const float pitch);
115 
121  float GetVolume(void) const;
122 
129  void SetVolume(const float volume);
130 
138  void FadeVolumeTo(const float desiredVolume, const tbCore::uint32 timeInMilliseconds);
139 
153  void SetLoopPoints(const tbCore::uint32 startSample, const tbCore::uint32 endSample);
154 
159  bool IsComplete(void) const;
160 
161  friend class AudioManager;
162  private:
163  AudioHandle mAudioData;
164  AudioChannel mAudioChannel;
165  };
166 
167  }; /* namespace Audio */
168 }; /* namespace TurtleBrains */
169 
170 namespace tbAudio = TurtleBrains::Audio;
171 
172 #endif /* tb_with_audio */
173 #endif /* TurtleBrains_AudioController_hpp */
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
Definition: tb_resource_handle.hpp:24
Bring some sound into the games created with TurtleBrains using a very simple fire and forget AudioMa...
uint32_t uint32
Unsigned integer with a size of 32 bits. Supports values from 0 to 4294967295, (2^32 - 1)...
Definition: tb_types.hpp:28
Definition: tb_application_dialog.hpp:19