ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Audio::Mixer Class Reference

The main audio mixer handles mixing of an arbitrary number of audio streams (in the form of AudioStream instances). More...

#include <mixer.h>

Inheritance diagram for Audio::Mixer:
Collaboration diagram for Audio::Mixer:

List of all members.

Public Types

enum  SoundType { kPlainSoundType = 0, kMusicSoundType = 1, kSFXSoundType = 2, kSpeechSoundType = 3 }
enum  { kMaxChannelVolume = 255, kMaxMixerVolume = 256 }

Public Member Functions

 Mixer ()
virtual ~Mixer ()
virtual bool isReady () const =0
 Is the mixer ready and setup? This may not be the case on systems which don't support digital sound output.
virtual void playStream (SoundType type, SoundHandle *handle, AudioStream *stream, int id=-1, byte volume=kMaxChannelVolume, int8 balance=0, DisposeAfterUse::Flag autofreeStream=DisposeAfterUse::YES, bool permanent=false, bool reverseStereo=false)=0
 Start playing the given audio stream.
virtual void stopAll ()=0
 Stop all currently playing sounds.
virtual void stopID (int id)=0
 Stop playing the sound with given ID.
virtual void stopHandle (SoundHandle handle)=0
 Stop playing the sound corresponding to the given handle.
virtual void pauseAll (bool paused)=0
 Pause/unpause all sounds, including all regular and permanent channels.
virtual void pauseID (int id, bool paused)=0
 Pause/unpause the sound with the given ID.
virtual void pauseHandle (SoundHandle handle, bool paused)=0
 Pause/unpause the sound corresponding to the given handle.
virtual bool isSoundIDActive (int id)=0
 Check if a sound with the given ID is active.
virtual int getSoundID (SoundHandle handle)=0
 Get the sound ID of handle sound.
virtual bool isSoundHandleActive (SoundHandle handle)=0
 Check if a sound with the given handle is active.
virtual void muteSoundType (SoundType type, bool mute)=0
 Set the mute state for a given sound type.
virtual bool isSoundTypeMuted (SoundType type) const =0
 Query the mute state for a given sound type.
virtual void setChannelVolume (SoundHandle handle, byte volume)=0
 Set the channel volume for the given handle.
virtual byte getChannelVolume (SoundHandle handle)=0
 Get the channel volume for the given handle.
virtual void setChannelBalance (SoundHandle handle, int8 balance)=0
 Set the channel balance for the given handle.
virtual int8 getChannelBalance (SoundHandle handle)=0
 Get the channel balance for the given handle.
virtual uint32 getSoundElapsedTime (SoundHandle handle)=0
 Get approximation of for how long the channel has been playing.
virtual Timestamp getElapsedTime (SoundHandle handle)=0
 Get approximation of for how long the channel has been playing.
virtual bool hasActiveChannelOfType (SoundType type)=0
 Check whether any channel of the given sound type is active.
virtual void setVolumeForSoundType (SoundType type, int volume)=0
 Set the volume for the given sound type.
virtual int getVolumeForSoundType (SoundType type) const =0
 Query the global volume.
virtual uint getOutputRate () const =0
 Query the system's audio output sample rate.

Detailed Description

The main audio mixer handles mixing of an arbitrary number of audio streams (in the form of AudioStream instances).

Definition at line 53 of file mixer.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
kMaxChannelVolume 
kMaxMixerVolume 

Definition at line 63 of file mixer.h.

Enumerator:
kPlainSoundType 
kMusicSoundType 
kSFXSoundType 
kSpeechSoundType 

Definition at line 55 of file mixer.h.


Constructor & Destructor Documentation

Audio::Mixer::Mixer (  )  [inline]

Definition at line 69 of file mixer.h.

virtual Audio::Mixer::~Mixer (  )  [inline, virtual]

Definition at line 70 of file mixer.h.


Member Function Documentation

virtual int8 Audio::Mixer::getChannelBalance ( SoundHandle  handle  )  [pure virtual]

Get the channel balance for the given handle.

Parameters:
handle the sound to affect
Returns:
channel balance

Implemented in Audio::MixerImpl.

virtual byte Audio::Mixer::getChannelVolume ( SoundHandle  handle  )  [pure virtual]

Get the channel volume for the given handle.

Parameters:
handle the sound to affect
Returns:
channel volume

Implemented in Audio::MixerImpl.

virtual Timestamp Audio::Mixer::getElapsedTime ( SoundHandle  handle  )  [pure virtual]

Get approximation of for how long the channel has been playing.

Implemented in Audio::MixerImpl.

virtual uint Audio::Mixer::getOutputRate (  )  const [pure virtual]

Query the system's audio output sample rate.

Returns:
the output sample rate in Hz

Implemented in Audio::MixerImpl.

virtual uint32 Audio::Mixer::getSoundElapsedTime ( SoundHandle  handle  )  [pure virtual]

Get approximation of for how long the channel has been playing.

Implemented in Audio::MixerImpl.

virtual int Audio::Mixer::getSoundID ( SoundHandle  handle  )  [pure virtual]

Get the sound ID of handle sound.

