Audio.h
Go to the documentation of this file.00001 00015 #ifndef __Audio_H__ 00016 #define __Audio_H__ 00017 00018 // Includes 00019 #include "Singleton.h" 00020 #include "Array.h" 00021 00022 // Forward declares 00023 class Music; 00024 class Platform_Sound_SoundStream; 00025 class Sound; 00026 class SoundInstance; 00027 class AudioFormat; 00028 class Asset; 00029 00030 const int MaxSimultaneousSounds = 16; 00031 const int Sound_BufferSize = 16*1024; 00032 const int Music_BufferSize=1024*256; // 256k sound buffer 00033 00034 // Audio 00035 class Audio:public Singleton<Audio> 00036 { 00037 public: 00038 Audio(); 00039 virtual ~Audio(); 00040 00041 void Update(); 00042 void Register(Music* stream); 00043 void Unregister(Music* stream); 00044 00045 unsigned int PlaySound(const Sound& sound, float priority = 0, bool looping = false); 00046 SoundInstance* GetSoundInstance(unsigned int handle); 00047 00048 Platform_Sound_SoundStream* AcquireSoundStream(SoundInstance* instance); 00049 void ReleaseSoundStream(SoundInstance* instance); 00050 00051 void* GetStreamBuffer(int minSize); 00052 private: 00053 Array<Music*> music_; 00054 00055 struct SoundInstanceEntry 00056 { 00057 unsigned int handle; 00058 SoundInstance* instance; 00059 }; 00060 Array<SoundInstanceEntry> soundInstances_; 00061 unsigned int currentSoundInstanceHandle_; 00062 00063 Array<Platform_Sound_SoundStream*> freeSoundStreams_; 00064 struct SoundStreamEntry 00065 { 00066 SoundInstance* instanceAssignedTo; 00067 Platform_Sound_SoundStream* stream; 00068 }; 00069 Array<SoundStreamEntry> assignedSoundStreams_; 00070 00071 void* streamBuffer_; 00072 int streamBufferSize_; 00073 00074 }; 00075 00076 #define siAudio Audio::GetInstance() 00077 00078 #endif /* __Audio_H__ */ 00079
Reproduction/republishing of any material on this site without permission is strictly prohibited.
