Log In  


Cart #47254 | 2017-12-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
11

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.

11


This is so cool! Nice job!



[Please log in to post a comment]