[demo] [code]


Trurl is Javascript for audio and animation.

It includes an abstraction layer over the Web Audio, Audio Data, and Canvas APIs, an event scheduler, a synthesis library, and a plotting library.

Animation runs under all modern browsers. Audio runs under recent versions of Firefox and Chrome, or under Safari for OS X with a properly configured nightly build. Everything also runs standalone under node.js.


Basic A/V sync is done by running the display on the first audio callback, if audio is enabled.

Audio is fixed to 2 channels.

Animation can be run under a specified target FPS with setInterval or a browser-determined frame rate with requestAnimationFrame. With setInterval timing of events can be controlled by Time or Frame number. With requestAnimationFrame events must be controlled by time, since the frame rate is variable and unknown. Latency correction is enabled by default for webAudioApi, else the audio begins bufferSize/sampleRate seconds after the display. All of these are configurable in the UI.

If performance is poor, try turning off the Waveform.


I had to peek at the (far superior) sink.js library for a workaround for this Chrome bug.

The Audio Data-specific code is adapted from the examples here.

Documentation generated with a modified docco-coffee.

Trurl is a constructor robot in Stanislaw Lem's The Cyberiad.