Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
114 lines (72 sloc) 3.38 KB
/**
\page lua_api_audio Audio
You can play musics and sound effects through \c sol.audio.
<hr>
\section lua_api_audio_functions Functions of sol.audio
<hr>
\subsection lua_api_audio_play_sound sol.audio.play_sound(sound_id)
Plays a sound effect.
A sound cannot be interrupted after you start playing it.
Several sounds can be played in parallel.
Unlike musics, sounds files are entirely read before being played.
A file access is made only the first time you play each sound.
You can use \ref lua_api_audio_preload_sounds if you want to also avoid this
initial file access.
- \c sound_id (string): Name of the sound file to play, relative to the
\c sounds directory and without extension. Currently, <tt>.ogg</tt> is the
only extension supported.
<hr>
\subsection lua_api_audio_preload_sounds sol.audio.preload_sounds()
Loads all sounds effects into memory for faster future access.
If you don't call this function, you can still play sound effects, but the
first access to each sound effect will require a file access that might be
perceptible on slow machines.
It is recommended to call this function at the beginning of the program
(typically from \ref lua_api_main_on_started or from your first screen).
The list of sound files to load is read from the
\ref project_db project database file.
This function does nothing if already called it before.
<hr>
\subsection lua_api_audio_play_music sol.audio.play_music(music_id)
Plays a music.
Only one music can be played at a time.
If a music was already playing, it will be stopped and replaced by the new
one.
- \c music_id (string): Name of the music file to play, relative to the
\c musics directory and without extension. The following extensions will be
tried in this order: \c <tt>.ogg</tt>, \c <tt>.it</tt> and \c <tt>.spc</tt>.
You can also specify the special value \c "none" to stop playing any music,
or \c "same" to let the music unchanged.
<hr>
\subsection lua_api_audio_stop_music sol.audio.stop_music()
Stops playing music.
This function has no effect if no music was playing.
This is equivalent to <tt>sol.audio.play_music("none")</tt>.
<hr>
\subsection lua_api_audio_get_sound_volume sol.audio.get_sound_volume()
Returns the current volume of sound effects.
This volume applies to all sounds played by \ref lua_api_audio_play_sound.
- Return value (number): The current volume of sound effects, as an integer
between \c 0 (mute) and \c 100 (full volume).
<hr>
\subsection lua_api_audio_set_sound_volume sol.audio.set_sound_volume(volume)
Sets the volume of sound effects.
This volume applies to all sounds played by \ref lua_api_audio_play_sound
and by the engine.
- \c volume (number): The new volume of sound effects, as an integer
between \c 0 (mute) and \c 100 (full volume).
<hr>
\subsection lua_api_audio_get_music_volume sol.audio.get_music_volume()
Returns the current volume of musics.
This volume applies to all musics played by \ref lua_api_audio_play_music
and by the engine.
- Return value (number): The current volume of musics, as an integer
between \c 0 (no sound effects) and \c 100 (full volume).
<hr>
\subsection lua_api_audio_set_music_volume sol.audio.set_music_volume(volume)
Sets the volume of musics.
This volume applies to all musics played by \ref lua_api_audio_play_music
and by the engine.
- \c volume (number): The new volume of musics, as an integer
between \c 0 (no music) and \c 100 (full volume).
*/
Something went wrong with that request. Please try again.