OSC Constructor working Routing
by Ehsan Ziya
HTML
<input type="button" id="play" value = "PLAY">
<input type="button" id="stop" value = "STOP">
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);
};
}