Web Audio API - Frequency Modulation is different in Chrome / Safari

I am working on a browser based patch interface for Web Audio API synthesizers. Frequency modulation (connecting an oscillator to the frequency of another oscillator) works as expected in Chrome. It should be a sci-fi sound such as a 300Hz waveform with a 30Hz frequency.

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

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

And a version of the script with minimal 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;
};

      

+3


source to share


2 answers


Safari 6 webkit has an older version of web audio. Try this on a nightly build and it might be better - but yes, these are temporary problems.



+1


source


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



0


source







All Articles