electronoora / webaudio-mod-player

MOD/S3M/XM module player for Web Audio
https://mod.haxor.fi/
MIT License
364 stars 54 forks source link

run a js callback when playing a specific note #1

Closed ranska closed 8 years ago

ranska commented 9 years ago

Thanks for your player. It seem the most active those days. (i use it in ludumdare31)

So my question is: Is there a way to run a js function, when the player play a specific note ?

electronoora commented 9 years ago

There's no such feature at the moment. However, you can put E8x or 8xy commands into your song and use them for syncing function calls to the music.

Create a function which is called with regular intervals and call the function hassyncevents() in your module object to check whether there are sync events queued. While it returns true, use the function popsyncevent() to pop the oldest value (0x0 to 0xF, lower 4 bits off the E8x/8xy command) off the FIFO and perform your syncing.