cAudio  2.3.0
3d Audio Engine
Public Types | Public Member Functions | Protected Member Functions | List of all members
cAudio::cAudioManager Class Reference
Inheritance diagram for cAudio::cAudioManager:
Inheritance graph
[legend]
Collaboration diagram for cAudio::cAudioManager:
Collaboration graph
[legend]

Public Types

enum  Events {
  ON_INIT, ON_UPDATE, ON_RELEASE, ON_SOURCECREATE,
  ON_DECODERREGISTER, ON_DATASOURCEREGISTER
}
 

Public Member Functions

virtual bool initialize (const char *deviceName=0x0, int outputFrequency=-1, int eaxEffectSlots=4)
 Initializes the manager. More...
 
virtual void shutDown ()
 Shuts the manager down, cleaning up audio sources in the process. Does not clean up decoders, data sources, or event handlers.
 
virtual void update ()
 If threading is disabled, you must call this function every frame to update the playback buffers of audio sources. Otherwise it should not be called.
 
virtual IAudioSourcegetSoundByName (const char *name)
 Returns an Audio Source by its "name" and NULL if the name is not found. More...
 
virtual void releaseAllSources ()
 Releases ALL Audio Sources (but does not shutdown the manager)
 
virtual void release (IAudioSource *source)
 Releases a single Audio Source, removing it from the manager. More...
 
virtual IAudioSourceplay2D (const char *filename, bool playLooped=false, bool startPaused=false)
 Creates an Audio Source object using the highest priority data source that has the referenced filename. More...
 
virtual IAudioSourceplay3D (const char *filename, cVector3 position, bool playLooped=false, bool startPaused=false)
 Creates an Audio Source object using the highest priority data source that has the referenced filename. More...
 
virtual void setMasterVolume (float vol)
 Sets master volume. (valid range [0 - 1.0])
 
virtual float getMasterVolume () const
 Get the master volume.
 
virtual void setSpeedOfSound (float speed)
 Set Speed of Sound (for doppler computations)
 
virtual float getSpeedOfSound () const
 Get Speed of Sound (for doppler computations)
 
virtual void setDopplerFactor (float factor) const
 Set Doppler Factor.
 
virtual float getDopplerFactor () const
 Get Doppler Factor.
 
virtual void stopAllSounds ()
 Stops all playing sounds.
 
virtual IAudioSourcecreate (const char *name, const char *filename, bool stream=false)
 Creates an Audio Source object using the highest priority data source that has the referenced filename. More...
 
virtual IAudioSourcecreateFromMemory (const char *name, const char *data, size_t length, const char *extension)
 Creates an Audio Source from a memory buffer using a specific audio codec. More...
 
virtual IAudioSourcecreateFromRaw (const char *name, const char *data, size_t length, unsigned int frequency, AudioFormats format)
 Creates an Audio Source from raw audio data in a memory buffer. More...
 
virtual IAudioSourcecreateFromAudioBuffer (const char *name, AudioCaptureBuffer *pBiffer, unsigned int frequency, AudioFormats format)
 Creates an Audio Source from AudioCaptureBuffer in a memory buffer. More...
 
virtual IAudioBuffercreateBuffer (const char *filename)
 Creates a Audio Sample using the highest priority data source that has the referenced filename. More...
 
virtual IAudioSourcecreateStatic (IAudioBuffer *buffer)
 Creates an Audio Source from an Audio Buffer object (see createAudioBuffer()) More...
 
virtual bool registerAudioDecoder (IAudioDecoderFactory *factory, const char *extension)
 Register an Audio Decoder. More...
 
virtual void unRegisterAudioDecoder (const char *extension)
 Unregister a previously registered Audio Decoder. More...
 
virtual bool isAudioDecoderRegistered (const char *extension)
 Returns whether an audio decoder is currently registered for this file type. More...
 
virtual IAudioDecoderFactorygetAudioDecoderFactory (const char *extension)
 Returns a registered audio decoder factory. More...
 
virtual void unRegisterAllAudioDecoders ()
 Unregisters all attached Audio Decoders. More...
 
