b3SoundEngine.h 1.0 KB

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