Yesterday, I took a Stromer electric bike out for a spin. I rented it from Blazing Saddles at the main Hyde Street location. I still don’t own an electric bike, but keep taking them out as rentals or on loan to check out this evolving technology. This is probably the one I’ve liked the best over the last few years of my periodic but infrequent testing.
AudioContext is very new, and many examples on the net illustrate the basics of starting and stopping a sound. The methods that start and stop sounds are called noteOn and noteOff. To start or stop a sound immediately you can call
The argument of 0 means “immediately” but does not correspond to the audio engine’s notion of “now.” Indeed, I first made the mistake of thinking that that the current audio time was relative to the execution time of the script: it is not – audio time is a property of the AudioContext.
To be completely explicit, I now write all mentions of sound triggers using the currentTime of a global audioContext.
var now = audioContext.currentTime;
sound.noteOn(now + 0);
var now audioContext.currentTime;
sound.noteOff(now + 0.5);