1 #ifndef B3_SOUND_ENGINE_H 2 #define B3_SOUND_ENGINE_H 3 4 #include "Bullet3Common/b3Scalar.h" 5 #include "b3Sound_C_Api.h" 6 7 struct b3SoundMessage 8 { 9 int m_type; //B3_SOUND_SOURCE_TYPE 10 double m_amplitude; 11 12 double m_frequency; 13 int m_wavId; 14 15 double m_attackRate; 16 double m_decayRate; 17 double m_sustainLevel; 18 double m_releaseRate; 19 bool m_autoKeyOff; 20 b3SoundMessageb3SoundMessage21 b3SoundMessage() 22 : m_type(B3_SOUND_SOURCE_SINE_OSCILLATOR), 23 m_amplitude(0.5), 24 m_frequency(440), 25 m_wavId(-1), 26 m_attackRate(0.001), 27 m_decayRate(0.00001), 28 m_sustainLevel(0.5), 29 m_releaseRate(0.0005), 30 m_autoKeyOff(false) 31 { 32 } 33 }; 34 35 class b3SoundEngine 36 { 37 struct b3SoundEngineInternalData* m_data; 38 39 public: 40 b3SoundEngine(); 41 virtual ~b3SoundEngine(); 42 43 void init(int maxNumSoundSources, bool useRealTimeDac); 44 void exit(); 45 46 int getAvailableSoundSource(); 47 void startSound(int soundSourceIndex, b3SoundMessage msg); 48 void releaseSound(int soundSourceIndex); 49 50 int loadWavFile(const char* fileName); 51 52 double getSampleRate() const; 53 }; 54 55 #endif //B3_SOUND_ENGINE_H 56