Parameters:
handle sound to query
Returns:
sound ID if active

Implemented in Audio::MixerImpl.

virtual int Audio::Mixer::getVolumeForSoundType ( SoundType  type  )  const [pure virtual]

Query the global volume.

Parameters:
type the sound type
Returns:
the global music volume, 0 - kMaxMixerVolume

Implemented in Audio::MixerImpl.

virtual bool Audio::Mixer::hasActiveChannelOfType ( SoundType  type  )  [pure virtual]

Check whether any channel of the given sound type is active.

For example, this can be used to check whether any SFX sound is currently playing, by checking for type kSFXSoundType.

Parameters:
type the sound type to look for
Returns:
true if any channels of the specified type are active.

Implemented in Audio::MixerImpl.

virtual bool Audio::Mixer::isReady (  )  const [pure virtual]

Is the mixer ready and setup? This may not be the case on systems which don't support digital sound output.

In that case, the mixer proc may never be called. That in turn can cause breakage in games which try to sync with an audio stream. In particular, the AdLib MIDI emulation...

Returns:
whether the mixer is ready and setup
Todo:
get rid of this?

Implemented in Audio::MixerImpl.

virtual bool Audio::Mixer::isSoundHandleActive ( SoundHandle  handle  )  [pure virtual]

Check if a sound with the given handle is active.

Parameters:
handle sound to query
Returns:
true if the sound is active

Implemented in Audio::MixerImpl.

virtual bool Audio::Mixer::isSoundIDActive ( int  id  )  [pure virtual]

Check if a sound with the given ID is active.

Parameters:
id the ID of the sound to query
Returns:
true if the sound is active

Implemented in Audio::MixerImpl.

virtual bool Audio::Mixer::isSoundTypeMuted ( SoundType  type  )  const [pure virtual]

Query the mute state for a given sound type.

Parameters:
type the sound type

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::muteSoundType ( SoundType  type,
bool  mute 
) [pure virtual]

Set the mute state for a given sound type.

Parameters:
type the sound type
mute Whether to mute (= true) or not (= false).

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::pauseAll ( bool  paused  )  [pure virtual]

Pause/unpause all sounds, including all regular and permanent channels.

Parameters:
paused true to pause everything, false to unpause

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::pauseHandle ( SoundHandle  handle,
bool  paused 
) [pure virtual]

Pause/unpause the sound corresponding to the given handle.

Parameters:
handle the sound to affect
paused true to pause the sound, false to unpause it

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::pauseID ( int  id,
bool  paused 
) [pure virtual]

Pause/unpause the sound with the given ID.

Parameters:
id the ID of the sound to affect
paused true to pause the sound, false to unpause it

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::playStream ( SoundType  type,
SoundHandle handle,
AudioStream stream,
int  id = -1,
byte  volume = kMaxChannelVolume,
int8  balance = 0,
DisposeAfterUse::Flag  autofreeStream = DisposeAfterUse::YES,
bool  permanent = false,
bool  reverseStereo = false 
) [pure virtual]

Start playing the given audio stream.

Note that the sound id assigned below is unique. At most one stream with a given id can play at any given time. Trying to play a sound with an id that is already in use causes the new sound to be not played.

Parameters:
type the type (voice/sfx/music) of the stream
handle a SoundHandle which can be used to reference and control the stream via suitable mixer methods
stream the actual AudioStream to be played
id a unique id assigned to this stream
volume the volume with which to play the sound, ranging from 0 to 255
balance the balance with which to play the sound, ranging from -127 to 127 (full left to full right), 0 is balanced, -128 is invalid
autofreeStream a flag indicating whether the stream should be freed after playback finished
permanent a flag indicating whether a plain stopAll call should not stop this particular stream
reverseStereo a flag indicating whether left and right channels shall be swapped

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::setChannelBalance ( SoundHandle  handle,
int8  balance 
) [pure virtual]

Set the channel balance for the given handle.

Parameters:
handle the sound to affect
balance the new channel balance: (-127 ... 0 ... 127) corresponds to (left ... center ... right)

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::setChannelVolume ( SoundHandle  handle,
byte  volume 
) [pure virtual]

Set the channel volume for the given handle.

Parameters:
handle the sound to affect
volume the new channel volume (0 - kMaxChannelVolume)

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::setVolumeForSoundType ( SoundType  type,
int  volume 
) [pure virtual]

Set the volume for the given sound type.

Parameters:
type the sound type
volume the new global volume, 0 - kMaxMixerVolume

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::stopAll (  )  [pure virtual]

Stop all currently playing sounds.

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::stopHandle ( SoundHandle  handle  )  [pure virtual]

Stop playing the sound corresponding to the given handle.

Parameters:
handle the sound to affect

Implemented in Audio::MixerImpl.

virtual void Audio::Mixer::stopID ( int  id  )  [pure virtual]

Stop playing the sound with given ID.

Parameters:
id the ID of the sound to affect

Implemented in Audio::MixerImpl.


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


Generated on Sat Jul 13 2019 05:03:31 for ResidualVM by doxygen 1.7.1
curved edge   curved edge