I’m using Web Audio API with javascript.
I create an oscillator, connect it to the volume (gainNode), connect it to a destination.
Ok. Nice.
I want a delay effect, I stick it between oscillator and volume.
Well, that doesn’t work, I only hear the delay. Although, it is clean.
Ok, so I connect the osc to the delay to the volume, and the osc to the volume, then the volume to the destination.
Now it seems to be distorted.
I tried osc to delay to volume to destination, with osc to destination so there are two connections to the destination. That too is distorted.
That’s on chrome.
In the little time I’ve had to try it, it seems to work right on iOS6. Don’t know about safari.
Try it by going to http://cloudmusiccompany.appspot.com/watch.jsp and clicking red and drawing. That’s a normal sine osc. Now click white and draw, that is the same withing with the delay, and on chrome (Ubuntu) it is distorted. Don’t know about Safar.
Obviously you can see the full source at the link because its javascript.
Relevant source:
function makeNewChannel(color){
var info = getInstrumentInfo(color);
var chan = {osc: acontext.createOscillator(),
freqs: [],
times: [],
pxdata: [],
i: 0,
muted: true,
finishedLoop: false,
volume: acontext.createGainNode(),
gate: acontext.createGainNode(),
delay: acontext.createDelayNode(),
delayGain: acontext.createGainNode(),
mute: function(){
this.muted = true;
this.volume.gain.value = 0;
},
unmute: function(){
this.muted = false;
this.volume.gain.value = player.defaultGain / (info.soft ? 2 : 1);
}
}
chan.osc.type = info.type;
// chan.osc.connect(chan.gate);
chan.osc.connect(chan.volume);
chan.delayGain.gain.value = player.defaultGain ;
/* ugh , the wet sounds ok, but somehow its distorting or doubling the dry signal
* although it seems ok on iphone?
* */
if (info.delay){
chan.delay.delayTime.value = 0.5;
chan.volume.connect(chan.delay)
chan.delay.connect(chan.delayGain);
chan.delayGain.connect(acontext.destination);
}
chan.volume.gain.value = 0; //player.defaultGain;
chan.gate.gain.value = 0;
chan.volume.connect(acontext.destination);
chan.osc.frequency.value = 0;
chan.osc.noteOn(0);
return chan;
}
I just had a chance to use it on Chrome on Windows, and it works fine. Delay sounds like it should.
This must be a bug in the Linux version (of chrome)