ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::sound Namespace Reference

Functions

bool _init ()
 Initialize the sound module. Called automatically by asw::core::init().
 
void _shutdown ()
 Shut down the sound module. Called automatically by asw::core::shutdown().
 
MIX_Mixer * get_mixer ()
 Get the SDL mixer device.
 
void play (const asw::Sample &sample, float volume=1.0F, float pan=0.0F, bool loop=false)
 Play a sample.
 
void play_music (const asw::Music &sample, float volume=1.0F, float fade_in_s=0.0F)
 Play a music sample.
 
void stop_music (float fade_out_s=0.0F)
 Stop the currently playing music.
 
void pause_music ()
 Pause the currently playing music.
 
void resume_music ()
 Resume paused music.
 
bool is_music_playing ()
 Check if music is currently playing.
 
bool is_music_paused ()
 Check if music is paused.
 
void set_master_volume (float volume)
 Set the master volume multiplier (affects all audio).
 
void set_sfx_volume (float volume)
 Set the SFX volume multiplier.
 
void set_music_volume (float volume)
 Set the music volume multiplier.
 
float get_master_volume ()
 Get the current master volume multiplier.
 
float get_sfx_volume ()
 Get the current SFX volume multiplier.
 
float get_music_volume ()
 Get the current music volume multiplier.
 

Function Documentation

◆ _init()

bool asw::sound::_init ( )

Initialize the sound module. Called automatically by asw::core::init().

Returns
True if initialization was successful, false otherwise.

Definition at line 58 of file sound.cpp.

◆ _shutdown()

void asw::sound::_shutdown ( )

Shut down the sound module. Called automatically by asw::core::shutdown().

Definition at line 48 of file sound.cpp.

◆ get_master_volume()

float asw::sound::get_master_volume ( )

Get the current master volume multiplier.

Returns
The master volume (0.0 - 1.0).

Definition at line 180 of file sound.cpp.

◆ get_mixer()

MIX_Mixer * asw::sound::get_mixer ( )

Get the SDL mixer device.

Returns
Pointer to the MIX_Mixer, or nullptr if not initialized.

Definition at line 43 of file sound.cpp.

◆ get_music_volume()

float asw::sound::get_music_volume ( )

Get the current music volume multiplier.

Returns
The music volume (0.0 - 1.0).

Definition at line 190 of file sound.cpp.

◆ get_sfx_volume()

float asw::sound::get_sfx_volume ( )

Get the current SFX volume multiplier.

Returns
The SFX volume (0.0 - 1.0).

Definition at line 185 of file sound.cpp.

◆ is_music_paused()

bool asw::sound::is_music_paused ( )

Check if music is paused.

Returns
True if music is paused.

Definition at line 159 of file sound.cpp.

◆ is_music_playing()

bool asw::sound::is_music_playing ( )

Check if music is currently playing.

Returns
True if music is playing.

Definition at line 154 of file sound.cpp.

◆ pause_music()

void asw::sound::pause_music ( )

Pause the currently playing music.

Definition at line 144 of file sound.cpp.

◆ play()

void asw::sound::play ( const asw::Sample & sample,
float volume = 1.0F,
float pan = 0.0F,
bool loop = false )

Play a sample.

Parameters
sampleSample to play
volumePlayback volume (0.0 - 1.0).
panPanning (-1.0 - 1.0), where -1.0 is full left, 0.0 is center, and 1.0 is full right.
loopWhether to loop the sample (false = no loop, true = infinite loop).

Definition at line 99 of file sound.cpp.

◆ play_music()

void asw::sound::play_music ( const asw::Music & sample,
float volume = 1.0F,
float fade_in_s = 0.0F )

Play a music sample.

Parameters
sampleSample to play
volumePlayback volume (0.0 - 1.0).
fade_in_sFade-in duration in seconds.

Definition at line 124 of file sound.cpp.

◆ resume_music()

void asw::sound::resume_music ( )

Resume paused music.

Definition at line 149 of file sound.cpp.

◆ set_master_volume()

void asw::sound::set_master_volume ( float volume)

Set the master volume multiplier (affects all audio).

Parameters
volumeVolume multiplier (0.0 - 1.0).

Definition at line 164 of file sound.cpp.

◆ set_music_volume()

void asw::sound::set_music_volume ( float volume)

Set the music volume multiplier.

Parameters
volumeVolume multiplier (0.0 - 1.0).

Definition at line 175 of file sound.cpp.

◆ set_sfx_volume()

void asw::sound::set_sfx_volume ( float volume)

Set the SFX volume multiplier.

Parameters
volumeVolume multiplier (0.0 - 1.0).

Definition at line 170 of file sound.cpp.

◆ stop_music()

void asw::sound::stop_music ( float fade_out_s = 0.0F)

Stop the currently playing music.

Definition at line 136 of file sound.cpp.