#include <tb_audio_manager.h>
|
class | tbImplementation::AudioManagerCreator |
|
The AudioManager is the interface for loading and playing sound effects. Like the SpriteManager the AudioManager is a global singleton like object accessed with tbAudio::theAudioManager. It can create a table of audio events that can then be played with PlayEvent().
tbCore::uint64 TurtleBrains::Audio::AudioManager::ComputeMemoryUsage |
( |
void |
| ) |
const |
Returns the number of bytes in memory from all audio buffers currently loaded in the managers audio cache and the data used by streaming players.
AudioHandle TurtleBrains::Audio::AudioManager::CreateSoundFromFile |
( |
const tbCore::tbString & |
filename, |
|
|
const bool |
isStreaming = false |
|
) |
| |
Consider this an implementation detail, it will indeed load a sound from the file provided, however it may become an implementation detail and be stripped away from the AudioManager interface.
- Parameters
-
filename | The path and name to the file to be loaded into the audio manager. |
isStreaming | True if the audio data should be loaded and decompressed while it plays vs a buffered effect that loads all data into memory at once during this function. Streaming audio has the advantage of reducing memory, but does incur some extra CPU time. At this time only OGG file format supports streaming. Defaults to false. |
- Note
- The audio handle returned should be cleaned up when finished by calling DestroySound().
-
Only OGG format has support for isStreaming, otherwise an error condition will be triggered.
void TurtleBrains::Audio::AudioManager::DestroySound |
( |
const AudioHandle & |
audioHandle | ) |
|
Consider this an implementation detail, it will indeed destroy a sound previously created, however it will do so even if it is being played, or shouldn't. Also this may become an implementation detail and be stripped away from the AudioManager interface.
- Parameters
-
audioHandle | The handle to the audio/sound data to be destroyed. Should have been returned by a call to CreateSoundFromFile(). |
float TurtleBrains::Audio::AudioManager::GetGlobalEffectVolume |
( |
void |
| ) |
const |
Returns the volume modifier for all audio that is tagged as a sound effect.
float TurtleBrains::Audio::AudioManager::GetGlobalMusicVolume |
( |
void |
| ) |
const |
Returns the volume modifier for all audio that is tagged as a piece of music.
Loads a table of audio events and the audio data files required for playback. Once loaded an audio event can be played by calling PlayEvent(). If the table file or any audio files could not be loaded an error condition will be triggered.
- Parameters
-
eventTableName | The name to use for this event table. If an event table already exists with the name, an error condition will be triggered. |
eventTableFile | The path and filename of the .json data to load up describing the event table. |
- Note
- Use UnloadEventTable() to unload after finished.
void TurtleBrains::Audio::AudioManager::PauseAllAudio |
( |
void |
| ) |
|
Pauses all the audio currently playing at the moment, and will be capable of resuming where it left off once ResumeAllAudio is called.
- Note
- If you call PlaySound or PlayEvent after pausing all audio, the new sounds will be audible and play normally, (not paused).
Triggers an audio event to begin playing in the background, an audio event can have multiple sound files to randomly choose from. The audio event must have been loaded by LoadEventTable prior to being the call or an error condition will be triggered.
- Parameters
-
eventTableName | The name of the table to grab the event from, if this table is not loaded an error condition will be triggered. |
eventName | The name of the event description. If this is not found on the specified event table an error condition will be triggered. |
- Note
- If the event being played is a looping event, you should hold onto the controller to be capable of stopping the audio from looping. See also: TODO: TurtleBrains: Documentation: Write up a looping audio example / controller example that shows this.
AudioController TurtleBrains::Audio::AudioManager::PlaySound |
( |
const AudioHandle & |
audioHandle, |
|
|
const bool |
isLooping = false , |
|
|
const bool |
isMusic = false |
|
) |
| |
Consider this an implementation detail, it will indeed play a sound by an AudioHandle loaded from CreateSoundFromFile, however it may be pulled out of the AudioManager interface in favor of PlayEvent().
- Parameters
-
audioHandle | The handle to the sound loaded via CreateSoundFromFile that should be played. |
isLooping | This should be true if the sound should start playing from the beginning immediately upon completing, and will loop until stopped from the controller returned back. |
isMusic | This determines if the audio will play with the global music volume when true, or the global effects volume when false. |
- Note
- Use at your own risk, this may be pulled out of the AudioManager in favor for only playing by event or other means. It is provided for quickly testing and developing the AudioManager API.
-
If the event being played is a looping event, you should hold onto the controller to be capable of stopping the audio from looping. See also: TODO: TurtleBrains: Documentation: Write up a looping audio example / controller example that shows this.
void TurtleBrains::Audio::AudioManager::ResumeAllAudio |
( |
void |
| ) |
|
Resume all audio that was paused. It will continue from where it left off.
void TurtleBrains::Audio::AudioManager::SetGlobalEffectVolume |
( |
const float |
effectVolume | ) |
|
Sets the volume modifier for all audio tagged as an effect, see PlaySound or the format loaded by LoadEventTable() to tag audio as music or effect.
- Parameters
-
effectVolume | The modifier to use on all audio effects, should be between 0.0 (for silence) and 1.0 (for full volume). |
- Note
- This is a modifier that multiplies against the musics volume set via the AudioController or by the PlayEvent data. So the actual volume of a piece could be lower than this.
void TurtleBrains::Audio::AudioManager::SetGlobalMusicVolume |
( |
const float |
musicVolume | ) |
|
Sets the volume modifier for all audio tagged as a piece of music, see PlaySound or the format loaded by LoadEventTable() to tag audio as music or effect.
- Parameters
-
musicVolume | The modifier to use on all music pieces, should be between 0.0 (for silence) and 1.0 (for full volume). |
- Note
- This is a modifier that multiplies against the musics volume set via the AudioController or by the PlayEvent data. So the actual volume of a piece could be lower than this.
void TurtleBrains::Audio::AudioManager::UnloadEventTable |
( |
const tbCore::tbString & |
eventTableName | ) |
|
Unloads a previously loaded EventTable and reduces reference count for all audio data used by any of the events. If this reference count reduces to 0, that audio data will be unloaded and instance of that data being played will immediately stop/end for the cleanup.
- Parameters
-
eventTableName | The name of the event table to unload. If this is not found to be loaded an error condition will be triggered. |