问题
I am crossfading some audio and I have a equal power curve stored in a table. I'm calling this function to start the fadeout. The fade parameter is a GainNode made with createGain()
fade.gain.setValueCurveAtTime(epCurveOut, context.currentTime, fadeTime);
In Chrome and Safari all goes well, but Firefox (v30) complains:
SyntaxError: An invalid or illegal string was specified
Instead of context.currentTime I've tried 0 and 0.01. Is this method not implemented maybe? If so how would I alternatively schedule a cosine equal power ramp over time?
回答1:
This seems to be a bug on our end indeed, I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1069825 to track this.
回答2:
Firefox seems to give that error whenever it doesn't like the parameters to setValueCurveAtTime. For example, if epCurveOut is an empty Float32Array, or if there is already a parameter change scheduled at the same time. I suspect the latter, because Chrome doesn't throw an error under the same circumstances. For example:
curve = new Float32Array([0.5, 0.5]);
node.gain.setValueCurveAtTime(curve, 5, 1);
node.gain.setValueCurveAtTime(curve, 5, 1);
Firefox throws the error the second time. Chrome doesn't throw an error. If you call node.gain.cancelScheduledValues(5) in between the calls to setValueCurveAtTime, Firefox allows it.
EDIT: Oh, hmm, Chrome doesn't complain about an empty Float32Array either. Well, anyway, Firefox seems to be much less forgiving, and gives that error when the arguments' types are correct but the values aren't allowed.
来源:https://stackoverflow.com/questions/25899432/web-audio-api-firefox-setvaluecurveattime