|
libmx2 2.2.1
C++20 multimedia and game-engine library (SDL2 / OpenGL / Vulkan)
|
SDL_mixer–based audio manager. More...
#include <sound.hpp>
Public Member Functions | |
| Mixer () | |
| Initialise SDL_mixer and open the audio device. | |
| ~Mixer () | |
| Halt all playback and free all loaded audio resources. | |
| Mixer (const Mixer &)=delete | |
| Mixer & | operator= (const Mixer &)=delete |
| Mixer (Mixer &&)=delete | |
| Mixer & | operator= (Mixer &&)=delete |
| void | init () |
| Open the audio device (called automatically by constructor). | |
| int | loadWav (const std::string &filename) |
| Load a WAV file as a sound effect chunk. | |
| int | loadMusic (const std::string &filename) |
| Load an audio file as streaming background music. | |
| int | playMusic (int id, int value=0) |
| Start playing a previously loaded music track. | |
| int | playWav (int id, int value=0, int channel=0) |
| Play a previously loaded WAV chunk. | |
| bool | isPlaying (int channel) const |
| Query whether a mixer channel is currently playing. | |
| void | cleanup () |
| Free all loaded audio chunks and music tracks. | |
| void | stopMusic () |
| Stop background music playback immediately. | |
Private Attributes | |
| bool | init_ = false |
| Whether the audio device is open. | |
| std::vector< Mix_Music * > | files |
| Loaded music tracks. | |
| std::vector< Mix_Chunk * > | wav |
| Loaded WAV chunks. | |
SDL_mixer–based audio manager.
Provides facilities for loading WAV sound chunks and streamed music tracks, playing them on SDL_mixer channels, and querying playback state. Only available when the library is built with WITH_MIXER defined.
| mx::Mixer::Mixer | ( | ) |
Initialise SDL_mixer and open the audio device.
Definition at line 16 of file sound.cpp.
References init_.
Referenced by Mixer(), Mixer(), operator=(), and operator=().
| mx::Mixer::~Mixer | ( | ) |
|
delete |
References Mixer().
|
delete |
References Mixer().
| void mx::Mixer::cleanup | ( | ) |
| void mx::Mixer::init | ( | ) |
| bool mx::Mixer::isPlaying | ( | int | channel | ) | const |
| int mx::Mixer::loadMusic | ( | const std::string & | filename | ) |
Load an audio file as streaming background music.
| filename | Path to the music file (OGG, MP3, WAV, etc.). |
Definition at line 64 of file sound.cpp.
References files.
| int mx::Mixer::loadWav | ( | const std::string & | filename | ) |
| int mx::Mixer::playMusic | ( | int | id, |
| int | value = 0 ) |
Start playing a previously loaded music track.
| id | Music index returned by loadMusic(). |
| value | Number of additional loops (0 = play once, -1 = infinite). |
Definition at line 74 of file sound.cpp.
References files.
| int mx::Mixer::playWav | ( | int | id, |
| int | value = 0, | ||
| int | channel = 0 ) |
Play a previously loaded WAV chunk.
| id | Chunk index returned by loadWav(). |
| value | Number of additional loops (0 = play once). |
| channel | SDL_mixer channel to play on (0 = first available). |
Definition at line 98 of file sound.cpp.
References wav.
| void mx::Mixer::stopMusic | ( | ) |
|
private |
Loaded music tracks.
Definition at line 92 of file sound.hpp.
Referenced by cleanup(), loadMusic(), and playMusic().
|
private |
|
private |