Routing Works
by Ehsan Ziya
JavaScript
var context = new webkitAudioContext();
function osc(type, frequency , detune){
this.type = type;
this.frequency = frequency;
this.detune = detune;
this.oscillator = context.createOscillator();
this.gain = context.createGainNode();
this.oscillator.frequency.value = frequency;
this.oscillator.type = type;
this.oscillator.detune.value = detune;
this.play = function(destination , volume){
this.destination = destination;
this.volume = volume;
this.oscillator.connect(this.gain);
this.gain.gain.value = volume;
this.gain.connect(destination);
this.oscillator.start(0);
};
this.stop = function(){
this.oscillator.stop(0);
}
}
/*
osc.prototype.play = function(){
oscillator.connect(context.destination);
oscillator.noteOn(0);
};
*/
osctest = new osc("sine",400,0);
osctest.play(context.destination , 0.9);
osctest2 = new osc("sawtooth", 6 , 0);
osctest2.play(osctest.oscillator.frequency , 1000);
//osctest.stop();
//osctest2.stop();