virtual bool registerDataSource (IDataSourceFactory *factory, const char *name, int priority)
 Registers a data source with this manager. More...
 
virtual void unRegisterDataSource (const char *name)
 Removes a previously registered data source. More...
 
virtual bool isDataSourceRegistered (const char *name)
 Returns whether a data source is currently registered under a certain name. More...
 
virtual IDataSourceFactorygetDataSourceFactory (const char *name)
 Returns a previously registered data source factory. More...
 
virtual void unRegisterAllDataSources ()
 Removes all previously registered data sources. More...
 
virtual void registerEventHandler (IManagerEventHandler *handler)
 Registers a new event handler with the manager. More...
 
virtual void unRegisterEventHandler (IManagerEventHandler *handler)
 Unregisters a previously registered event handler from the manager. More...
 
virtual void unRegisterAllEventHandlers ()
 Unregisters all previously registered event handlers from the manager. More...
 
virtual IListenergetListener ()
 Returns the interface for the listener.
 
virtual bool isUpdateThreadRunning ()
 Returns if the thread used to update all Audio Managers is running. More...
 
virtual cAudioMutexgetMutex ()
 
- Public Member Functions inherited from cAudio::cMemoryOverride
void * operator new (size_t size, const char *file, int line, const char *function)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *pointer)
 
void * operator new[] (size_t size, const char *file, int line, const char *function)
 
void * operator new[] (size_t size)
 
void operator delete (void *pointer)
 
void operator delete (void *pointer, void *)
 
void operator delete (void *pointer, const char *, int, const char *)
 
void operator delete[] (void *pointer)
 
void operator delete[] (void *pointer, const char *, int, const char *)
 

Protected Member Functions

virtual void run ()
 
IAudioSourcecreateAudioSource (IAudioDecoder *decoder, const cAudioString &audioName, const cAudioString &dataSource)
 

Detailed Description

Definition at line 23 of file cAudioManager.h.

Member Function Documentation

◆ create()

IAudioSource * cAudio::cAudioManager::create ( const char *  name,
const char *  filename,
bool  stream = false 
)
virtual

Creates an Audio Source object using the highest priority data source that has the referenced filename.

Parameters
nameName of the audio source.
filenamePath to the file to load audio data from.
streamWhether to stream the audio data or load it all into a memory buffer at the start. You should consider using streaming for really large sound files.
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 306 of file cAudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createBuffer()

IAudioBuffer * cAudio::cAudioManager::createBuffer ( const char *  filename)
virtual

Creates a Audio Sample using the highest priority data source that has the referenced filename.

Parameters
filenamePath to the file to load audio data from.
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 402 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ createFromAudioBuffer()

IAudioSource * cAudio::cAudioManager::createFromAudioBuffer ( const char *  name,
AudioCaptureBuffer pBiffer,
unsigned int  frequency,
AudioFormats  format 
)
virtual

Creates an Audio Source from AudioCaptureBuffer in a memory buffer.

Parameters
nameName of the audio source.
AudioCaptureBufferPointer to a AudioCaptureBuffer in memory to load the data from.
frequencyFrequency (or sample rate) of the audio data.
formatFormat of the audio data.
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 371 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ createFromMemory()

IAudioSource * cAudio::cAudioManager::createFromMemory ( const char *  name,
const char *  data,
size_t  length,
const char *  extension 
)
virtual

Creates an Audio Source from a memory buffer using a specific audio codec.

Parameters
nameName of the audio source.
dataPointer to a buffer in memory to load the data from.
lengthLength of the data buffer.
extensionExtension for the audio codec of the data in the memory buffer.
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 344 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ createFromRaw()

IAudioSource * cAudio::cAudioManager::createFromRaw ( const char *  name,
const char *  data,
size_t  length,
unsigned int  frequency,
AudioFormats  format 
)
virtual

Creates an Audio Source from raw audio data in a memory buffer.

Parameters
nameName of the audio source.
dataPointer to a buffer in memory to load the data from.
lengthLength of the data buffer.
frequencyFrequency (or sample rate) of the audio data.
formatFormat of the audio data.
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 376 of file cAudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createStatic()

