oampo / Audiolet

A JavaScript library for real-time audio synthesis and composition from within the browser
http://oampo.github.com/Audiolet/
Apache License 2.0
895 stars 117 forks source link

Pass different frequncies to each channel? #22

Closed waynehoover closed 12 years ago

waynehoover commented 12 years ago

Is there a way to pass an audiolet.output to each channel? For example in the creation of Binaural Beats two slightly different frequencies are passed to the left and right channel. How is this possible with Audiolet?

oampo commented 12 years ago

To get this to work you need something like:

    var audiolet = new Audiolet();
    var sine1 = new Sine(audiolet, frequency1);
    var sine2 = new Sine(audiolet, frequency2);
    var pan1 = new Pan(audiolet, 0);
    var pan2 = new Pan(audiolet, 1);
    sine1.connect(pan1);
    sine2.connect(pan2);
    pan1.connect(audiolet.output);
    pan2.connect(audiolet.output);

What happens is that the pan nodes convert the mono sine outputs to stereo outputs panned to the left and right, which are then summed at audiolet.output.

Hope this helps, Joe