Brenta Engine 1.1
|
Audio subsystem. More...
#include <engine_audio.hpp>
Static Public Member Functions | |
static void | init () |
Initialize the audio system. | |
static void | destroy () |
Destroy the audio system. | |
static types::audio_file_t | get_audio_file (types::audio_name_t name) |
Get an audio file. | |
static SDL_AudioStream * | get_stream (types::stream_name_t name) |
Get an audio stream. | |
static void | load_audio (types::audio_name_t name, std::string path) |
Load an audio file. | |
static void | create_stream (types::stream_name_t) |
Create an audio stream. | |
static void | play_audio (types::audio_name_t, types::stream_name_t="default") |
Play an audio file. | |
static void | set_volume (types::stream_name_t name, int volume) |
Set the volume of a stream. | |
static void | pause_stream (types::stream_name_t name) |
Pause a stream. | |
static void | resume_stream (types::stream_name_t name) |
Resume a stream. | |
static void | clear_stream (types::stream_name_t name) |
Stop a stream. | |
Static Public Attributes | |
static std::unordered_map< types::audio_name_t, types::audio_file_t > | audio_files |
Map of audio files. | |
static std::unordered_map< types::stream_name_t, 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 156 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 100 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 52 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 116 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 126 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 39 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 66 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 170 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 83 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 184 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 136 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 106 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 118 of file engine_audio.hpp.