Support Forum       G3D Web Page     
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Friends | List of all members
G3D::AudioDevice Class Reference


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 AudioDeviceinstance
 

Protected Attributes

WeakCleanupArray< AudioChannelm_channelArray
 For cleaning up during shutdown. More...
 
bool m_enable
 
WeakCleanupArray< Soundm_soundArray
 For cleaning up during shutdown. More...
 

Friends

class AudioChannel
 
class Sound
 

Detailed Description


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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ANY_FREE 

Constructor & Destructor Documentation

◆ AudioDevice()

G3D::AudioDevice::AudioDevice ( )

◆ ~AudioDevice()

G3D::AudioDevice::~AudioDevice ( )

Member Function Documentation

◆ cleanup()

void G3D::AudioDevice::cleanup ( )

Destroys all Sounds and AudioChannels and shuts down the FMOD library.

◆ enabled()

bool G3D::AudioDevice::enabled ( ) const
inline

The value from init() of the enableSound argument.

◆ init()

void G3D::AudioDevice::init ( bool  enableSound = true,
int  numVirtualChannels = 1000,
unsigned int  bufferLength = 1024,
int  numBuffers = 4 
)
Parameters
numVirtualChannelsNumber 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.
enableSoundIf 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.
bufferLengthLength 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.
numBuffersNumber of DSP buffers to use. Default from FMOD is 4. Similar to bufferLength, FMOD warns against changing this value.

◆ setListener3DAttributes()

void G3D::AudioDevice::setListener3DAttributes ( const CFrame listenerFrame,
const Vector3 listenerVelocity 
)
See also
G3D::Scene::setActiveListener

◆ update()

void G3D::AudioDevice::update ( )

Invoke once per frame on the main thread to service the audio system.

RenderDevice::swapBuffers automatically invokes this.

Friends And Related Function Documentation

◆ AudioChannel

friend class AudioChannel
friend

◆ Sound

friend class Sound
friend

Member Data Documentation

◆ instance

AudioDevice* G3D::AudioDevice::instance
static

◆ m_channelArray

WeakCleanupArray<AudioChannel> G3D::AudioDevice::m_channelArray
protected

For cleaning up during shutdown.

◆ m_enable

bool G3D::AudioDevice::m_enable
protected

Referenced by enabled().

◆ m_fmodSystem

FMOD::System* G3D::AudioDevice::m_fmodSystem

◆ m_soundArray

WeakCleanupArray<Sound> G3D::AudioDevice::m_soundArray
protected

For cleaning up during shutdown.


documentation generated on Wed Nov 24 2021 08:01:53 using doxygen 1.8.15