# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLSOUND::UAudioMixer Class Reference

Game interface for audio. More...

#include <u_audio_mixer.h>

Inheritance diagram for NLSOUND::UAudioMixer:

NLSOUND::CAudioMixerUser List of all members.

Public Methods

virtual void init ()=0
 Initialization. More...

virtual void setPriorityReserve (TSoundPriority priorityChannel, uint reserve)=0
 Set the priority channel reserve. More...

virtual void setLowWaterMark (uint value)=0
 Set the Low water mark. More...

virtual void reset ()=0
 Resets the audio system (deletes all the sources, include envsounds). More...

virtual void enable (bool b)=0
 Disables or reenables the sound. More...

virtual uint32 loadSampleBank (bool async, const std::string &filename, std::vector< std::string > *notfoundfiles=NULL)=0
 Load buffers. More...

virtual bool unloadSampleBank (const std::string &filename)=0
 Unload buffers. More...

virtual void reloadSampleBanks (bool async)=0
 Reload all the sample bank. More...

virtual uint32 getLoadedSampleSize ()=0
 Return the total size in byte of loaded samples. More...

virtual TSoundId getSoundId (const std::string &name)=0
 Get a TSoundId from a name (returns NULL if not found). More...

virtual USourcecreateSource (const std::string &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam=NULL, CSoundContext *context=0)=0
 Add a logical sound source (returns NULL if name not found). More...

virtual USourcecreateSource (TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam=NULL, CSoundContext *context=0)=0
 Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*). More...

virtual void setListenerPos (const NLMISC::CVector &pos)=0
 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 UListenergetListener ()=0
 Return the listener interface. More...

virtual void selectEnvEffects (const std::string &tag)=0
 Choose the environmental effect(s) corresponding to tag. More...

virtual void update ()=0
 Update audio mixer (call evenly). More...

virtual void getSoundNames (std::vector< std::string > &names) const=0
 Return the names of the sounds (call this method after loadSounds()). More...

virtual uint getPolyphony () const=0
 Return the number of mixing tracks (voices). More...

virtual uint getSourcesNumber () const=0
 Return the number of sources. More...

virtual uint getPlayingSourcesNumber () const=0
 Return the number of playing sources. More...

virtual uint getNumberAvailableTracks () const=0
 Return the number of available tracks. More...

virtual std::string getSourcesStats () const=0
 Return a string showing the playing sources. More...

virtual void setSamplePath (const std::string &path)=0
 Set the global path to the sample banks. More...

virtual void writeProfile (std::ostream &out)=0
 Write profiling information about the mixer to the output stream. More...

virtual void setBackgroundFlags (const TBackgroundFlags &backgroundFlags)=0
virtual void loadBackgroundSoundFromRegion (const NLLIGO::CPrimRegion &region)=0
virtual void loadBackgroundEffectsFromRegion (const NLLIGO::CPrimRegion &region)=0
virtual void loadBackgroundSamplesFromRegion (const NLLIGO::CPrimRegion &region)=0
virtual void loadBackgroundSound (const std::string &continent)=0
virtual void playBackgroundSound ()=0
virtual void stopBackgroundSound ()=0
virtual void getPlayingSoundsPos (std::vector< std::pair< bool, NLMISC::CVector > > &pos)=0
virtual ~UAudioMixer ()
 Destructor. More...


Static Public Methods

UAudioMixer * createAudioMixer ()
 Create the audio mixer singleton and return a pointer to its instance. More...


Protected Methods

 UAudioMixer ()
 Constructor. More...


Detailed Description

Game interface for audio.

The logical sources represent all entities in the world, from the client's point of view. Their number can be higher than the number of simultaneous playable sound on the soundcard.

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 65 of file u_audio_mixer.h.


Constructor & Destructor Documentation

virtual NLSOUND::UAudioMixer::~UAudioMixer   [inline, virtual]
 

Destructor.

Definition at line 225 of file u_audio_mixer.h.

NLSOUND::UAudioMixer::UAudioMixer   [inline, protected]
 

Constructor.

Definition at line 230 of file u_audio_mixer.h.


Member Function Documentation

UAudioMixer * NLSOUND::UAudioMixer::createAudioMixer   [static]
 

Create the audio mixer singleton and return a pointer to its instance.

Definition at line 93 of file audio_mixer_user.cpp.

virtual USource* NLSOUND::UAudioMixer::createSource TSoundId    id,
bool    spawn = false,
TSpawnEndCallback    cb = NULL,
void *    callbackUserParam = NULL,
CSoundContext   context = 0
[pure virtual]
 

Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*).

Implemented in NLSOUND::CAudioMixerUser.