IAudioSource * cAudio::cAudioManager::createStatic ( IAudioBuffer buffer)
virtual

Creates an Audio Source from an Audio Buffer object (see createAudioBuffer())

Parameters
bufferThe buffer to play, or NULL to create an empty static source
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 440 of file cAudioManager.cpp.

◆ getAudioDecoderFactory()

IAudioDecoderFactory * cAudio::cAudioManager::getAudioDecoderFactory ( const char *  extension)
virtual

Returns a registered audio decoder factory.

Parameters
extensionExtension for the audio decoder to return.
Returns
A pointer to the found factory or NULL if it could not be found.

Implements cAudio::IAudioManager.

Definition at line 478 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ getDataSourceFactory()

IDataSourceFactory * cAudio::cAudioManager::getDataSourceFactory ( const char *  name)
virtual

Returns a previously registered data source factory.

Parameters
nameName of the data source to return.
Returns
A pointer to the found factory or NULL if it could not be found.

Implements cAudio::IAudioManager.

Definition at line 544 of file cAudioManager.cpp.

◆ getSoundByName()

IAudioSource * cAudio::cAudioManager::getSoundByName ( const char *  name)
virtual

Returns an Audio Source by its "name" and NULL if the name is not found.

Parameters
nameName of the audio source to retrieve.
Returns
Pointer to the audio source object or NULL if it could not be found.

Implements cAudio::IAudioManager.

Definition at line 650 of file cAudioManager.cpp.

◆ initialize()

bool cAudio::cAudioManager::initialize ( const char *  deviceName = 0x0,
int  outputFrequency = -1,
int  eaxEffectSlots = 4 
)
virtual

Initializes the manager.

Parameters
deviceNameName of the device to create this manager for.
outputFrequencyFrequency of the output audio or -1 for the device default.
eaxEffectSlotsNumber of EFX effect slots to request. Has no effect if EFX is not supported or compiled out.
Returns
True on success, False if initialization of OpenAL failed.

Implements cAudio::IAudioManager.

Definition at line 29 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ isAudioDecoderRegistered()

bool cAudio::cAudioManager::isAudioDecoderRegistered ( const char *  extension)
virtual

Returns whether an audio decoder is currently registered for this file type.

Parameters
extensionExtension for the audio decoder to check for.
Returns
True if the specified decoder is registered or False if not.

Implements cAudio::IAudioManager.

Definition at line 470 of file cAudioManager.cpp.

◆ isDataSourceRegistered()

bool cAudio::cAudioManager::isDataSourceRegistered ( const char *  name)
virtual

Returns whether a data source is currently registered under a certain name.

Parameters
nameName of the data source to check for.
Returns
True if the specified data source is registered or False if not.

Implements cAudio::IAudioManager.

Definition at line 536 of file cAudioManager.cpp.

◆ isUpdateThreadRunning()

bool cAudio::cAudioManager::isUpdateThreadRunning ( )
virtual

Returns if the thread used to update all Audio Managers is running.

Note: Will always return false if threading is disabled. The library automatically shuts down the thread if no Audio Managers exist and will restart the thread on creation of a new manager.

Returns
True if the thread is currently running, false otherwise.

Implements cAudio::IAudioManager.

Definition at line 151 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ play2D()

IAudioSource * cAudio::cAudioManager::play2D ( const char *  filename,
bool  playLooped = false,
bool  startPaused = false 
)
virtual

Creates an Audio Source object using the highest priority data source that has the referenced filename.

Parameters
nameName of the audio source.
playLoopedif the sound is looped a IAudioSource is returned
startPausedif false the sound plays asap
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 167 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ play3D()

IAudioSource * cAudio::cAudioManager::play3D ( const char *  filename,
cVector3  position,
bool  playLooped = false,
bool  startPaused = false 
)
virtual

Creates an Audio Source object using the highest priority data source that has the referenced filename.

Parameters
nameName of the audio source.
positionThe start position of the sound.
playLoopedif the sound is looped a IAudioSource is returned
startPausedif false the sound plays asap
Returns
A pointer to an Audio Source or NULL if creation failed.

