Question

I'm trying to apply a pitch vibrato to an AudioBufferSource using an oscillator.

var source = context.createBufferSource();
source.connect(context.destination);
source.buffer = buffer;
source.loop = true;
source.start(0);

// None of the below seems to have any effect in Chrome

var osc = context.createOscillator();
osc.type = "sine";
osc.frequency.value = 0.5;
osc.start(0);

var osc_gain = context.createGain();
osc_gain.connect(source.playbackRate);
osc.connect(osc_gain);
// osc_gain.gain.value = 0.1 doesn't work
osc_gain.gain.setValueAtTime(0.1, 0);

Here's a fiddle. http://jsfiddle.net/HRkcE/12/

The oscillator doesn't seem to have any effect in Chrome, but is working in Firefox (once I figured out that setting osc_gain.gain.value directly doesn't work).

Am I doing anything wrong to make it not work in Chrome?

Was it helpful?

Solution

No, you're not doing anything wrong. Blink has a bug where we do not support this, which was reported to me by someone else just last week, and I filed: https://code.google.com/p/chromium/issues/detail?id=311284. We will get that fixed.

In the meantime, it's actually relatively easy to do a vibrato effect on ANY audio connection (not just buffersourcenodes) using an LFO to drive oscillations on the delayTime of a delayNode - check out the "Vibrato" effect I added to the end of http://webaudiodemos.appspot.com/input/index.html, and the node chain I set up to do it: https://github.com/cwilso/Audio-Input-Effects/blob/master/js/effects.js#L478 is the vibrato subgraph creation routine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top