Stromer Electric Bike

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.

Stromer Electric Bike

Specs

When I first started trying out electric bikes, I basically wanted a motorcycle experience. Continue reading Stromer Electric Bike

AudioContext, noteOn/noteOff, currentTime and time units

The Web Audio API is a high-level JavaScript API for processing sounds in web applications. The specification was released in 2012, and is supported in Chrome and Safari on Mac OSX, and in iOS6. Implementations of the standard I’ve tested are stable and responsive.

Beosystem 2000

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

    noteOn(0)

or

    noteOff(0)

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);

or

    var now audioContext.currentTime;
    sound.noteOff(now + 0.5);

Background

An AudioContext is an object into which sounds can be rendered, much in the way graphics can be rendered into a Canvas. Continue reading AudioContext, noteOn/noteOff, currentTime and time units