Implements cAudio::IAudioManager.

Definition at line 196 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ registerAudioDecoder()

bool cAudio::cAudioManager::registerAudioDecoder ( IAudioDecoderFactory factory,
const char *  extension 
)
virtual

Register an Audio Decoder.

Parameters
factoryPointer to the factory instance to use.
extensionExtension of the audio codec to register this decoder under. For example, .wav for a RIFF/wav decoder.
Returns
True on success, False if registration failed.

Implements cAudio::IAudioManager.

Definition at line 449 of file cAudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerDataSource()

bool cAudio::cAudioManager::registerDataSource ( IDataSourceFactory factory,
const char *  name,
int  priority 
)
virtual

Registers a data source with this manager.

Use this function to provide access to a custom resource manager, zip archive, vfs, or any other place you'd like to get audio files from.

Parameters
factoryPointer to the data source factory to register.
nameName for the data source (ie. Zip Archive or FileSystem)
priorityDetermines what order data sources are asked for a file. The higher the priority, the sooner they are asked. cAudio stops looking for a file as soon as any data source returns it.
Returns
True on success, False on failure to register.

Implements cAudio::IAudioManager.

Definition at line 501 of file cAudioManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerEventHandler()

void cAudio::cAudioManager::registerEventHandler ( IManagerEventHandler handler)
virtual

Registers a new event handler with the manager.

Parameters
handlerPointer to an event handler instance to register.

Implements cAudio::IAudioManager.

Definition at line 563 of file cAudioManager.cpp.

◆ release()

void cAudio::cAudioManager::release ( IAudioSource source)
virtual

Releases a single Audio Source, removing it from the manager.

Parameters
sourcePointer to the source to release.

Implements cAudio::IAudioManager.

Definition at line 701 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ unRegisterAllAudioDecoders()

void cAudio::cAudioManager::unRegisterAllAudioDecoders ( )
virtual

Unregisters all attached Audio Decoders.

Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself.

Implements cAudio::IAudioManager.

Definition at line 490 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ unRegisterAllDataSources()

void cAudio::cAudioManager::unRegisterAllDataSources ( )
virtual

Removes all previously registered data sources.

Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself.

Implements cAudio::IAudioManager.

Definition at line 556 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ unRegisterAllEventHandlers()

void cAudio::cAudioManager::unRegisterAllEventHandlers ( )
virtual

Unregisters all previously registered event handlers from the manager.

Note: Will not delete your event handler, you must take care of that yourself.

Implements cAudio::IAudioManager.

Definition at line 579 of file cAudioManager.cpp.

Here is the caller graph for this function:

◆ unRegisterAudioDecoder()

void cAudio::cAudioManager::unRegisterAudioDecoder ( const char *  extension)
virtual

Unregister a previously registered Audio Decoder.

Note that all current sound sources will still continue to use any currently allocated decoders. Will NOT delete any user added factory instance, you must do that yourself.

Parameters
extensionExtension for the audio decoder to remove.

Implements cAudio::IAudioManager.

Definition at line 458 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ unRegisterDataSource()

void cAudio::cAudioManager::unRegisterDataSource ( const char *  name)
virtual

Removes a previously registered data source.

Note that sound sources will still continue to use any currently allocated sources, so you may not be able to close an open zip/archive file handle until they are done. Will NOT delete any user added factory instance, you must do that yourself.

Parameters
nameName of the data source to unregister.

Implements cAudio::IAudioManager.

Definition at line 513 of file cAudioManager.cpp.

Here is the call graph for this function:

◆ unRegisterEventHandler()

void cAudio::cAudioManager::unRegisterEventHandler ( IManagerEventHandler handler)
virtual

Unregisters a previously registered event handler from the manager.

Note: Will not delete your event handler, you must take care of that yourself.

Parameters
handlerPointer to the event handler to remove.

Implements cAudio::IAudioManager.

Definition at line 571 of file cAudioManager.cpp.


The documentation for this class was generated from the following files: