Functions to play some sound and music.
More...
|
void | ImportMusic (Context &context, const std::string &path, const std::string &name) |
|
void | ImportSFX (Context &context, const std::string &path, const std::string &name) |
|
void | PlayMusic (const Context &context, const std::string &name, i32 loops=-1) |
|
void | PlaySFX (const Context &context, const std::string &name, i32 loops=0, i32 ticks=-1) |
|
void | StopMusic (const Context &context, const std::string &name) |
|
void | StopSFX (const Context &context, const std::string &name) |
|
Functions to play some sound and music.
You need sdl2_mixer library to be installed. https://www.libsdl.org/projects/SDL_mixer/
void ImportMusic |
( |
Context & |
context, |
|
|
const std::string & |
path, |
|
|
const std::string & |
name |
|
) |
| |
Loads audio file in memory. Setup an association between sound and name.
- Parameters
-
path | Music file path |
name | Name to reference this music from the PlayMusic() function |
Definition at line 8 of file sound.cpp.
void ImportSFX |
( |
Context & |
context, |
|
|
const std::string & |
path, |
|
|
const std::string & |
name |
|
) |
| |
Loads audio file in memory. Setup an association between sound and name.
- Parameters
-
path | Sound effect file path |
name | Name to reference this sound effect from the PlaySFX() function |
Definition at line 11 of file sound.cpp.
void PlayMusic |
( |
const Context & |
context, |
|
|
const std::string & |
name, |
|
|
i32 |
loops = -1 |
|
) |
| |
- Parameters
-
name | Name of the music to play. |
loops | Number of loops, -1 is infinite loops. Passing one here plays the sample twice (1 loop). |
Definition at line 14 of file sound.cpp.
void PlaySFX |
( |
const Context & |
context, |
|
|
const std::string & |
name, |
|
|
i32 |
loops = 0 , |
|
|
i32 |
ticks = -1 |
|
) |
| |
- Parameters
-
name | Name of the music to play. |
loops | Number of loops, -1 is infinite loops. Passing one here plays the sample twice (1 loop). |
ticks | Millisecond limit to play sample, at most. If not enough loops or the sample chunk is not long enough, then the sample may stop before this timeout occurs. -1 means play forever. |
Definition at line 17 of file sound.cpp.
void StopMusic |
( |
const Context & |
context, |
|
|
const std::string & |
name |
|
) |
| |
Stop the music. Next PlayMusic call starts playing from the beginning.
- Parameters
-
context | |
name | unique music name which was set by ImportMusic |
Definition at line 20 of file sound.cpp.
void StopSFX |
( |
const Context & |
context, |
|
|
const std::string & |
name |
|
) |
| |
Stop the sound effect. Next PlaySFX call starts playing from the beginning.
- Parameters
-
context | |
name | unique sound effect name which was set by ImportSFX |
Definition at line 23 of file sound.cpp.