|
|
|
|
|
by bambax
1454 days ago
|
|
Interesting! The way I understand it, Web Audio API only lets one schedule audio source nodes with start and stop methods. As I needed to schedule something that was not audio related, I ended up creating silent oscillators of almost zero length and relying on the 'ended' event. But running a scheduled callback is better! It's not immediately clear to me how you do it. Can you maybe explain your code a little? |
|
It runs your callback every 16th note, slightly before it is actually due to play, this can vary by a few milliseconds each time but that doesn't matter as the actual audio context start time for the note is passed in to the callback, and you use that to actually schedule the events for that 16th note, eg: osc.start(time).
You can schedule 32nd notes etc too by using the stepLength property that is also passed in, time + (stepLength/2) would be a 32nd note.
Hope that makes sense? I do need to write a better description on the github page of what it actually is.
The inner workings of the library itself are mostly just as described in the article with a few tweaks.