#include <mixer.h>
Public Types | |
enum | SoundType { kPlainSoundType = 0, kMusicSoundType = 1, kSFXSoundType = 2, kSpeechSoundType = 3 } |
enum | { kMaxChannelVolume = 255, kMaxMixerVolume = 256 } |
Public Member Functions | |
virtual bool | isReady () const =0 |
virtual Common::Mutex & | mutex ()=0 |
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 |
virtual void | stopAll ()=0 |
virtual void | stopID (int id)=0 |
virtual void | stopHandle (SoundHandle handle)=0 |
virtual void | pauseAll (bool paused)=0 |
virtual void | pauseID (int id, bool paused)=0 |
virtual void | pauseHandle (SoundHandle handle, bool paused)=0 |
virtual bool | isSoundIDActive (int id)=0 |
virtual int | getSoundID (SoundHandle handle)=0 |
virtual bool | isSoundHandleActive (SoundHandle handle)=0 |
virtual void | muteSoundType (SoundType type, bool mute)=0 |
virtual bool | isSoundTypeMuted (SoundType type) const =0 |
virtual void | setChannelVolume (SoundHandle handle, byte volume)=0 |
virtual byte | getChannelVolume (SoundHandle handle)=0 |
virtual void | setChannelBalance (SoundHandle handle, int8 balance)=0 |
virtual int8 | getChannelBalance (SoundHandle handle)=0 |
virtual void | setChannelRate (SoundHandle handle, uint32 rate)=0 |
virtual uint32 | getChannelRate (SoundHandle handle)=0 |
virtual void | resetChannelRate (SoundHandle handle)=0 |
virtual uint32 | getSoundElapsedTime (SoundHandle handle)=0 |
virtual Timestamp | getElapsedTime (SoundHandle handle)=0 |
virtual void | loopChannel (SoundHandle handle)=0 |
virtual bool | hasActiveChannelOfType (SoundType type)=0 |
virtual void | setVolumeForSoundType (SoundType type, int volume)=0 |
virtual int | getVolumeForSoundType (SoundType type) const =0 |
virtual uint | getOutputRate () const =0 |
virtual bool | getOutputStereo () const =0 |
virtual uint | getOutputBufSize () const =0 |
The main audio mixer that handles mixing of an arbitrary number of audio streams (in the form of AudioStream instances).
anonymous enum |
|
pure virtual |
Check whether the mixer is ready and set up.
The mixer might not be set up on systems that do not support digital sound output. In such case, the mixer processing might never be called. That, in turn, can cause breakage in games that try to sync with an audio stream. In particular, the AdLib MIDI emulation.
Implemented in Audio::MixerImpl.
|
pure virtual |
Return the mixer's internal mutex so that audio players can use it.
Implemented in Audio::MixerImpl.
|
pure virtual |
Start playing the given audio stream.
Note that the sound ID assigned here is unique. At most, one stream with the 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 not be played.
type | Type of the stream - voice/SFX/music. |
handle | A SoundHandle instance that can be used to reference and control the stream using suitable mixer methods. |
stream | The actual AudioStream to be played. |
id | Unique ID assigned to this stream. |
volume | Volume with which to play the sound, ranging from 0 to 255. |
balance | Balance with which to play the sound, ranging from -127 to 127 (full left to full right). 0 is balanced, -128 is invalid. |
autofreeStream | If set, the stream will be freed after the playback is finished. |
permanent | If set, a plain stopAll call will not stop this particular stream. |
reverseStereo | If set, left and right channels will be swapped. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Stop all currently playing sounds.
Implemented in Audio::MixerImpl.
|
pure virtual |
Stop playing the sound with the given ID.
id | ID of the sound. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Stop playing the sound corresponding to the given handle.
handle | The sound to stop playing. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Pause or unpause all sounds, including all regular and permanent channels.
paused | True to pause everything, false to unpause. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Pause or unpause the sound with the given ID.
id | ID of the sound. |
paused | True to pause the sound, false to unpause it. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Pause or unpause the sound corresponding to the given handle.
handle | The sound to pause or unpause. |
paused | True to pause the sound, false to unpause it. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Check whether a sound with the given ID is active.
id | ID of the sound to query. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Get the sound ID for the given handle.
handle | The sound to query. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Check whether a sound with the given handle is active.
handle | The sound to query. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Set the mute state for a given sound type.
type | Sound type. See SoundType. |
mute | Whether to mute (= true) or not (= false). |
Implemented in Audio::MixerImpl.
|
pure virtual |
Query the mute state for a given sound type.
type | Sound type. See SoundType. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Set the channel volume for the given handle.
handle | The sound to affect. |
volume | The new channel volume, in the range 0 - kMaxChannelVolume. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Get the channel volume for the given handle.
handle | The sound to affect. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Set the channel balance for the given handle.
handle | The sound to affect. |
balance | The new channel balance: (-127 ... 0 ... 127) corresponds to (left ... center ... right) |
Implemented in Audio::MixerImpl.
|
pure virtual |
Get the channel balance for the given handle.
handle | The sound to affect. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Set the sample rate for the given handle.
handle | The sound to affect. |
rate | The new sample rate. Must be less than 131072 |
Implemented in Audio::MixerImpl.
|
pure virtual |
Get the sample rate for the given handle.
handle | The sound to affect. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Reset the sample rate of the channel back to its AudioStream's native rate.
handle | The sound to affect. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Get an approximation of for how long the channel has been playing.
Implemented in Audio::MixerImpl.
|
pure virtual |
Get an approximation of for how long the channel has been playing.
Implemented in Audio::MixerImpl.
|
pure virtual |
Replace the channel's stream with a version that loops indefinitely.
Implemented in Audio::MixerImpl.
|
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.
type | The sound type to query. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Set the volume for the given sound type.
type | Sound type. |
volume | The new global volume, in the range 0 - kMaxMixerVolume. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Check what the global volume is for a sound type.
type | Sound type. |
Implemented in Audio::MixerImpl.
|
pure virtual |
Return the output sample rate of the system.
Implemented in Audio::MixerImpl.
|
pure virtual |
Check whether the output is stereo.
Implemented in Audio::MixerImpl.
|
pure virtual |
Return the output sample buffer size of the system.
The return value is measured in frame units instead of bytes. It can be converted to bytes by multiplying it with the sample size and the number of channels. For example, for 16-bit stereo output it should be multiplied by 4.
Implemented in Audio::MixerImpl.