Music Fountain (plus example code)

Subscribe to this Thread (Receive email notifications)

Copy and paste the snippet below into your HTML. Note: This cartridge's settings do not allow embedded playback. A [Play at lexaloffle] link will be included instead.

A particle effect that spawns streams based on the music that's playing!

The song is a chiptune cover of "STONEFIST" by HEALTH.

It never stops repeating once it starts, but the music loop is maybe 45 seconds long.

Here's an example of how to do some basic stuff that reacts to music:

// pick a channel - a number from 0-3 // (0 is the far-left channel in the music editor) channel=0 // get the sfx index that's playing in this channel // (the number at the top of an enabled music channel's column) sound=stat(16+channel) // get the current timeline position of this channel (0-31) row=stat(20+channel) // get the two bytes representing the channel's current note byte1=peek(0x3200+68*sound+row*2) byte2=peek(0x3200+68*sound+row*2+1) // now we can extract the note values! // all three of these return 0-7 volume=band(byte2,0b1110)/2 effect=band(byte2,0b1110000)/16 instrument=band(byte1,0b11000000)/64 instrument+=band(byte2,1)*4

More info about the audio memory layout is available here.