All examples · Audio · As Markdown, for AIs

Layered music

What this example shows

useMusic plays one piece of music recorded in several files, its layers: here the melody, the harmony, the bass and the drums of the same minuet, all the same length. They always play together and in time, and the game only changes how loud each one is with setLayer. A layer that comes back comes in on the beat it is on, because it never stopped: that is music that follows the game (the drums for a fight, the melody gone in a cave) without starting over.

Which one to use. useSound plays one file: an effect, an ambience, a song that is a single recording. useMusic plays one piece in several files that the game fades in and out, this example. useSong plays a tune written as notes in a .song, made into sound by the engine's 8-bit synthesizer, which can also change its tempo and key.

Space to play, 1 to 4 to bring a layer in or out. The light blinks on every beat (onBeat, which needs the music's bpm), yellow on the first of the bar.

Starting
Starting
—