Handles playback of sounds and music with volume control and crossfading.
More...
#include <AudioSystem.hpp>
|
| void | Update (const float deltaT) override |
| | Updates music stream and removes finished sounds.
|
| void | PlaySound (const Sound &sound, float volume=1) |
| | Plays a sound effect.
|
| void | StopSound (const Sound &sound) |
| | Stops a sound effect immediately.
|
| void | SetSoundVolume (const Sound &sound, float volume) |
| | Changes volume of a currently playing sound.
|
| void | PlayMusic (const Music &music, float volume=1, const bool loop=false, const float crossfadeS=0) |
| | Starts playing background music.
|
| void | StopMusic (const float fadeOutDuration=0) |
| | Stops the current music, optionally with a fade out.
|
| bool | IsMusicPlaying () |
| | Checks if music is currently playing or fading in.
|
|
void | PauseMusic () |
| | Pauses the current music stream.
|
|
void | ResumeMusic () |
| | Resumes a paused music stream.
|
| std::optional< float > | GetMusicLengthS () |
| | Gets the total length of the current music.
|
| std::optional< float > | GetMusicPlayedS () |
| | Gets the current playback position.
|
| void | SeekMusic (const float timeS) |
| | Seeks to a specific time in the current music.
|
| void | SetMusicVolume (float volume) |
| | Sets the music volume (without affecting sound effects).
|
| void | SetMusicPitch (const float pitch) |
| | Sets the music pitch.
|
| void | SetMusicPan (float pan) |
| | Sets the music stereo pan.
|
| void | SetMusicLoop (const bool loop) |
| | Enables or disables looping for the current music.
|
| void | SetSFXVolume (float volume) |
| | Sets the volume multiplier for all sound effects.
|
| virtual void | Draw () const |
| | Renders the system.
|
|
| static void | SetSoundPitch (const Sound &sound, const float pitch) |
| | Changes pitch of a playing sound.
|
| static void | SetSoundPan (const Sound &sound, const float pan) |
| | Changes stereo pan of a playing sound.
|
| static void | SetMasterVolume (float volume) |
| | Sets the master volume for the entire audio device.
|
Handles playback of sounds and music with volume control and crossfading.
◆ GetMusicLengthS()
| std::optional< float > AudioSystem::GetMusicLengthS |
( |
| ) |
|
Gets the total length of the current music.
- Returns
- Length in seconds, or std::nullopt if no music is loaded.
◆ GetMusicPlayedS()
| std::optional< float > AudioSystem::GetMusicPlayedS |
( |
| ) |
|
Gets the current playback position.
- Returns
- Position in seconds, or std::nullopt if no music is loaded.
◆ IsMusicPlaying()
| bool AudioSystem::IsMusicPlaying |
( |
| ) |
|
Checks if music is currently playing or fading in.
- Returns
- True if music is active.
◆ PlayMusic()
| void AudioSystem::PlayMusic |
( |
const Music & | music, |
|
|
float | volume = 1, |
|
|
const bool | loop = false, |
|
|
const float | crossfadeS = 0 ) |
Starts playing background music.
- Parameters
-
| music | The music asset. |
| volume | Volume (0.0–1.0). |
| loop | Whether to repeat the track. |
| crossfadeS | Crossfade duration in seconds (if another music is playing). |
◆ PlaySound()
| void AudioSystem::PlaySound |
( |
const Sound & | sound, |
|
|
float | volume = 1 ) |
Plays a sound effect.
- Parameters
-
| sound | The sound asset. |
| volume | Playback volume (0.0–1.0), scaled by global SFX volume. |
◆ SeekMusic()
| void AudioSystem::SeekMusic |
( |
const float | timeS | ) |
|
Seeks to a specific time in the current music.
- Parameters
-
| timeS | Target time in seconds. |
◆ SetMasterVolume()
| void AudioSystem::SetMasterVolume |
( |
float | volume | ) |
|
|
static |
Sets the master volume for the entire audio device.
- Parameters
-
◆ SetMusicLoop()
| void AudioSystem::SetMusicLoop |
( |
const bool | loop | ) |
|
Enables or disables looping for the current music.
- Parameters
-
◆ SetMusicPan()
| void AudioSystem::SetMusicPan |
( |
float | pan | ) |
|
Sets the music stereo pan.
- Parameters
-
| pan | -1.0 left … 1.0 right. |
◆ SetMusicPitch()
| void AudioSystem::SetMusicPitch |
( |
const float | pitch | ) |
|
Sets the music pitch.
- Parameters
-
| pitch | Multiplier (1.0 = original). |
◆ SetMusicVolume()
| void AudioSystem::SetMusicVolume |
( |
float | volume | ) |
|
Sets the music volume (without affecting sound effects).
- Parameters
-
◆ SetSFXVolume()
| void AudioSystem::SetSFXVolume |
( |
float | volume | ) |
|
Sets the volume multiplier for all sound effects.
- Parameters
-
◆ SetSoundPan()
| void AudioSystem::SetSoundPan |
( |
const Sound & | sound, |
|
|
const float | pan ) |
|
static |
Changes stereo pan of a playing sound.
- Parameters
-
| sound | The sound asset. |
| pan | -1.0 = left, 0.0 = center, 1.0 = right. |
◆ SetSoundPitch()
| void AudioSystem::SetSoundPitch |
( |
const Sound & | sound, |
|
|
const float | pitch ) |
|
static |
Changes pitch of a playing sound.
- Parameters
-
| sound | The sound asset. |
| pitch | Pitch multiplier (1.0 = original). |
◆ SetSoundVolume()
| void AudioSystem::SetSoundVolume |
( |
const Sound & | sound, |
|
|
float | volume ) |
Changes volume of a currently playing sound.
- Parameters
-
| sound | The sound asset. |
| volume | New volume (0.0–1.0). |
◆ StopMusic()
| void AudioSystem::StopMusic |
( |
const float | fadeOutDuration = 0 | ) |
|
Stops the current music, optionally with a fade out.
- Parameters
-
| fadeOutDuration | Seconds to fade out before stopping (0 = immediate). |
◆ StopSound()
| void AudioSystem::StopSound |
( |
const Sound & | sound | ) |
|
Stops a sound effect immediately.
- Parameters
-
◆ Update()
| void AudioSystem::Update |
( |
const float | deltaT | ) |
|
|
overridevirtual |
Updates music stream and removes finished sounds.
- Parameters
-
Implements System.
The documentation for this class was generated from the following files: