On 01/02/2014 22:11, Benjamin Smedberg wrote:
Not sure if there's a better group to ask about WebAudio stuff
specifically. 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);
There is an ongoing spec discussion [1] on how this should work:
automatic dezippering or explicit dezippering, on all AudioParam or only
a subset of them, which constant to use for the dezippering, etc. Gecko
implements dezippering only on the DelayNode's delayTime AudioParam, at
the moment. Note that in the meantime, something like:
gGain.gain.setTargetAtTime(desiredVolume, gAudio.currentTime, 0.05);
will smooth the transition for you with an exponential curve.
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.
This behaves just fine here (I can go down to super low frequencies, and
hear/feel it, but I've got high-end audio equipment). I'm running Linux,
but this code should be platform independent. Please get in touch on irc
(#media, ping padenot) or file a bug in the Core :: Web Audio component,
so we can fix it.
Cheers,
Paul.
[1]: http://lists.w3.org/Archives/Public/public-audio/2013OctDec/0304.html,
http://lists.w3.org/Archives/Public/public-audio/2013OctDec/0242.html
and followups.
___
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform