Key Concepts

Quick and dirty documentation for TinyRave. I strongly suggest coding with the TinyRave package for Atom.

TinyRave looks for two special functions when running your track: buildSample or buildTrack. A track should define either buildSample, OR buildTrack, but not both.

Most public methods use named parameters. Instead of parseMidi(myTransport, myParts) you would write parseMidi({transport: myTransport, parts: myParts}).


A mixable is any function that takes a time in seconds and returns a sample value. E.g.:

var mixable = function(time) { return Math.sin(TWO_PI * A_4 * time); }

Mixables generate audio samples. All process() functions in the Instruments library accept a mixable, and return a new mixable. buildSample() is itself a mixable.


The easiest way to generate audio. Define a function named buildSample, which accepts a time value and returns a sample. If defined TinyRave will call this function 44,100 times a second.


// JavaScript Example
var buildSample = function(time){
  return Math.sin(TWO_PI * A_4 * time);
# CoffeeScript Example
buildSample = (time) ->
  Math.sin TWO_PI * A_4 * time


The more powerful, but more advanced, way to compose tracks. Define a buildTrack function and it will run in the scope of a small DSL for scheduling events.

If defined, this function runs once.

You can call the following special methods in the body of your buildTrack function to schedule events and add mixables to the global mixer:

  • this.every(interval, callback)
  • this.until(duration, callback)
  • this.after(delay, callback)

And configure your environment:

  • this.setMasterGain(gain)
  • this.setBPM(bpm)

Technically we run any function named buildTrack in the scope of a BuildTrackEnvironment instance from the Standard Library.


// JavaScript Example
var buildTrack = function(){
  this.every(1, function(){
    // Every second ...
    var o = new Oscillator;
    var e = new Envelope;
    var mixable = e.process(o);

    // Add mixable to the global mixer;
# CoffeeScript Example
buildTrack = ->
  @every 1, ->
    o = new Oscillator
    e = new Envelope
    mixable = e.process(o)
    @play mixable


TinyRave provides two external libraries for added functionality. The adapter and standard library, included in all tracks by default, are open source.


Imported by default. Allows communication between a track and its host.

View Source


Imported by default. Tools to schedule events, along with note frequency definitions.

View Source


Optional. Oscillator, Filter, Envelope and Mixer classes. Higher-level abstractions for building music.

Import with require('v1/instruments')

View Source


Optional. An adapter for the JSON structures generated by an online MIDI converter: MidiConvert

Import with require('v1/midi')

View Source


results matching ""

    No results matching ""