» Uncategorized Posts

music_crossfade

Warning: A crossfading music track must be exactly the same length as its counterpart music track. This function will fail if there is even the tiniest of a length mismatch.

When called in a stage article, gradually crossfades the music to its laststock counterpart if a valid _laststock music file is detected in the /sounds folder. (A valid laststock counterpart to music_loop.ogg would be named music_loop_laststock.ogg, for example.) Both arguments are optional. This function can be used in conjunction with is_laststock() to replicate the music change on the Aethereal Gates stage.

ArgumentTypeDescription
fade_to_laststock:int[optional]
Determines whether to crossfade toward the laststock music track or the original music track. A value of 1 will crossfade toward the laststock track, and a value of 0 will crossfade into the original track.
amount_per_frame:real[optional]
Determines how much the volume decrements or increments per frame, with a range of 0 to 1.

Example 1, called from a stage’s update.gml:

// if everyone has 1 stock remaining, crossfade into laststock music at a rate of 0.01 per frame:
if (is_laststock()) {
music_crossfade();
}

Example 2, called from a stage’s update.gml:

// if everyone has 1 stock remaining, crossfade into laststock music at a rate of 0.025 per frame:
if (is_laststock()) {
music_crossfade( 1, 0.025 );
}

music_fade

When called in a stage article, gradually decreases or increases the background music to the target volume.

Both arguments are optional; by default the music will fade to silence. Once the music is fully silent, background music playback will be stopped.

ArgumentTypeDescription
volume:real(optional)
The target music volume, with a range of 0 to 1.
amount_per_frame:real(optional)
Determines how much the volume decrements or increments per frame, with a range of 0 to 1.

Example 1, called from a stage’s update.gml:

// fade to silence at a rate of 0.01 per frame:
music_fade();

Example 2, called from a stage’s update.gml:

// fade to 10% volume at a rate of 0.025 per frame:
music_fade( 0.1, 0.025 );

music_set_volume

When called in a stage article, instantly changes the background music volume.

ArgumentTypeDescription
volume:realThe target music volume, with a range of 0 to 1.

Example, called from a stage’s update.gml:

// instantly set music volume to 50%:
music_set_volume( 0.5 );

music_stop

When called in a stage article, stops the current background music track.

Example, called from a stage’s update.gml:

// instantly stop music:
music_stop();

music_play_file

When called in a stage article, plays a background music track which replaces the currently playing music track.

ArgumentTypeDescription
file:stringThe file to load located in the /sounds directory.

Example, called from a stage’s update.gml:

// plays "my_song.ogg" located in the /sounds directory:
music_play_file( "my_song" );