2017-04-27 04:31:01 +00:00
|
|
|
#ifndef B3_SOUND_ENGINE_H
|
|
|
|
#define B3_SOUND_ENGINE_H
|
|
|
|
|
|
|
|
#include "Bullet3Common/b3Scalar.h"
|
2017-04-28 19:39:51 +00:00
|
|
|
#include "b3Sound_C_Api.h"
|
2017-04-27 04:31:01 +00:00
|
|
|
|
2017-04-28 18:35:00 +00:00
|
|
|
struct b3SoundMessage
|
|
|
|
{
|
2018-09-23 21:17:31 +00:00
|
|
|
int m_type; //B3_SOUND_SOURCE_TYPE
|
2017-04-28 18:35:00 +00:00
|
|
|
double m_amplitude;
|
|
|
|
|
|
|
|
double m_frequency;
|
|
|
|
int m_wavId;
|
|
|
|
|
2017-04-28 19:39:51 +00:00
|
|
|
double m_attackRate;
|
|
|
|
double m_decayRate;
|
|
|
|
double m_sustainLevel;
|
|
|
|
double m_releaseRate;
|
2017-05-01 18:14:09 +00:00
|
|
|
bool m_autoKeyOff;
|
2017-04-28 19:39:51 +00:00
|
|
|
|
|
|
|
b3SoundMessage()
|
2018-09-23 21:17:31 +00:00
|
|
|
: m_type(B3_SOUND_SOURCE_SINE_OSCILLATOR),
|
|
|
|
m_amplitude(0.5),
|
|
|
|
m_frequency(440),
|
|
|
|
m_wavId(-1),
|
|
|
|
m_attackRate(0.001),
|
|
|
|
m_decayRate(0.00001),
|
|
|
|
m_sustainLevel(0.5),
|
|
|
|
m_releaseRate(0.0005),
|
|
|
|
m_autoKeyOff(false)
|
2017-04-28 19:39:51 +00:00
|
|
|
{
|
|
|
|
}
|
2017-04-28 18:35:00 +00:00
|
|
|
};
|
|
|
|
|
2017-04-27 04:31:01 +00:00
|
|
|
class b3SoundEngine
|
|
|
|
{
|
|
|
|
struct b3SoundEngineInternalData* m_data;
|
2018-09-23 21:17:31 +00:00
|
|
|
|
|
|
|
public:
|
2017-04-27 04:31:01 +00:00
|
|
|
b3SoundEngine();
|
|
|
|
virtual ~b3SoundEngine();
|
|
|
|
|
2017-04-28 18:35:00 +00:00
|
|
|
void init(int maxNumSoundSources, bool useRealTimeDac);
|
2017-04-27 04:31:01 +00:00
|
|
|
void exit();
|
|
|
|
|
2017-04-28 18:35:00 +00:00
|
|
|
int getAvailableSoundSource();
|
|
|
|
void startSound(int soundSourceIndex, b3SoundMessage msg);
|
|
|
|
void releaseSound(int soundSourceIndex);
|
2017-04-27 04:31:01 +00:00
|
|
|
|
|
|
|
int loadWavFile(const char* fileName);
|
|
|
|
|
|
|
|
double getSampleRate() const;
|
|
|
|
};
|
|
|
|
|
2018-09-23 21:17:31 +00:00
|
|
|
#endif //B3_SOUND_ENGINE_H
|