Benjamin Smedberg writes:

> Is there a way to keep WebAudio from "popping" when
> I start/stop an oscillator or change gain? The WebAudio spec
> claims that changes in gain should be dezippered to avoid popping,
> but that doesn't seem to happen in practice. e.g. this kind of
> script is popping a lot for me on mac:
>
> var gAudio = new AudioContext();
> var gGain = gAudio.createGain();
> gGain.gain.value = 0;
> gGain.connect(gAudio.destination);
> var gOscillator = gAudio.createOscillator();
> gOscillator.frequency.value = 256;
> gOscillator.connect(gGain);
> gOscillator.start(0);
>
> function toggleGain()
> {
>   if (gGain.gain.value == 0) {
>     gGain.gain.value = 1;
>   }
>   else {
>     gGain.gain.value = 0;
>   }
> }
> setInterval(toggleGain, 400);

GainNode.gain.value changes probably will be de-zippered by Gecko
one day.  There has been discussion re if and how on public-audio.

gain.setValueAtTime(), gain.linearRampToValueAtTime(), etc. are
the intended means of explicitly making continuous changes.

If you need an interval less than about 100 ms, the methods above
have issues [1].  See [2] for the best working solutions that I
know on release, or [3] for Gecko 29.

[1] http://lists.w3.org/Archives/Public/public-audio/2013OctDec/0286.html
[2] view-source:http://people.mozilla.org/~karlt/delay-changes-cross-fade.html
[3] view-source:https://bug943589.bugzilla.mozilla.org/attachment.cgi?id=8338792

> Also, is there a minimum frequency for an oscillator? It seems
> like I don't get any audible output for sine-wafe frequencies
> below 115 or so and square-wave frequencies below 55 or so, when
> both piano and human hearing go down to 25hz or so.

I suspect that is probably a speaker limitation.
You can hear square waves with lower fundamental frequencies
because they have high frequency components.
_______________________________________________
dev-media mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-media

Reply via email to