virtual USource* NLSOUND::UAudioMixer::createSource const std::string &    name,
bool    spawn = false,
TSpawnEndCallback    cb = NULL,
void *    callbackUserParam = NULL,
CSoundContext   context = 0
[pure 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.

Implemented in NLSOUND::CAudioMixerUser.

Referenced by NL3D::CPSSoundServImpl::createSound.

virtual void NLSOUND::UAudioMixer::enable bool    b [pure virtual]
 

Disables or reenables the sound.

Implemented in NLSOUND::CAudioMixerUser.

virtual UListener* NLSOUND::UAudioMixer::getListener   [pure virtual]
 

Return the listener interface.

Implemented in NLSOUND::CAudioMixerUser.

virtual uint32 NLSOUND::UAudioMixer::getLoadedSampleSize   [pure virtual]
 

Return the total size in byte of loaded samples.

Implemented in NLSOUND::CAudioMixerUser.

virtual uint NLSOUND::UAudioMixer::getNumberAvailableTracks   const [pure virtual]
 

Return the number of available tracks.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::getPlayingSoundsPos std::vector< std::pair< bool, NLMISC::CVector > > &    pos [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual uint NLSOUND::UAudioMixer::getPlayingSourcesNumber   const [pure virtual]
 

Return the number of playing sources.

Implemented in NLSOUND::CAudioMixerUser.

virtual uint NLSOUND::UAudioMixer::getPolyphony   const [pure virtual]
 

Return the number of mixing tracks (voices).

Implemented in NLSOUND::CAudioMixerUser.

virtual TSoundId NLSOUND::UAudioMixer::getSoundId const std::string &    name [pure virtual]
 

Get a TSoundId from a name (returns NULL if not found).

Deprecated:

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::getSoundNames std::vector< std::string > &    names const [pure virtual]
 

Return the names of the sounds (call this method after loadSounds()).

Implemented in NLSOUND::CAudioMixerUser.

virtual uint NLSOUND::UAudioMixer::getSourcesNumber   const [pure virtual]
 

Return the number of sources.

Implemented in NLSOUND::CAudioMixerUser.

virtual std::string NLSOUND::UAudioMixer::getSourcesStats   const [pure virtual]
 

Return a string showing the playing sources.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::init   [pure 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" in millisecond (but in update()) (set 0 for "never auto-balance")

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::loadBackgroundEffectsFromRegion const NLLIGO::CPrimRegion   region [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::loadBackgroundSamplesFromRegion const NLLIGO::CPrimRegion   region [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::loadBackgroundSound const std::string &    continent [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::loadBackgroundSoundFromRegion const NLLIGO::CPrimRegion   region [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual uint32 NLSOUND::UAudioMixer::loadSampleBank bool    async,
const std::string &    filename,
std::vector< std::string > *    notfoundfiles = NULL
[pure virtual]
 

Load buffers.

Returns the number of buffers successfully loaded. If you specify a non null notfoundfiles vector, it is filled with the names of missing files if any.

Parameters:
async  If true, the sample are loaded in a background thread.
filename  Name of the directory that contains the samples to load.
notfoundfiles  An optionnal pointer to a vector that will be filled with the list of not found files.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::playBackgroundSound   [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::reloadSampleBanks bool    async [pure 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.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::reset   [pure virtual]
 

Resets the audio system (deletes all the sources, include envsounds).

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::selectEnvEffects const std::string &    tag [pure virtual]
 

Choose the environmental effect(s) corresponding to tag.

Deprecated:

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::setBackgroundFlags const TBackgroundFlags   backgroundFlags [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::setListenerPos const NLMISC::CVector   pos [pure virtual]
 

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.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::setLowWaterMark uint    value [pure 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.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::setPriorityReserve TSoundPriority    priorityChannel,
uint    reserve
[pure 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.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::setSamplePath const std::string &    path [pure virtual]
 

Set the global path to the sample banks.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::stopBackgroundSound   [pure virtual]
 

Implemented in NLSOUND::CAudioMixerUser.

virtual bool NLSOUND::UAudioMixer::unloadSampleBank const std::string &    filename [pure virtual]
 

Unload buffers.

Return false if the bank can't be unloaded because an async loading is running.

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::update   [pure virtual]
 

Update audio mixer (call evenly).

Implemented in NLSOUND::CAudioMixerUser.

virtual void NLSOUND::UAudioMixer::writeProfile std::ostream &    out [pure virtual]
 

Write profiling information about the mixer to the output stream.

Parameters:
out  The output stream to which to write the information

Implemented in NLSOUND::CAudioMixerUser.


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