Support Forum G3D Web Page |
Initializes the audio system.
More...
Classes | |
class | WeakCleanupArray |
Append-only dynamic array of weak pointers for objects to be shut down on AudioDevice::cleanup() More... | |
Public Types | |
enum | { ANY_FREE = -1 } |
Public Member Functions | |
AudioDevice () | |
~AudioDevice () | |
void | cleanup () |
Destroys all Sounds and AudioChannels and shuts down the FMOD library. More... | |
bool | enabled () const |
The value from init() of the enableSound argument. More... | |
void | init (bool enableSound=true, int numVirtualChannels=1000, unsigned int bufferLength=1024, int numBuffers=4) |
void | setListener3DAttributes (const CFrame &listenerFrame, const Vector3 &listenerVelocity) |
void | update () |
Invoke once per frame on the main thread to service the audio system. More... | |
Public Attributes | |
FMOD::System * | m_fmodSystem |
Static Public Attributes | |
static AudioDevice * | instance |
Protected Attributes | |
WeakCleanupArray< AudioChannel > | m_channelArray |
For cleaning up during shutdown. More... | |
bool | m_enable |
WeakCleanupArray< Sound > | m_soundArray |
For cleaning up during shutdown. More... | |
Friends | |
class | AudioChannel |
class | Sound |
Initializes the audio system.
G3D automatically initializes and cleans up AudioDevice and invokes AudioDevice::update from RenderDevice::swapBuffers, so this class is rarely accessed by programs explicitly.
AudioDevice does not depend on the graphics API at present. However, it is in the gfx layer of G3D instead of the base layer because future implementations may use the GPU for 3D sound simulation.
G3D::AudioDevice::AudioDevice | ( | ) |
G3D::AudioDevice::~AudioDevice | ( | ) |
void G3D::AudioDevice::cleanup | ( | ) |
Destroys all Sounds and AudioChannels and shuts down the FMOD library.
|
inline |
The value from init() of the enableSound argument.
void G3D::AudioDevice::init | ( | bool | enableSound = true , |
int | numVirtualChannels = 1000 , |
||
unsigned int | bufferLength = 1024 , |
||
int | numBuffers = 4 |
||
) |
numVirtualChannels | Number of channels to allocate. There is no reason not to make this fairly large. The limit is 4093 and 1000 is the default inherited from FMOD. |
enableSound | If false, then AudioDevice exists but no sounds will play and FMOD is not initialized. This is convenient for debugging a program that uses sound, so that Sound objects can still be instantiated but no disk access or sound-related performance delays will occur. |
bufferLength | Length of DSP buffer to use. Affects latency and 1024 is the default from FMOD. FMOD claims that the default results in 21.33 ms of latency at 48 khz (1024 / 48000 * 1000 = 21.33). FMOD warns that bufferlength is generally best left alone. |
numBuffers | Number of DSP buffers to use. Default from FMOD is 4. Similar to bufferLength, FMOD warns against changing this value. |
void G3D::AudioDevice::setListener3DAttributes | ( | const CFrame & | listenerFrame, |
const Vector3 & | listenerVelocity | ||
) |
void G3D::AudioDevice::update | ( | ) |
Invoke once per frame on the main thread to service the audio system.
RenderDevice::swapBuffers automatically invokes this.
|
friend |
|
friend |
|
static |
|
protected |
For cleaning up during shutdown.
|
protected |
Referenced by enabled().
FMOD::System* G3D::AudioDevice::m_fmodSystem |
|
protected |
For cleaning up during shutdown.