|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NLSOUND::CAudioMixerUser Class ReferenceImplementation of UAudioMixer.
More...
#include <audio_mixer_user.h>
Inheritance diagram for NLSOUND::CAudioMixerUser:
List of all members.
Public Methods |
| CAudioMixerUser () |
| Constructor. More...
|
virtual | ~CAudioMixerUser () |
| Destructor. More...
|
virtual void | init () |
| Initialization. More...
|
virtual void | setPriorityReserve (TSoundPriority priorityChannel, uint reserve) |
| Set the priority channel reserve. More...
|
virtual void | setLowWaterMark (uint value) |
| Set the Low water mark. More...
|
virtual void | reset () |
| Resets the audio system (deletes all the sources, include envsounds). More...
|
virtual void | enable (bool b) |
| Disables or reenables the sound. More...
|
virtual uint32 | loadSampleBank (bool async, const std::string &filename, std::vector< std::string > *notfoundfiles=NULL) |
| Load buffers. More...
|
virtual bool | unloadSampleBank (const std::string &filename) |
| Unload buffers. More...
|
virtual void | reloadSampleBanks (bool async) |
| Reload all the sample bank. More...
|
virtual uint32 | getLoadedSampleSize () |
| Return the total size in byte of loaded samples. More...
|
virtual TSoundId | getSoundId (const std::string &name) |
| Get a TSoundId from a name (returns NULL if not found). More...
|
virtual USource * | createSource (const std::string &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam=NULL, CSoundContext *context=0) |
| Add a logical sound source (returns NULL if name not found). More...
|
virtual USource * | createSource (TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam=NULL, CSoundContext *context=0) |
| Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*). More...
|
void | addSource (CSourceCommon *source) |
| Add a source which was created by an EnvSound. More...
|
virtual void | removeSource (CSourceCommon *source) |
| Delete a logical sound source. More...
|
virtual void | setListenerPos (const NLMISC::CVector &pos) |
| Use this method to set the listener position instead of using getListener->setPos(); It's because we have to update the background sounds in this case. More...
|
virtual UListener * | getListener () |
| Return the listener interface. More...
|
virtual void | selectEnvEffects (const std::string &tag) |
| Choose the environmental effect(s) corresponding to tag. More...
|
virtual void | update () |
| Update audio mixer (call evenly). More...
|
virtual void | getSoundNames (std::vector< std::string > &names) const |
| Return the names of the sounds (call this method after loadSounds()). More...
|
virtual uint | getPolyphony () const |
| Return the number of mixing tracks (voices). More...
|
virtual uint | getSourcesNumber () const |
| Return the number of sources (slow). More...
|
virtual uint | getPlayingSourcesNumber () const |
| Return the number of playing sources (slow). More...
|
virtual uint | getNumberAvailableTracks () const |
| Return the number of available tracks. More...
|
virtual std::string | getSourcesStats () const |
| Return a string showing the playing sources (slow). More...
|
void | applyListenerMove (const NLMISC::CVector &listenerpos) |
| Take a listener's move into account. More...
|
const NLMISC::CVector & | getListenPosVector () const |
| Return the listen pos vector. More...
|
virtual void | setSamplePath (const std::string &path) |
| Set the global path to the sample banks. More...
|
CBackgroundSoundManager * | getBackgroundSoundManager () |
virtual void | writeProfile (std::ostream &out) |
| Write profiling information about the mixer to the output stream. More...
|
virtual void | loadBackgroundSoundFromRegion (const NLLIGO::CPrimRegion ®ion) |
virtual void | loadBackgroundEffectsFromRegion (const NLLIGO::CPrimRegion ®ion) |
virtual void | loadBackgroundSamplesFromRegion (const NLLIGO::CPrimRegion ®ion) |
virtual void | loadBackgroundSound (const std::string &continent) |
virtual void | playBackgroundSound () |
virtual void | stopBackgroundSound () |
ISoundDriver * | getSoundDriver () |
| Return the sound driver. More...
|
void | registerBufferAssoc (CSound *sound, IBuffer *buffer) |
void | unregisterBufferAssoc (CSound *sound, IBuffer *buffer) |
void | bufferUnloaded (IBuffer *buffer) |
void | setBackgroundFlags (const TBackgroundFlags &backgroundFlags) |
CTrack * | getFreeTrack (CSimpleSource *source) |
void | freeTrack (CTrack *track) |
void | incPlayingSource () |
void | decPlayingSource () |
void | registerUpdate (IMixerUpdate *pmixerUpdate) |
| Register an object in the update list. More...
|
void | unregisterUpdate (IMixerUpdate *pmixerUpdate) |
| Unregister an object from the update list. More...
|
void | addEvent (IMixerEvent *pmixerEvent, const NLMISC::TTime &date) |
| Add an event in the future. More...
|
void | removeEvents (IMixerEvent *pmixerEvent) |
| Remove any event programmed for this object. More...
|
void | addSourceWaitingForPlay (CSimpleSource *source) |
| Add a source for play as possible (for non discadable sound). More...
|
uint32 | curTime () |
Static Public Methods |
CAudioMixerUser * | instance () |
| Return the audio mixer object. More...
|
Public Attributes |
TSourceContainer | _Sources |
| All Logical sources. More...
|
uint32 | _PlayingSources |
| The source that wanted to play. More...
|
CTrack * | _Tracks [MAX_TRACKS] |
| Physical sources array. More...
|
uint | _NbTracks |
| Size of the physical sources array (must be <= MAX_TRACKS). More...
|
uint | _MaxNbTracks |
| Max _NbTracks. More...
|
bool | _Leaving |
| Flag set in destructor. More...
|
NLMISC::TTicks | _StartTime |
double | _UpdateTime |
double | _CreateTime |
uint32 | _UpdateCount |
uint32 | _CreateCount |
Protected Methods |
void | getFreeTracks (uint nb, CTrack **tracks) |
| Returns nb available tracks (or NULL). More...
|
virtual void | getPlayingSoundsPos (std::vector< std::pair< bool, NLMISC::CVector > > &pos) |
| See removeSource(USource*) and removeMySource(USource*). More...
|
Protected Attributes |
TMixerUpdateContainer | _UpdateList |
| List of object to update. More...
|
std::vector< std::pair< IMixerUpdate *,
bool > > | _UpdateEventList |
| List of update to add or remove (bool param of the pair). More...
|
TTimedEventContainer | _EventList |
| List of event ordered by time. More...
|
TEventContainer | _Events |
| List of event ordered by event ptr with there respective multimap iterator. More...
|
std::vector< std::pair< NLMISC::TTime,
IMixerEvent * > > | _EventListUpdate |
| List of update for the event list. More...
|
Private Types |
typedef std::hash_set< CSourceCommon *,
THashPtr< CSourceCommon * > > | TSourceContainer |
typedef std::hash_set< IMixerUpdate *,
THashPtr< IMixerUpdate * > > | TMixerUpdateContainer |
typedef std::hash_map< IBuffer *,
std::vector< class CSound * >,
THashPtr< IBuffer * > > | TBufferToSourceContainer |
typedef std::multimap< NLMISC::TTime,
IMixerEvent * > | TTimedEventContainer |
typedef std::multimap< IMixerEvent *,
TTimedEventContainer::iterator > | TEventContainer |
Private Attributes |
std::vector< CTrack * > | _FreeTracks |
| The vector of curently free tracks. More...
|
std::list< CSimpleSource * > | _SourceWaitingForPlay |
| The list of non discardable sound to play as soon as possible in order of arrival. More...
|
uint32 | _PriorityReserve [NbSoundPriorities] |
| Table of track reserve for each priority. More...
|
uint32 | _ReserveUsage [NbSoundPriorities] |
| Table of current playing source for each priority. More...
|
uint32 | _LowWaterMark |
| Low water mark. After this number of free voice is reach, reserve can't be overloaded. More...
|
ISoundDriver * | _SoundDriver |
| The sound driver instance. More...
|
CBackgroundSoundManager * | _BackgroundSoundManager |
| Intance of the background sound manager. More...
|
CListenerUser | _Listener |
| The listener instance. More...
|
NLMISC::CVector | _ListenPosition |
| Listener position vector. More...
|
std::string | _SamplePath |
| The path to the sample banks. This should be specified in the config file. More...
|
TBufferToSourceContainer | _BufferToSources |
| Assoc between buffer and source. Used when buffers are unloaded. More...
|
CEnvEffect * | _CurEnvEffect |
| Current effect. More...
|
Static Private Attributes |
CAudioMixerUser * | _Instance = NULL |
| The audio mixer singleton instance. More...
|
Friends |
struct | displaySoundInfoClass |
Detailed Description
Implementation of UAudioMixer.
The logical sources (_Sources) are the sources representing all entities in the world, from the client's point of view. The tracks (_Tracks) are the physical sources played by the sound driver. Their number is small.
When there are more sources than tracks, the process of choosing which sources go into the tracks is called "balancing". The source are auto-balanced according to the argument passed to init(). The sources are also balanced when
- Adding a new source
- Removing a new source
- Entering/Exiting from an envsound area
Important: The user is responsible for deleting the sources that have been allocated by createSource(), before deleting the audio mixer object.
-
Author:
-
Olivier Cado , Nevrax France
-
Date:
-
2001
Definition at line 97 of file audio_mixer_user.h.
Member Typedef Documentation
typedef std::hash_map<IBuffer*, std::vector<class CSound*>, THashPtr<IBuffer*> > NLSOUND::CAudioMixerUser::TBufferToSourceContainer [private]
|
|
typedef std::multimap<IMixerEvent*, TTimedEventContainer::iterator> NLSOUND::CAudioMixerUser::TEventContainer [private]
|
|
Constructor & Destructor Documentation
NLSOUND::CAudioMixerUser::CAudioMixerUser |
( |
|
) |
|
|
NLSOUND::CAudioMixerUser::~CAudioMixerUser |
( |
|
) |
[virtual] |
|
Member Function Documentation
|
Add an event in the future.
|
void NLSOUND::CAudioMixerUser::addSource |
( |
CSourceCommon * |
source |
) |
|
|
void NLSOUND::CAudioMixerUser::addSourceWaitingForPlay |
( |
CSimpleSource * |
source |
) |
|
|
void NLSOUND::CAudioMixerUser::applyListenerMove |
( |
const NLMISC::CVector & |
listenerpos |
) |
|
|
void NLSOUND::CAudioMixerUser::bufferUnloaded |
( |
IBuffer * |
buffer |
) |
|
|
|
Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*).
Implements NLSOUND::UAudioMixer.
Definition at line 775 of file audio_mixer_user.cpp.
References _CreateCount, _CreateTime, _ListenPosition, _profile, createSource, curTime, getNumberAvailableTracks, getPlayingSourcesNumber, getSourcesNumber, id, nlassert, nldebug, nlwarning, NLSOUND::TSoundId, NLSOUND::TSpawnEndCallback, and NLMISC::TTicks. |
USource * NLSOUND::CAudioMixerUser::createSource |
( |
const std::string & |
name, |
|
|
bool |
spawn = false, |
|
|
TSpawnEndCallback |
cb = NULL, |
|
|
void * |
cbUserParam = NULL, |
|
|
CSoundContext * |
context = 0 |
|
) |
[virtual] |
|
|
Add a logical sound source (returns NULL if name not found).
If spawn is true, the source will auto-delete after playing. If so, the return USource* pointer is valid only before the time when calling play() plus the duration of the sound. You can pass a callback function that will be called (if not NULL) just before deleting the spawned source.
Implements NLSOUND::UAudioMixer.
Definition at line 874 of file audio_mixer_user.cpp.
References getSoundId, and NLSOUND::TSpawnEndCallback.
Referenced by createSource. |
uint32 NLSOUND::CAudioMixerUser::curTime |
( |
|
) |
[inline] |
|
void NLSOUND::CAudioMixerUser::decPlayingSource |
( |
|
) |
[inline] |
|
void NLSOUND::CAudioMixerUser::enable |
( |
bool |
b |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::freeTrack |
( |
CTrack * |
track |
) |
|
|
|
Definition at line 481 of file audio_mixer_user.cpp.
References _FreeTracks, _ListenPosition, _LowWaterMark, _NbTracks, _PriorityReserve, _ReserveUsage, _SourceWaitingForPlay, _Tracks, NLSOUND::HighestPri, nldebug, and nlwarning. |
void NLSOUND::CAudioMixerUser::getFreeTracks |
( |
uint |
nb, |
|
|
CTrack ** |
tracks |
|
) |
[protected] |
|
virtual UListener* NLSOUND::CAudioMixerUser::getListener |
( |
|
) |
[inline, virtual] |
|
const NLMISC::CVector& NLSOUND::CAudioMixerUser::getListenPosVector |
( |
|
) |
const [inline] |
|
uint32 NLSOUND::CAudioMixerUser::getLoadedSampleSize |
( |
|
) |
[virtual] |
|
uint NLSOUND::CAudioMixerUser::getNumberAvailableTracks |
( |
|
) |
const [virtual] |
|
void NLSOUND::CAudioMixerUser::getPlayingSoundsPos |
( |
std::vector< std::pair< bool, NLMISC::CVector > > & |
pos |
) |
[protected, virtual] |
|
uint NLSOUND::CAudioMixerUser::getPlayingSourcesNumber |
( |
|
) |
const [virtual] |
|
virtual uint NLSOUND::CAudioMixerUser::getPolyphony |
( |
|
) |
const [inline, virtual] |
|
TSoundId NLSOUND::CAudioMixerUser::getSoundId |
( |
const std::string & |
name |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::getSoundNames |
( |
std::vector< std::string > & |
names |
) |
const [virtual] |
|
virtual uint NLSOUND::CAudioMixerUser::getSourcesNumber |
( |
|
) |
const [inline, virtual] |
|
string NLSOUND::CAudioMixerUser::getSourcesStats |
( |
|
) |
const [virtual] |
|
void NLSOUND::CAudioMixerUser::incPlayingSource |
( |
|
) |
[inline] |
|
void NLSOUND::CAudioMixerUser::init |
( |
|
) |
[virtual] |
|
|
Initialization.
In case of failure, can throw one of these ESoundDriver (Exception) objects: ESoundDriverNotFound, ESoundDriverCorrupted, ESoundDriverOldVersion, ESoundDriverUnknownVersion.
The sources will be auto-balanced every "balance_period" calls to update() (set 0 for "never auto-balance")
Implements NLSOUND::UAudioMixer.
Definition at line 276 of file audio_mixer_user.cpp.
References _BackgroundSoundManager, _FreeTracks, _Instance, _Listener, _LowWaterMark, _MaxNbTracks, _NbTracks, _PriorityReserve, _profile, _ReserveUsage, _SoundDriver, _StartTime, _Tracks, NLSOUND::MAX_TRACKS, NLSOUND::NbSoundPriorities, nldebug, and nlinfo. |
CAudioMixerUser* NLSOUND::CAudioMixerUser::instance |
( |
|
) |
[inline, static] |
|
virtual void NLSOUND::CAudioMixerUser::loadBackgroundEffectsFromRegion |
( |
const NLLIGO::CPrimRegion & |
region |
) |
[virtual] |
|
virtual void NLSOUND::CAudioMixerUser::loadBackgroundSamplesFromRegion |
( |
const NLLIGO::CPrimRegion & |
region |
) |
[virtual] |
|
virtual void NLSOUND::CAudioMixerUser::loadBackgroundSound |
( |
const std::string & |
continent |
) |
[virtual] |
|
virtual void NLSOUND::CAudioMixerUser::loadBackgroundSoundFromRegion |
( |
const NLLIGO::CPrimRegion & |
region |
) |
[virtual] |
|
uint32 NLSOUND::CAudioMixerUser::loadSampleBank |
( |
bool |
async, |
|
|
const std::string & |
filename, |
|
|
std::vector< std::string > * |
notfoundfiles = NULL |
|
) |
[virtual] |
|
virtual void NLSOUND::CAudioMixerUser::playBackgroundSound |
( |
|
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::registerBufferAssoc |
( |
CSound * |
sound, |
|
|
IBuffer * |
buffer |
|
) |
|
|
void NLSOUND::CAudioMixerUser::registerUpdate |
( |
IMixerUpdate * |
pmixerUpdate |
) |
|
|
|
Register an object in the update list.
|
void NLSOUND::CAudioMixerUser::reloadSampleBanks |
( |
bool |
async |
) |
[virtual] |
|
|
Reload all the sample bank.
Thid method use provided for use in a sound editor or sound tool to update the list of available samples. \async If true, the samples are loaded in a background thread.
Implements NLSOUND::UAudioMixer.
Definition at line 474 of file audio_mixer_user.cpp. |
void NLSOUND::CAudioMixerUser::removeEvents |
( |
IMixerEvent * |
pmixerEvent |
) |
|
|
|
Remove any event programmed for this object.
|
void NLSOUND::CAudioMixerUser::removeSource |
( |
CSourceCommon * |
source |
) |
[virtual] |
|
|
Delete a logical sound source.
If you don't call it, the source will be auto-deleted when deleting the audio mixer object
Definition at line 882 of file audio_mixer_user.cpp.
References _Sources, and nlassert. |
void NLSOUND::CAudioMixerUser::reset |
( |
|
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::selectEnvEffects |
( |
const std::string & |
tag |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::setBackgroundFlags |
( |
const TBackgroundFlags & |
backgroundFlags |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::setListenerPos |
( |
const NLMISC::CVector & |
pos |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::setLowWaterMark |
( |
uint |
value |
) |
[virtual] |
|
|
Set the Low water mark.
This value is use to mute sound source that try to play when there priority channel is full (see setPriorityReserve). Set a value 1 to 4 to keep some extra track available when a HighestPri source need to play. By default, the value is set to 0, witch mean no special treatment is done and the mixer will mute sound with no user control at all. Note also that the availability of a track is not guarantie if the sum of the priority reserve (see setPriorityReserve) is grater than the number od available tracks (witch is almos alwais the case). But this value will help the mixer make it's best.
Implements NLSOUND::UAudioMixer.
Definition at line 173 of file audio_mixer_user.cpp.
References _LowWaterMark, _NbTracks, min, and value. |
void NLSOUND::CAudioMixerUser::setPriorityReserve |
( |
TSoundPriority |
priorityChannel, |
|
|
uint |
reserve |
|
) |
[virtual] |
|
|
Set the priority channel reserve.
Each priority channel can be assign a restrictive reserve value. This value is used when the number free track available for playing drop under the low water mark value (see setLowWaterMark). The mixer count the number of playing source in each priority channel. A priority channel can orverflow it's reserve value only if the low water mark is not reach. In other word, when the number of played source increase, you can control a 'smooth' cut in priority layer. The idea is to try to keep some free track for the HighestPri source. By default, reserve are set for each channel to the number of available tracks.
Implements NLSOUND::UAudioMixer.
Definition at line 168 of file audio_mixer_user.cpp.
References _NbTracks, _PriorityReserve, min, and NLSOUND::TSoundPriority. |
virtual void NLSOUND::CAudioMixerUser::setSamplePath |
( |
const std::string & |
path |
) |
[inline, virtual] |
|
virtual void NLSOUND::CAudioMixerUser::stopBackgroundSound |
( |
|
) |
[virtual] |
|
bool NLSOUND::CAudioMixerUser::unloadSampleBank |
( |
const std::string & |
filename |
) |
[virtual] |
|
void NLSOUND::CAudioMixerUser::unregisterBufferAssoc |
( |
CSound * |
sound, |
|
|
IBuffer * |
buffer |
|
) |
|
|
void NLSOUND::CAudioMixerUser::unregisterUpdate |
( |
IMixerUpdate * |
pmixerUpdate |
) |
|
|
|
Unregister an object from the update list.
|
void NLSOUND::CAudioMixerUser::update |
( |
|
) |
[virtual] |
|
|
Update audio mixer (call evenly).
Implements NLSOUND::UAudioMixer.
Definition at line 592 of file audio_mixer_user.cpp.
References _EventList, _EventListUpdate, _Events, _NbTracks, _SoundDriver, _Sources, _SourceWaitingForPlay, _Tracks, _UpdateCount, _UpdateEventList, _UpdateList, _UpdateTime, NLMISC::CTime::getLocalTime, nldebug, range, NLMISC::TTicks, and NLMISC::TTime. |
void NLSOUND::CAudioMixerUser::writeProfile |
( |
std::ostream & |
out |
) |
[virtual] |
|
|
Write profiling information about the mixer to the output stream.
Implements NLSOUND::UAudioMixer.
Definition at line 181 of file audio_mixer_user.cpp.
References _CreateCount, _CreateTime, _NbTracks, _PlayingSources, _ReserveUsage, _SoundDriver, _SourceWaitingForPlay, _UpdateCount, _UpdateTime, curTime, getNumberAvailableTracks, getPlayingSourcesNumber, NLSOUND::HighestPri, NLSOUND::HighPri, NLSOUND::LowPri, NLSOUND::MidPri, and sint. |
Friends And Related Function Documentation
friend struct displaySoundInfoClass [friend]
|
|
Member Data Documentation
|
Assoc between buffer and source. Used when buffers are unloaded.
Definition at line 392 of file audio_mixer_user.h. |
uint32 NLSOUND::CAudioMixerUser::_CreateCount
|
|
double NLSOUND::CAudioMixerUser::_CreateTime
|
|
CEnvEffect* NLSOUND::CAudioMixerUser::_CurEnvEffect [private]
|
|
|
List of event ordered by event ptr with there respective multimap iterator.
Definition at line 323 of file audio_mixer_user.h.
Referenced by update. |
std::vector<CTrack*> NLSOUND::CAudioMixerUser::_FreeTracks [private]
|
|
CAudioMixerUser * NLSOUND::CAudioMixerUser::_Instance = NULL [static, private]
|
|
bool NLSOUND::CAudioMixerUser::_Leaving
|
|
uint32 NLSOUND::CAudioMixerUser::_LowWaterMark [private]
|
|
uint NLSOUND::CAudioMixerUser::_MaxNbTracks
|
|
uint NLSOUND::CAudioMixerUser::_NbTracks
|
|
uint32 NLSOUND::CAudioMixerUser::_PlayingSources
|
|
uint32 NLSOUND::CAudioMixerUser::_PriorityReserve[NbSoundPriorities] [private]
|
|
uint32 NLSOUND::CAudioMixerUser::_ReserveUsage[NbSoundPriorities] [private]
|
|
std::string NLSOUND::CAudioMixerUser::_SamplePath [private]
|
|
ISoundDriver* NLSOUND::CAudioMixerUser::_SoundDriver [private]
|
|
uint32 NLSOUND::CAudioMixerUser::_UpdateCount
|
|
std::vector<std::pair<IMixerUpdate*, bool> > NLSOUND::CAudioMixerUser::_UpdateEventList [protected]
|
|
double NLSOUND::CAudioMixerUser::_UpdateTime
|
|
The documentation for this class was generated from the following files:
|
|