|
Brenta Engine 1.0
|
#include <engine_audio.hpp>
Static Public Member Functions | |
| static void | Init () |
| Initialize the audio system. | |
| static void | Destroy () |
| Destroy the audio system. | |
| static Types::AudioFile | GetAudioFile (Types::AudioName name) |
| Get an audio file. | |
| static SDL_AudioStream * | GetStream (Types::StreamName name) |
| Get an audio stream. | |
| static void | LoadAudio (Types::AudioName name, std::string path) |
| Load an audio file. | |
| static void | CreateStream (Types::StreamName) |
| Create an audio stream. | |
| static void | PlayAudio (Types::AudioName, Types::StreamName="default") |
| Play an audio file. | |
| static void | SetVolume (Types::StreamName name, int volume) |
| Set the volume of a stream. | |
| static void | PauseStream (Types::StreamName name) |
| Pause a stream. | |
| static void | ResumeStream (Types::StreamName name) |
| Resume a stream. | |
| static void | ClearStream (Types::StreamName name) |
| Stop a stream. | |
Static Public Attributes | |
| static std::unordered_map< Types::AudioName, Types::AudioFile > | audiofiles |
| Map of audio files. | |
| static std::unordered_map< Types::StreamName, SDL_AudioStream * > | streams |
| Map of audio streams. | |
Audio subsystem.
This class contains the audio subsystem of the engine. It is used to load audio files, create audio streams, play audio files on streams, set the volume of streams, pause, resume and stop streams. The audio system needs to be initialized and destroyed by the engine. Audio files and streamd are stored in maps and are identified by this name.
Definition at line 93 of file engine_audio.hpp.
|
static |
Stop a stream.
This function stops the stream with the given name. If the stream does not exist, it does nothing.
| name | The name of the stream |
Definition at line 157 of file engine_audio.cpp.
|
static |
Create an audio stream.
This function creates an audio stream with the given name. If a stream with the same name already exists, it does nothing.
| name | The name of the stream |
Definition at line 101 of file engine_audio.cpp.
|
static |
Destroy the audio system.
This function frees all audio streams and audio files, and closes the audio system.
Definition at line 53 of file engine_audio.cpp.
|
static |
Get an audio file.
This function returns the audio file with the given name. If the audio file does not exist, it returns an empty AudioFile.
| name | The name of the audio file |
Definition at line 117 of file engine_audio.cpp.
|
static |
Get an audio stream.
This function returns the audio stream with the given name. If the audio stream does not exist, it returns nullptr.
| name | The name of the audio stream |
Definition at line 127 of file engine_audio.cpp.
|
static |
Initialize the audio system.
This function initializes the audio system of the engine. It is called automatically by the engine when the game is started. It creates a default stream called "default".
Definition at line 40 of file engine_audio.cpp.
|
static |
Load an audio file.
This function loads an audio file from the given path and stores it in the audiofiles map with the given name.
| name | The name of the audio file |
| path | The path to the audio file |
Definition at line 67 of file engine_audio.cpp.
|
static |
Pause a stream.
This function pauses the stream with the given name. If the stream does not exist, it does nothing.
| name | The name of the stream |
Definition at line 171 of file engine_audio.cpp.
|
static |
Play an audio file.
This function plays the audio file with the given name on the stream with the given name. If the stream does not exist, it creates a new stream with the given name. If the audio file does not exist, it does nothing.
| audio_name | The name of the audio file |
| stream_name | The name of the stream |
Definition at line 84 of file engine_audio.cpp.
|
static |
Resume a stream.
This function resumes the stream with the given name. If the stream does not exist, it does nothing.
| name | The name of the stream |
Definition at line 185 of file engine_audio.cpp.
|
static |
Set the volume of a stream.
This function sets the volume of the stream with the given name. If the stream does not exist, it does nothing.
| name | The name of the stream |
| volume | The volume of the stream |
Definition at line 137 of file engine_audio.cpp.
|
static |
Map of audio files.
This map contains all the audio files loaded by the engine. The key is the name of the audio file provided by the user, the value is the struct AudioFile containing the path to the audio file, the audio buffer, the length of the audio buffer and the audio format.
Definition at line 105 of file engine_audio.hpp.
|
static |
Map of audio streams.
This map contains all the audio streams created by the engine. The key is the name of the stream provided by the user, the value is the SDL_AudioStream pointer. A stream can only play one audio file at a time, so multiple streams need to be created to play multiple audio files at the same time. The engine creates a default stream called "default", the handling of the streams is left to the programmer.
Definition at line 117 of file engine_audio.hpp.