|
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++.
|
Classes | |
| struct | Attenuation |
| Distance settings for positional sounds, in world units (pixels). More... | |
| struct | HandleAccess |
| struct | PlayOptions |
| Options for playing a sound. More... | |
| class | SoundHandle |
| A handle to a playing sound, used to change it while it plays. More... | |
Enumerations | |
| enum class | Bus : uint8_t { Sfx , Music , Ambient , Ui , Voice , Count } |
| Mix buses. Each sound plays on one bus, and each bus has its own volume and can be ducked. More... | |
| enum class | Rolloff : uint8_t { Linear , Inverse , InverseSquare } |
| How volume falls off with distance for positional sounds. More... | |
| enum class | SpatialMode : uint8_t { Stereo , Surround } |
| How positional sounds are placed on the speakers. More... | |
Functions | |
| bool | _init () |
| Initialize the sound module. Called automatically by asw::core::init(). | |
| void | _update () |
| Update fades, ducking and positional sounds. Called automatically by asw::core::update(). | |
| void | _shutdown () |
| Shut down the sound module. Called automatically by asw::core::shutdown(). | |
| MIX_Mixer * | get_mixer () |
| Get the SDL mixer device. | |
| uint32_t | _get_session () |
| Get the number of times the sound module has been shut down. | |
| SoundHandle | play (const asw::Sample &sample, float volume=1.0F, float pan=0.0F, bool loop=false) |
| Play a sample. | |
| SoundHandle | play (const asw::Sample &sample, const PlayOptions &options) |
| Play a sample with options. | |
| SoundHandle | play_positional (const asw::Sample &sample, const Vec2< float > &position, const PlayOptions &options={}) |
| Play a sample at a point in the world. It is panned, faded and pitch shifted relative to the listener, and keeps updating while it plays. | |
| SoundHandle | play_at (const asw::Sample &sample, float x, float volume=1.0F) |
| Play a sample panned by where it happens on screen. Sounds pan towards the side they are on and fade out once they are off screen, going silent a full screen width past the edge. | |
| SoundHandle | play_at (const asw::Sample &sample, float x, const PlayOptions &options) |
| Play a sample panned by where it happens on screen, with options. Works like play_at above, so pitch, variation, bus and priority can be set too. The pan is worked out once when the sound starts. | |
| void | set_listener (const Vec2< float > &position, const Vec2< float > &velocity={ 0.0F, 0.0F }) |
| Set where the listener is, usually the player or camera centre. | |
| Vec2< float > | get_listener () |
| Get the listener position. | |
| void | set_spatial_mode (SpatialMode mode) |
| Choose how positional sounds are placed on the speakers. | |
| void | set_doppler (float factor, float speed_of_sound=3000.0F) |
| Set how strong doppler pitch shift is. | |
| void | set_bus_volume (Bus bus, float volume) |
| Set a bus volume. | |
| float | get_bus_volume (Bus bus) |
| Get a bus volume. | |
| void | duck (Bus bus, float gain, float hold_s, float fade_s=0.2F) |
| Turn a bus down for a while, for example music under dialogue or everything under a big explosion. Overlapping ducks keep the deepest level and the longest hold. | |
| 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. Same as the Sfx bus volume. | |
| void | set_music_volume (float volume) |
| Set the music volume multiplier. Same as the Music bus volume. | |
| 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. | |
|
strong |
|
strong |
|
strong |
| uint32_t asw::sound::_get_session | ( | ) |
| bool asw::sound::_init | ( | ) |
Initialize the sound module. Called automatically by asw::core::init().
| void asw::sound::_shutdown | ( | ) |
Shut down the sound module. Called automatically by asw::core::shutdown().
| void asw::sound::_update | ( | ) |
Update fades, ducking and positional sounds. Called automatically by asw::core::update().
| void asw::sound::duck | ( | Bus | bus, |
| float | gain, | ||
| float | hold_s, | ||
| float | fade_s = 0.2F ) |
Turn a bus down for a while, for example music under dialogue or everything under a big explosion. Overlapping ducks keep the deepest level and the longest hold.
| bus | The bus to turn down. |
| gain | Level while ducked (0.0 - 1.0). |
| hold_s | Seconds to stay ducked. |
| fade_s | Seconds to fade down and back up. |
| float asw::sound::get_bus_volume | ( | Bus | bus | ) |
| asw::Vec2< float > asw::sound::get_listener | ( | ) |
| float asw::sound::get_master_volume | ( | ) |
| MIX_Mixer * asw::sound::get_mixer | ( | ) |
| float asw::sound::get_music_volume | ( | ) |
| float asw::sound::get_sfx_volume | ( | ) |
| bool asw::sound::is_music_paused | ( | ) |
| bool asw::sound::is_music_playing | ( | ) |
| void asw::sound::pause_music | ( | ) |
| asw::sound::SoundHandle asw::sound::play | ( | const asw::Sample & | sample, |
| const PlayOptions & | options ) |
| asw::sound::SoundHandle asw::sound::play | ( | const asw::Sample & | sample, |
| float | volume = 1.0F, | ||
| float | pan = 0.0F, | ||
| bool | loop = false ) |
Play a sample.
| sample | Sample to play |
| volume | Playback volume (0.0 - 1.0). |
| pan | Panning (-1.0 - 1.0), where -1.0 is full left, 0.0 is center, and 1.0 is full right. |
| loop | Whether to loop the sample (false = no loop, true = infinite loop). |
| asw::sound::SoundHandle asw::sound::play_at | ( | const asw::Sample & | sample, |
| float | x, | ||
| const PlayOptions & | options ) |
Play a sample panned by where it happens on screen, with options. Works like play_at above, so pitch, variation, bus and priority can be set too. The pan is worked out once when the sound starts.
| sample | Sample to play |
| x | Horizontal position in logical screen coordinates. |
| options | How to play it. volume is before distance fading, pan is replaced by the screen position. |
| asw::sound::SoundHandle asw::sound::play_at | ( | const asw::Sample & | sample, |
| float | x, | ||
| float | volume = 1.0F ) |
Play a sample panned by where it happens on screen. Sounds pan towards the side they are on and fade out once they are off screen, going silent a full screen width past the edge.
| sample | Sample to play |
| x | Horizontal position in logical screen coordinates. |
| volume | Playback volume (0.0 - 1.0) before distance fading. |
| void asw::sound::play_music | ( | const asw::Music & | sample, |
| float | volume = 1.0F, | ||
| float | fade_in_s = 0.0F ) |
| asw::sound::SoundHandle asw::sound::play_positional | ( | const asw::Sample & | sample, |
| const Vec2< float > & | position, | ||
| const PlayOptions & | options = {} ) |
Play a sample at a point in the world. It is panned, faded and pitch shifted relative to the listener, and keeps updating while it plays.
| sample | Sample to play |
| position | The world position. |
| options | How to play it. |
| void asw::sound::set_bus_volume | ( | Bus | bus, |
| float | volume ) |
| void asw::sound::set_doppler | ( | float | factor, |
| float | speed_of_sound = 3000.0F ) |
| void asw::sound::set_master_volume | ( | float | volume | ) |
| void asw::sound::set_music_volume | ( | float | volume | ) |
| void asw::sound::set_sfx_volume | ( | float | volume | ) |
| void asw::sound::set_spatial_mode | ( | SpatialMode | mode | ) |