Simple Game Graphics Library
1.0
|
Functions | |
void | graphics::playSound (std::string soundfile, float volume, bool looping=false) |
void | graphics::playMusic (std::string soundfile, float volume, bool looping=true, int fade_time=0) |
void | graphics::stopMusic (int fade_time=0) |
void graphics::playMusic | ( | std::string | soundfile, |
float | volume, | ||
bool | looping = true , |
||
int | fade_time = 0 |
||
) |
Starts playing an audio file as a stream.
The function plays a sound file provided in mp3, ogg or wav format at specified volume level, with the option to indefinately loop it. The file is loaded in chunks, in order to support large audio files and therefore, the function is suitable for reproducing large pieces of music. If the provided sound file is successfully loaded, it is set to play immediately. If the sound file is not found, no sound is played. There is also the option to set a fade in/out time for a smooth transition to a subsequent call to the function using a different sound. The same fade effect applies to the beggining of the play cycle. Only one audio file can be played as "music" at any one time. A subsequent call to playMusic, simply fades in a new audio stream and eventually stops the currently played one.
\params soundfile is the music file to load in MP3, OGG or WAV format.
volume | is the volume of the played sound sample with values in the range [0,1] |
looping | sets the sound to indefinately loop. Default value is true; |
fade_time | is the fade-in/-out time for the audio file in miliseconds. Default value is 0. |
void graphics::playSound | ( | std::string | soundfile, |
float | volume, | ||
bool | looping = false |
||
) |
Plays a sound sample.
The function plays a sound file provided in mp3, ogg or wav format at specified volume level, with the option to indefinately loop it. If the provided sound file is successfully loaded into memory, it is set to play immediately. The sound data are kept in memory, therefore future attempts to play the sample, do not reload the file. If the sound file is not found, no sound is played.
soundfile | is the path to the file of the sound sample. WAV, MP3 or OGG file formats are supported. |
volume | is the volume of the played sound sample with values in the range [0,1] |
looping | sets the sound to indefinately loop. Default value is false; |
void graphics::stopMusic | ( | int | fade_time = 0 | ) |
Stops any music that is being played.
This operation only applies to audio files played with the playMusic function. The function also takes as optional argument a fade-out time.
\params fade_time is the fade-out time for the currently playing sound.