Mooog examples

3. Tracks

Creating tracks and sends

Track#balafon
Track#delay
Track#reverb

In addition to connect() and chain(), Mooog provides a Track object which is a special node that includes a pan/gain stage and a send() method that routes audio to another track, pre- or post-fader. The track object takes a string id as its first argument followed by one or more objects to define the nodes of its internal chain.

In this example, we've set up 3 Track objects: an AudioBuffer to play a sound, and two effects tracks for delay (sent post-fader) and a reverb (sent pre-fader). Since the returns are also Track objects, they have their own gain and pan controls.

In the code below, the slider change events are omitted for brevity. Track sends are just Gain objects so changing send levels after init is simply: M.track("balafon").send("delay_send").param("gain", new_gain_value);

M = new Mooog();
M.track( "balafon",
    { id: "ding", node_type: "AudioBufferSource", buffer_source_file: "sound/balafon1.mp3", loop: true },
    { id: "compressor", node_type: "DynamicsCompressor", threshold: -30, ratio: 50 } //gross compression to demonstrate automatic chaining
);
M.track( "delay",
    { node_type: "Delay", delayTime: 0.76, feedback: 0.2 }
);
M.track( "reverb",
    { node_type: "Convolver", buffer_source_file: "sound/impulse-responses/st-andrews-church-ortf-shaped.mp3" }
);

// track.send( id, destination, pre/post, initial_gain )
M.track("balafon").send( 'delay_send', M.track('delay'), 'post', 0.5);
M.track("balafon").send( 'reverb_send', M.track('reverb'), 'pre', 0.25);

$(document)
    .on("mousedown", ".ding.start", function(){
        M.node("ding").start();
    })
    .on("mousedown", ".ding.stop", function(){
        M.node("ding").stop();
    })



<< 2. Parameters
4. Envelopes >>

AudioContext not fully supported

Your browser doesn't fully support the current AudioContext spec, so these examples may not function.

For more information, see the section on browser support.