Manages audio playback via SDL3_mixer.
More...
#include <flint/audio/audio.h>
|
| FLINT_API bool | init () |
| | Initialize the audio subsystem and open the default playback device.
|
| |
| FLINT_API void | cleanup () |
| | Release all audio resources and shut down SDL_mixer.
|
| |
| FLINT_API int | loadSound (const void *data, const size_t size) |
| | Load a sound from an in-memory audio file.
|
| |
| FLINT_API bool | playSound (int id, bool loop=false, float volume=1.0f, float pitch=1.0f) |
| | Begin playback of a previously loaded sound.
|
| |
| FLINT_API void | pauseSound (int id) |
| | Pause playback of the given sound.
|
| |
| FLINT_API void | resumeSound (int id) |
| | Resume a paused sound.
|
| |
| FLINT_API bool | isPaused (const int id) const |
| | Query whether a sound is currently paused.
|
| |
| FLINT_API void | stopSound (int id) |
| | Stop playback of a sound immediately.
|
| |
|
FLINT_API void | stopAllSounds () |
| | Stop all currently playing sounds immediately.
|
| |
| FLINT_API void | setVolume (int id, float volume) |
| | Set the playback volume for a specific sound.
|
| |
| FLINT_API void | setPitch (int id, float pitch) |
| | Set the playback pitch (frequency ratio) for a specific sound.
|
| |
| FLINT_API void | setLooping (int id, bool loop) |
| | Change the looping state of a currently playing sound.
|
| |
| FLINT_API bool | isPlaying (int id) const |
| | Query whether a sound is currently playing (not stopped or finished).
|
| |
|
FLINT_API void | pauseAll () const |
| | Pause all tracks on the mixer device.
|
| |
|
FLINT_API void | resumeAll () const |
| | Resume all tracks on the mixer device.
|
| |
| FLINT_API void | setMasterVolume (float volume) const |
| | Set the master output volume for the entire mixer.
|
| |
Manages audio playback via SDL3_mixer.
Wraps an SDL_mixer device along with per-sound track and audio-data lifetime management. Sounds are identified by integer IDs returned from loadSound(). The subsystem must be initialized with init() before any other method is called.
Definition at line 20 of file audio.h.
◆ ~Audio()
◆ cleanup()
| FLINT_API void Flint::Audio::cleanup |
( |
| ) |
|
Release all audio resources and shut down SDL_mixer.
Destroys every loaded track and audio buffer, then tears down the mixer device.
◆ init()
| FLINT_API bool Flint::Audio::init |
( |
| ) |
|
Initialize the audio subsystem and open the default playback device.
- Returns
- true on success, false if SDL_mixer could not be initialized or the playback device could not be opened.
◆ isPaused()
| FLINT_API bool Flint::Audio::isPaused |
( |
const int | id | ) |
const |
Query whether a sound is currently paused.
- Parameters
-
- Returns
- true if the sound is currently paused.
◆ isPlaying()
| FLINT_API bool Flint::Audio::isPlaying |
( |
int | id | ) |
const |
Query whether a sound is currently playing (not stopped or finished).
- Parameters
-
- Returns
- true if the sound's track is actively playing.
◆ loadSound()
| FLINT_API int Flint::Audio::loadSound |
( |
const void * | data, |
|
|
const size_t | size ) |
Load a sound from an in-memory audio file.
- Parameters
-
| data | Pointer to the raw audio file bytes. |
| size | Number of bytes in data. |
- Returns
- A positive integer ID that identifies the loaded sound, or -1 on failure.
◆ pauseSound()
| FLINT_API void Flint::Audio::pauseSound |
( |
int | id | ) |
|
Pause playback of the given sound.
The sound can be resumed with resumeSound().
- Parameters
-
◆ playSound()
| FLINT_API bool Flint::Audio::playSound |
( |
int | id, |
|
|
bool | loop = false, |
|
|
float | volume = 1.0f, |
|
|
float | pitch = 1.0f ) |
Begin playback of a previously loaded sound.
- Parameters
-
| id | Sound ID returned by loadSound(). |
| loop | If true the sound loops indefinitely until stopped. |
| volume | Linear gain in [0, 1] (1.0 = original level). |
| pitch | Frequency ratio (1.0 = original pitch). |
- Returns
- true if playback was started successfully, false otherwise.
◆ resumeSound()
| FLINT_API void Flint::Audio::resumeSound |
( |
int | id | ) |
|
Resume a paused sound.
- Parameters
-
◆ setLooping()
| FLINT_API void Flint::Audio::setLooping |
( |
int | id, |
|
|
bool | loop ) |
Change the looping state of a currently playing sound.
If the sound is playing, it is restarted with the new loop flag while preserving the current gain and pitch settings.
- Parameters
-
| id | Sound ID to modify. |
| loop | true to loop indefinitely, false to play once. |
◆ setMasterVolume()
| FLINT_API void Flint::Audio::setMasterVolume |
( |
float | volume | ) |
const |
Set the master output volume for the entire mixer.
- Parameters
-
| volume | Linear gain in [0, 1] applied to all tracks combined. |
◆ setPitch()
| FLINT_API void Flint::Audio::setPitch |
( |
int | id, |
|
|
float | pitch ) |
Set the playback pitch (frequency ratio) for a specific sound.
- Parameters
-
| id | Sound ID to adjust. |
| pitch | Frequency ratio (1.0 = original pitch). |
◆ setVolume()
| FLINT_API void Flint::Audio::setVolume |
( |
int | id, |
|
|
float | volume ) |
Set the playback volume for a specific sound.
- Parameters
-
| id | Sound ID to adjust. |
| volume | Linear gain in [0, 1]. |
◆ stopSound()
| FLINT_API void Flint::Audio::stopSound |
( |
int | id | ) |
|
Stop playback of a sound immediately.
- Parameters
-
The documentation for this class was generated from the following file: