var ctx = new AudioContext(); varsource = ctx.createOscillator(); var lfo = ctx.createOscillator(); var lfoIntensity = ctx.createGain(); var effect = ctx.createGain(); var sp = ctx.createScriptProcessor(2048, 1);
source.frequency.value = 440;
lfo.frequency.value = 2;
// Very low gain, so the LFO should have very little influence
// on the source, its RMS value should be close to the nominal value
// for a sine wave.
lfoIntensity.gain.value = 0.0001;
sp.onaudioprocess = function(e) { var buffer = e.inputBuffer.getChannelData(0); var rms = 0;
for (var i = 0; i < buffer.length; i++) {
rms += buffer[i] * buffer[i];
}
rms /= buffer.length;
rms = Math.sqrt(rms);
// 1 / Math.sqrt(2) is the theoretical RMS value for a sine wave.
ok(fuzzyCompare(rms, 1 / Math.sqrt(2)), "Gain correctly applied to the AudioParam.");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.