SplashKit's audio library allows you to easily load and play music and
sound effects within your programs. To get started with audio the first
thing you need to do is load a sound effect or music file. You can do this
by calling the Load Sound Effect(string Name)
function to the
Load Music(string Name)
function.
Audio Guides
Get started with SplashKit AudioFunctions
Fade Music In
Fade Music In
Fades music file matching the name to full volume over a specified number of milliseconds
- Parameters
-
Name Type Description Name String
The name of the
Music
file to play.Ms Integer
How many milliseconds it takes to fade the
Music
to full volume - Signatures
-
void fade_music_in(const string &name, int ms)
public static void Audio.FadeMusicIn(string name, int ms); public static void SplashKit.FadeMusicIn(string name, int ms);
procedure FadeMusicIn(const name: String; ms: Integer)
def fade_music_in_named(name, ms):
Fade Music In
Fades music file matching the name to full volume over a specified number of milliseconds and loops a specified number of times
- Parameters
-
Name Type Description Name String
The name of the
Music
file to play.Times Integer
Controls the number of times the music is played.
Ms Integer
How many milliseconds it takes to fade the
Music
to full volume - Signatures
-
void fade_music_in(const string &name, int times, int ms)
public static void Audio.FadeMusicIn(string name, int times, int ms); public static void SplashKit.FadeMusicIn(string name, int times, int ms);
procedure FadeMusicIn(const name: String; times: Integer; ms: Integer)
def fade_music_in_named_with_times(name, times, ms):
Fade Music In
Fades music up to full volume over a specified number of milliseconds.
- Parameters
-
Name Type Description Data The name of the
Music
to play.Ms Integer
How many milliseconds it takes to fade the
Music
to full volume - Signatures
-
void fade_music_in(music data, int ms)
public void Music.FadeMusicIn(int ms); public static void SplashKit.FadeMusicIn(Music data, int ms);
procedure FadeMusicIn(data: Music; ms: Integer)
def fade_music_in(data, ms):
Fade Music In
Fades music up to full volume over a specified number of milliseconds for a specified number of times.
- Parameters
-
Name Type Description Data The name of the
Music
to play.Times Integer
Controls the number of times the music is played.
Ms Integer
How many milliseconds it takes to fade the
Music
to full volume - Signatures
-
void fade_music_in(music data, int times, int ms)
public void Music.FadeMusicIn(int times, int ms); public static void SplashKit.FadeMusicIn(Music data, int times, int ms);
procedure FadeMusicIn(data: Music; times: Integer; ms: Integer)
def fade_music_in_with_times(data, times, ms):
Fade Music Out
Fades music outover a specified number of milliseconds
- Parameters
-
Name Type Description Ms Integer
How many milliseconds it takes to fade the
Music
out - Signatures
-
void fade_music_out(int ms)
public static void Audio.FadeMusicOut(int ms); public static void SplashKit.FadeMusicOut(int ms);
procedure FadeMusicOut(ms: Integer)
def fade_music_out(ms):
Free All Music
Releases all of the music files that have been loaded.
- Signatures
-
void free_all_music()
public static void Audio.FreeAllMusic(); public static void SplashKit.FreeAllMusic();
procedure FreeAllMusic()
def free_all_music():
Free Music
Releases the SplashKit resources associated with music.
- Parameters
-
Name Type Description Effect The music file whose resources should be released.
- Signatures
-
void free_music(music effect)
public void Music.FreeMusic(); public static void SplashKit.FreeMusic(Music effect);
procedure FreeMusic(effect: Music)
def free_music(effect):
Has Music
Determines if SplashKit has a music file loaded for the supplied name.
This checks against all music files loaded, those loaded without a name
are assigned the filename as a default. If this returns False
, you may
want to use Load Music
to load in a specific sound effect and give
it the desired name.
- Return Type
-
Boolean
Returns
True
if there is a music file with the givenName
has has been loaded. - Parameters
-
Name Type Description Name String
The name to check if a music file is loaded.
- Signatures
-
bool has_music(const string &name)
public static bool Audio.HasMusic(string name); public static bool SplashKit.HasMusic(string name);
function HasMusic(const name: String): Boolean
def has_music(name):
Load Music
Loads and returns a music value. The supplied Filename
is used to
locate the music file to load. The supplied Name
indicates the
name to use to refer to this Music value. The Music
can then be
retrieved by passing this Name
to the Music Named
function.
- Return Type
-
A new music resource
- Parameters
-
Name Type Description Name String
The name of the resource for SplashKit
Filename String
The filename to load
- Signatures
-
music load_music(const string &name, const string &filename)
public static Music SplashKit.LoadMusic(string name, string filename); public Music(string name, string filename);
function LoadMusic(const name: String; const filename: String): Music
def load_music(name, filename):
- Guides
- Get started with SplashKit Audio
Music Filename
Returns the filename the of the music data
- Return Type
-
String
Returns a string with the filename of the
Music
file. - Parameters
-
Name Type Description Data The music resource
- Signatures
-
string music_filename(music data)
public string Music.Filename { get } public static string SplashKit.MusicFilename(Music data);
function MusicFilename(data: Music): String
def music_filename(data):
Music Name
Returns the name that SplashKit uses to refer to this music data
- Return Type
-
String
Returns a string with the name of the
Music
that SplashKit refers to. - Parameters
-
Name Type Description Data The music resource
- Signatures
-
string music_name(music data)
public string Music.Name { get } public static string SplashKit.MusicName(Music data);
function MusicName(data: Music): String
def music_name(data):
Music Named
Retrieves a Music
that has been loaded into SplashKit.
- Return Type
-
Returns the
Music
that has been loaded with the specifiedName
usingLoad Music
. - Parameters
-
Name Type Description Name String
The name of the music file to return.
- Signatures
-
music music_named(const string &name)
public static Music Audio.MusicNamed(string name); public static Music SplashKit.MusicNamed(string name);
function MusicNamed(const name: String): Music
def music_named(name):
- Guides
- Get started with SplashKit Audio
Music Playing
Checks whether music is currently playing.
- Return Type
-
Boolean
Returns true or false value representing whether music is currently playing.
- Signatures
-
bool music_playing()
public static bool Audio.Playing { get } public static bool SplashKit.MusicPlaying();
function MusicPlaying(): Boolean
def music_playing():
Music Volume
Returns the volume of the currently playing Music
.
- Return Type
-
Float
Returns the percentage of the currently playing
Music
. - Signatures
-
float music_volume()
public static float Audio.Volume { get } public static float SplashKit.MusicVolume();
function MusicVolume(): Single
def music_volume():
Pause Music
Pauses currently playing music - see resume_music to continue playing.
- Signatures
-
void pause_music()
public static void Audio.PauseMusic(); public static void SplashKit.PauseMusic();
procedure PauseMusic()
def pause_music():
Play Music
Play Music
Plays the music file that matches the name once at full volume.
- Parameters
-
Name Type Description Name String
The name of the
Music
to play. - Signatures
-
void play_music(const string &name)
public static void Audio.PlayMusic(string name); public static void SplashKit.PlayMusic(string name);
procedure PlayMusic(const name: String)
def play_music_named(name):
- Guides
- Get started with SplashKit Audio
Play Music
Plays the music file that matches the name a specified number of times at full volume.
- Parameters
-
Name Type Description Name String
The name of the
Music
to play.Times Integer
Controls the number of times the music is played.
- Signatures
-
void play_music(const string &name, int times)
public static void Audio.PlayMusic(string name, int times); public static void SplashKit.PlayMusic(string name, int times);
procedure PlayMusic(const name: String; times: Integer)
def play_music_named_with_times(name, times):
- Guides
- Get started with SplashKit Audio
Play Music
Plays a music file once at full volume.
- Parameters
-
Name Type Description Data The name of the
Music
to play. - Signatures
-
void play_music(music data)
public void Music.PlayMusic(); public static void SplashKit.PlayMusic(Music data);
procedure PlayMusic(data: Music)
def play_music(data):
- Guides
- Get started with SplashKit Audio
Play Music
Plays a music file a specified number of times at full volume.
- Parameters
-
Name Type Description Data The name of the
Music
to play.Times Integer
Controls the number of times the music is played.
- Signatures
-
void play_music(music data, int times)
public void Music.PlayMusic(int times); public static void SplashKit.PlayMusic(Music data, int times);
procedure PlayMusic(data: Music; times: Integer)
def play_music_with_times(data, times):
- Guides
- Get started with SplashKit Audio
Play Music
Plays a music file for a specified number of times and playback volume.
- Parameters
-
Name Type Description Data The name of the
Music
to play.Times Integer
Controls the number of times the music is played.
Volume Float
Indicates the percentage of the original volume to play the
Music
at. This must be between0
and1
. - Signatures
-
void play_music(music data, int times, float volume)
public void Music.PlayMusic(int times, float volume); public static void SplashKit.PlayMusic(Music data, int times, float volume);
procedure PlayMusic(data: Music; times: Integer; volume: Single)
def play_music_with_times_and_volume(data, times, volume):
- Guides
- Get started with SplashKit Audio
Resume Music
Resumes currently paused music - see pause_music to pause playing music.
- Signatures
-
void resume_music()
public static void Audio.ResumeMusic(); public static void SplashKit.ResumeMusic();
procedure ResumeMusic()
def resume_music():
Set Music Volume
Sets the volume of the currently playing Music
. Must be between 0 and 1, e.g. 0.1 is 10%.
- Parameters
-
Name Type Description Volume Float
Indicates the percentage of the original volume to play the
Music
at. This must be between0
and1
. - Signatures
-
void set_music_volume(float volume)
public static void Audio.Volume { set } public static void SplashKit.SetMusicVolume(float volume);
procedure SetMusicVolume(volume: Single)
def set_music_volume(volume):
Stop Music
Stops currently playing music.
- Signatures
-
void stop_music()
public static void Audio.StopMusic(); public static void SplashKit.StopMusic();
procedure StopMusic()
def stop_music():
Fade All Sound Effects Out
Fades out all Sound Effect
s over the specified milliseconds.
- Parameters
-
Name Type Description Ms Integer
The number of milliseconds to fade out all sound effects.
- Signatures
-
void fade_all_sound_effects_out(int ms)
public static void Audio.FadeAllSoundEffectsOut(int ms); public static void SplashKit.FadeAllSoundEffectsOut(int ms);
procedure FadeAllSoundEffectsOut(ms: Integer)
def fade_all_sound_effects_out(ms):
Fade Sound Effect Out
Fades out the Sound Effect
over the specified milliseconds.
- Parameters
-
Name Type Description Effect The
Sound Effect
to fade out.Ms Integer
The number of milliseconds to fade out the
Sound Effect
. - Signatures
-
void fade_sound_effect_out(sound_effect effect, int ms)
public void SoundEffect.FadeSoundEffectOut(int ms); public static void SplashKit.FadeSoundEffectOut(SoundEffect effect, int ms);
procedure FadeSoundEffectOut(effect: SoundEffect; ms: Integer)
def fade_sound_effect_out(effect, ms):
Free All Sound Effects
Releases all of the sound effects that have been loaded.
- Signatures
-
void free_all_sound_effects()
public static void Audio.FreeAllSoundEffects(); public static void SplashKit.FreeAllSoundEffects();
procedure FreeAllSoundEffects()
def free_all_sound_effects():
Free Sound Effect
Releases the SplashKit resources associated with the sound effect.
- Parameters
-
Name Type Description Effect The
Sound Effect
whose resources should be released. - Signatures
-
void free_sound_effect(sound_effect effect)
public void SoundEffect.FreeSoundEffect(); public static void SplashKit.FreeSoundEffect(SoundEffect effect);
procedure FreeSoundEffect(effect: SoundEffect)
def free_sound_effect(effect):
Has Sound Effect
Determines if SplashKit has a sound effect loaded for the supplied name.
This checks against all sounds loaded, those loaded without a name
are assigned the filename as a default. If this returns False
, you may
want to use Load Sound Effect
to load in a specific sound effect and give
it the desired name.
- Return Type
-
Boolean
Returns
True
if there is a sound effect with the givenName
has has been loaded. - Parameters
-
Name Type Description Name String
The name to check if a sound effect is loaded.
- Signatures
-
bool has_sound_effect(const string &name)
public static bool Audio.HasSoundEffect(string name); public static bool SplashKit.HasSoundEffect(string name);
function HasSoundEffect(const name: String): Boolean
def has_sound_effect(name):
Load Sound Effect
The supplied Filename
is used to locate the sound effect to load. The
supplied Name
indicates the name to use to refer to this Sound Effect
.
The Sound Effect
can then be retrieved by passing this Name
to
the Sound Effect Named
function.
- Return Type
-
A new
Sound Effect
with the initialised values provided. - Parameters
-
Name Type Description Name String
The name used to refer to the sound effect.
Filename String
The filename used to locate the sound effect to use.
- Signatures
-
sound_effect load_sound_effect(const string &name, const string &filename)
public static SoundEffect SplashKit.LoadSoundEffect(string name, string filename); public SoundEffect(string name, string filename);
function LoadSoundEffect(const name: String; const filename: String): SoundEffect
def load_sound_effect(name, filename):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
-
Play Sound Effect
(
name
:
String
) -
Play Sound Effect
(
name
:
String
volume :Float
) -
Play Sound Effect
(
name
:
String
times :Integer
) -
Play Sound Effect
(
name
:
String
times :Integer
volume :Float
) -
Play Sound Effect
(
effect
:
Sound Effect
) -
Play Sound Effect
(
effect
:
Sound Effect
volume :Float
) -
Play Sound Effect
(
effect
:
Sound Effect
times :Integer
) -
Play Sound Effect
(
effect
:
Sound Effect
times :Integer
volume :Float
)
Play Sound Effect
Plays a sound effect once at full volume.
- Parameters
-
Name Type Description Name String
The name of the effect to play.
- Signatures
-
void play_sound_effect(const string &name)
public static void Audio.PlaySoundEffect(string name); public static void SplashKit.PlaySoundEffect(string name);
procedure PlaySoundEffect(const name: String)
def play_sound_effect_named(name):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect once at full volume.
- Parameters
-
Name Type Description Name String
The name of the effect to play.
Volume Float
The volume to play the
Sound Effect
- Signatures
-
void play_sound_effect(const string &name, float volume)
public static void Audio.PlaySoundEffect(string name, float volume); public static void SplashKit.PlaySoundEffect(string name, float volume);
procedure PlaySoundEffect(const name: String; volume: Single)
def play_sound_effect_named_with_volume(name, volume):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect for a specified number of times at full volume.
- Parameters
-
Name Type Description Name String
The name of the effect to play.
Times Integer
Controls the number of times the sound effect is played.
- Signatures
-
void play_sound_effect(const string &name, int times)
public static void Audio.PlaySoundEffect(string name, int times); public static void SplashKit.PlaySoundEffect(string name, int times);
procedure PlaySoundEffect(const name: String; times: Integer)
def play_sound_effect_named_with_times(name, times):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect for a specified number of times and playback volume.
- Parameters
-
Name Type Description Name String
The name of the effect to play.
Times Integer
Controls the number of times the sound effect is played.
Volume Float
Indicates the percentage of the original volume to play the
Sound Effect
at. This must be between0
and1
. - Signatures
-
void play_sound_effect(const string &name, int times, float volume)
public static void Audio.PlaySoundEffect(string name, int times, float volume); public static void SplashKit.PlaySoundEffect(string name, int times, float volume);
procedure PlaySoundEffect(const name: String; times: Integer; volume: Single)
def play_sound_effect_named_with_times_and_volume(name, times, volume):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect once at full volume.
- Parameters
-
Name Type Description Effect The effect indicates which sound effect to start playing.
- Signatures
-
void play_sound_effect(sound_effect effect)
public void SoundEffect.PlaySoundEffect(); public static void SplashKit.PlaySoundEffect(SoundEffect effect);
procedure PlaySoundEffect(effect: SoundEffect)
def play_sound_effect(effect):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect once at playback volume.
- Parameters
-
Name Type Description Effect The effect indicates which sound effect to start playing.
Volume Float
Indicates the percentage of the original volume to play the
Sound Effect
at. This must be between0
and1
. - Signatures
-
void play_sound_effect(sound_effect effect, float volume)
public void SoundEffect.PlaySoundEffect(float volume); public static void SplashKit.PlaySoundEffect(SoundEffect effect, float volume);
procedure PlaySoundEffect(effect: SoundEffect; volume: Single)
def play_sound_effect_with_volume(effect, volume):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
Plays a sound effect once at full volume.
- Parameters
-
Name Type Description Effect The effect indicates which sound effect to start playing.
Times Integer
Controls the number of times the sound effect is played.
- Signatures
-
void play_sound_effect(sound_effect effect, int times)
public void SoundEffect.PlaySoundEffect(int times); public static void SplashKit.PlaySoundEffect(SoundEffect effect, int times);
procedure PlaySoundEffect(effect: SoundEffect; times: Integer)
def play_sound_effect_with_times(effect, times):
- Guides
- Get started with SplashKit Audio
Play Sound Effect
This version of Play Sound Effect
allows you to control both the number
of times the Sound Effect
is repeated and its playback volume.
- Parameters
-
Name Type Description Effect The effect indicates which sound effect to start playing.
Times Integer
Controls the number of times the sound effect is played.
Volume Float
Indicates the percentage of the original volume to play the
Sound Effect
at. This must be between0
and1
. - Signatures
-
void play_sound_effect(sound_effect effect, int times, float volume)
public void SoundEffect.PlaySoundEffect(int times, float volume); public static void SplashKit.PlaySoundEffect(SoundEffect effect, int times, float volume);
procedure PlaySoundEffect(effect: SoundEffect; times: Integer; volume: Single)
def play_sound_effect_with_times_and_volume(effect, times, volume):
- Guides
- Get started with SplashKit Audio
Sound Effect Filename
Returns the filename of the Sound Effect
that has been loaded by SplashKit
- Return Type
-
String
Returns the filename of the
Sound Effect
that has been loaded - Parameters
-
Name Type Description Effect The
Sound Effect
to check - Signatures
-
string sound_effect_filename(sound_effect effect)
public string SoundEffect.Filename { get } public static string SplashKit.SoundEffectFilename(SoundEffect effect);
function SoundEffectFilename(effect: SoundEffect): String
def sound_effect_filename(effect):
Sound Effect Name
Returns the name of the Sound Effect
that has been loaded by SplashKit
- Return Type
-
String
Returns the name of the
Sound Effect
that has been loaded - Parameters
-
Name Type Description Effect The
Sound Effect
to check - Signatures
-
string sound_effect_name(sound_effect effect)
public string SoundEffect.Name { get } public static string SplashKit.SoundEffectName(SoundEffect effect);
function SoundEffectName(effect: SoundEffect): String
def sound_effect_name(effect):
Sound Effect Named
Retrieves a Sound Effect
that has been loaded into SplashKit. If the
sound effect has not been loaded, this will attempt to use the name to
locate the file for you. If a file can be found, the sound effect is loaded
and returned.
- Return Type
-
Returns the
Sound Effect
that has been loaded with the specifiedName
usingLoad Sound Effect
. - Parameters
-
Name Type Description Name String
The name of the sound effect to return.
- Signatures
-
sound_effect sound_effect_named(const string &name)
public static SoundEffect Audio.SoundEffectNamed(string name); public static SoundEffect SplashKit.SoundEffectNamed(string name);
function SoundEffectNamed(const name: String): SoundEffect
def sound_effect_named(name):
- Guides
- Get started with SplashKit Audio
Sound Effect Playing
Sound Effect Playing
Checks whether the Sound Effect
that matches the name is currently playing
- Return Type
-
Boolean
Returns whether the "sound_effect" that matches the name is currently playing or not
- Parameters
-
Name Type Description Name String
The name of the
Sound Effect
- Signatures
-
bool sound_effect_playing(const string &name)
public static bool Audio.SoundEffectPlaying(string name); public static bool SplashKit.SoundEffectPlaying(string name);
function SoundEffectPlaying(const name: String): Boolean
def sound_effect_playing_named(name):
Sound Effect Playing
Checks whether the Sound Effect
is currently playing
- Return Type
-
Boolean
Returns whether the "sound_effect" is currently playing or not
- Parameters
-
Name Type Description Effect The
Sound Effect
to be tested. - Signatures
-
bool sound_effect_playing(sound_effect effect)
public bool SoundEffect.IsPlaying { get } public static bool SplashKit.SoundEffectPlaying(SoundEffect effect);
function SoundEffectPlaying(effect: SoundEffect): Boolean
def sound_effect_playing(effect):
Stop Sound Effect
Stop Sound Effect
Stops the Sound Effect
that matches the name, if it is currently playing.
- Parameters
-
Name Type Description Name String
The name of the
Sound Effect
to stop. - Signatures
-
void stop_sound_effect(const string &name)
public static void Audio.StopSoundEffect(string name); public static void SplashKit.StopSoundEffect(string name);
procedure StopSoundEffect(const name: String)
def stop_sound_effect_named(name):
Stop Sound Effect
Stops the Sound Effect
if it is currently playing
- Parameters
-
Name Type Description Effect The
Sound Effect
to stop. - Signatures
-
void stop_sound_effect(sound_effect effect)
public void SoundEffect.StopSoundEffect(); public static void SplashKit.StopSoundEffect(SoundEffect effect);
procedure StopSoundEffect(effect: SoundEffect)
def stop_sound_effect(effect):
Audio Ready
Checks if SplashKit audio currently ready to be used.
Should this return False
, you may want to use Open Audio
to enable audio.
- Return Type
-
Boolean
Returns
True
if the audio has been initalised. - Signatures
-
bool audio_ready()
public static bool Audio.IsReady { get } public static bool SplashKit.AudioReady();
function AudioReady(): Boolean
def audio_ready():
Close Audio
Turns off audio, stopping all current sounds effects and music.
- Signatures
-
void close_audio()
public static void Audio.CloseAudio(); public static void SplashKit.CloseAudio();
procedure CloseAudio()
def close_audio():
Open Audio
Starts the SplashKit audio system working.
- Signatures
-
void open_audio()
public static void Audio.OpenAudio(); public static void SplashKit.OpenAudio();
procedure OpenAudio()
def open_audio():
Types
Music
The Music type is used to refer to music that can be
played by SplashKit. Music files are loaded with
Load Music
, played using Play Music
, and must be
released using Free Music
.
Unlike Sound Effect
s, there can only be one music track
playing at a time. Playing an new track will stop the currently
playing music and switch to the new track.
Sound Effect
The Sound Effect
type is used to refer to sound effects that can be
played by the SplashKit audio code. Sound effects are:
loaded with
Load Sound Effect
,played using
Play Sound Effect
,and must be released using
Delete Sound Effect
(to release a specific sound effect) orDelete All Sound Effects
(to release all loaded sound effects).
SplashKit will mix the audio from multiple sound effects, making it
possible to play multiple Sound Effect
s, or even to play the one
Sound Effect
multiple times.
You can check if a Sound Effect
is currently playing using
Sound Effect Playing
.
To stop a Sound Effect
playing use Stop Sound Effect
. This will stop all
instances of this one sound effect from playing.
Use Music
for background music for your games.