WebAudio MIDI-fied Drum Machine
webaudiodemos.appspot.com
webaudiodemos.appspot.com
The audio processing itself works fine while in the background, but the api makes no facility at all for any sequencing or any user-supplied control-rate data which runs as part of the audio graph. This is rather unfortunate and makes it hard to build real applications.
If somebody knows some solution for scheduling playback events while in a background tab, please speak up. In my own experiments, the very best I was able to do was synthesizing control-like signals inside of a ScriptProcessorNode. I quit before I got it to work, but that's all I could really come up with. The other option would have been to start scheduling 500ms ahead once the tab goes into the background, but you have to know it's coming.
When developing client-side javascript I get the impression that time is running on a thin sheet of rubber. I have also wanted to have a more reliable tick but I often have to move onto other parts of what I am working on.
One useful technique is to try to create a fixed tick that all clients can receive, at least you can use this to nail down some of the rubber sheet. I use a shared tick emitting from the websocket server, and then calculate -- every sec -- how that differs from client time. In order to give clients a synchronized event I "schedule ahead" using setTimeout and this client-server time diff.
There are a couple of synth examples on the root page of that domain, just need to make 'em scream and squelch. Easier said than done unfortunately.
{"kitIndex":0,"effectIndex":1,"tempo":100,"swingFactor":0,"effectMix":0.10204081632653061, "kickPitchVal":0.5102040816326531,"snarePitchVal":0.5,"hihatPitchVal":0.5,"tom1PitchVal":0.4285714285714286,"tom2PitchVal":0.5,"tom3PitchVal":0.5,"rhythm1":[2,2,0,0,0,0,1,2,2,0,0,0,1,2,2,2],"rhythm2":[0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0],"rhythm3":[0,0,0,2,2,2,0,0,0,2,2,0,2,0,2,2],"rhythm4":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"rhythm5":[0,0,0,2,0,1,2,0,0,2,0,0,2,0,0,2],"rhythm6":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}
{"kitIndex":4, "effectIndex":15, "tempo":176, "swingFactor":0, "effectMix":0.326530612244898, "kickPitchVal":0.5, "snarePitchVal":0.5, "hihatPitchVal":0.6122448979591837, "tom1PitchVal":0.8571428571428572, "tom2PitchVal":0.7551020408163265, "tom3PitchVal":0.6734693877551021, "rhythm1":[2,0,0,0,0,0,1,0,0,0,2,0,0,0,0,0], "rhythm2":[0,0,0,0,2,0,0,1,0,1,0,0,2,0,0,0], "rhythm3":[2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1], "rhythm4":[0,0,2,0,0,0,0,0,0,0,0,0,0,0,1,0], "rhythm5":[0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0], "rhythm6":[0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0]}
(I believe FF has a separate mozAudioContext(), cant wait till this stuff is standard in browsers).
This is awesome!
except for cross browser compatibility, which i don't particularly care about for audio experiments.