4
votes

I'm working on a browser-based patching interface for Web Audio API synths. Frequency modulation (hooking an oscillator to the frequency of another oscillator) works as expected in Chrome. It should be a sci-fi sound like a 300Hz sin wave with the frequency wavering 30Hz.

In Safari (and Mobile Safari) it just sounds like a low rumble. It sounds like there is FM, but not the right base frequency. Is this just a browser quirk that will be ironed out in future versions? Is there a workaround now?

Here is the visual/interactive version:
html5 fm synth
http://forresto.github.com/dataflow-webaudio/

And the fiddle version, with the minimum code to demonstrate the effect:
http://jsfiddle.net/FVaWL/28/

var mod, modGain, osc;

var out = context.destination;

var startTest = function(){
    mod = context.createOscillator();
    mod.frequency.value = 8;

    modGain = context.createGain();
    modGain.gain.value = 30;

    osc = context.createOscillator();
    osc.frequency.value = 300;

    mod.connect(modGain);
    modGain.connect(osc.frequency);
    osc.connect(out);

    osc.start(0);
    mod.start(0);
};

var stopTest = function(){
    osc.stop(0);
    mod.stop(0);
    mod = modGain = osc = null;
};
2

2 Answers

1
votes

Safari 6's webkit has an older version of web audio. Try it on a nightly build, and it might be better - but yes, these are transient issues.

0
votes

This is an older question but I'll answer since I've come across this before. It seems that in older Safari versions, the GainNode value was limited to 0..1. In Chrome and newer Safari versions you can assign any value (I've run FM/xmod with gain nodes at 30000, for example). I haven't found a solution to this, other than to advise users to use a current browser. The good news is that as of 2016 / Safari 9, the issue has been fixed.