diff --git a/content/media/webaudio/test/test_AudioBuffer.html b/content/media/webaudio/test/test_AudioBuffer.html index b60b7fb7ca2..cd7112a915b 100644 --- a/content/media/webaudio/test/test_AudioBuffer.html +++ b/content/media/webaudio/test/test_AudioBuffer.html @@ -12,13 +12,13 @@ SimpleTest.waitForExplicitFinish(); addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); - var ac = new AudioContext(); - var buffer = ac.createBuffer(2, 2048, 44100); + var context = new AudioContext(); + var buffer = context.createBuffer(2, 2048, context.sampleRate); SpecialPowers.gc(); // Make sure that our channels are accessible after GC ok(buffer, "Buffer was allocated successfully"); - is(buffer.sampleRate, 44100, "Correct sample rate"); + is(buffer.sampleRate, context.sampleRate, "Correct sample rate"); is(buffer.length, 2048, "Correct length"); - ok(Math.abs(buffer.duration - 2048 / 44100) < 0.0001, "Correct duration"); + ok(Math.abs(buffer.duration - 2048 / context.sampleRate) < 0.0001, "Correct duration"); is(buffer.numberOfChannels, 2, "Correct number of channels"); for (var i = 0; i < buffer.numberOfChannels; ++i) { var buf = buffer.getChannelData(i); diff --git a/content/media/webaudio/test/test_biquadFilterNode.html b/content/media/webaudio/test/test_biquadFilterNode.html index 63efe926c4d..de6e029cb57 100644 --- a/content/media/webaudio/test/test_biquadFilterNode.html +++ b/content/media/webaudio/test/test_biquadFilterNode.html @@ -19,9 +19,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination; @@ -38,7 +38,7 @@ addLoadEvent(function() { // Verify default values is(filter.type, 0, "Correct default value for type"); near(filter.frequency.minValue, 10, "Correct min value for filter frequency"); - near(filter.frequency.maxValue, 22050, "Correct max value for filter frequency"); + near(filter.frequency.maxValue, context.sampleRate/2, "Correct max value for filter frequency"); near(filter.frequency.defaultValue, 350, "Correct default value for filter frequency"); near(filter.Q.minValue, 0.001, "Correct min value for filter Q"); near(filter.Q.maxValue, 1000, "Correct max value for filter Q"); diff --git a/content/media/webaudio/test/test_decodeAudioData.html b/content/media/webaudio/test/test_decodeAudioData.html index f881ec155d5..f7a0b6ed182 100644 --- a/content/media/webaudio/test/test_decodeAudioData.html +++ b/content/media/webaudio/test/test_decodeAudioData.html @@ -254,8 +254,13 @@ expectTypeError(function() { cx.decodeAudioData(new Uint8Array(100), callbackShouldNeverRun, callbackShouldNeverRun); }); -// Now, let's get real! -runNextTest(); +if (cx.sampleRate == 44100) { + // Now, let's get real! + runNextTest(); +} else { + todo(false, "Decoded data tests disabled; context sampleRate " + cx.sampleRate + " not supported"); + SimpleTest.finish(); +} diff --git a/content/media/webaudio/test/test_delayNode.html b/content/media/webaudio/test/test_delayNode.html index 76a5bb35994..9a7721fc5d0 100644 --- a/content/media/webaudio/test/test_delayNode.html +++ b/content/media/webaudio/test/test_delayNode.html @@ -15,9 +15,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination; diff --git a/content/media/webaudio/test/test_dynamicsCompressorNode.html b/content/media/webaudio/test/test_dynamicsCompressorNode.html index 97ec916a477..96266647eab 100644 --- a/content/media/webaudio/test/test_dynamicsCompressorNode.html +++ b/content/media/webaudio/test/test_dynamicsCompressorNode.html @@ -18,9 +18,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination; diff --git a/content/media/webaudio/test/test_gainNode.html b/content/media/webaudio/test/test_gainNode.html index 55ffdba7cc4..ebec5c4ccfb 100644 --- a/content/media/webaudio/test/test_gainNode.html +++ b/content/media/webaudio/test/test_gainNode.html @@ -14,9 +14,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination; diff --git a/content/media/webaudio/test/test_pannerNode.html b/content/media/webaudio/test/test_pannerNode.html index 4dbf16d509b..b531ebe7a8f 100644 --- a/content/media/webaudio/test/test_pannerNode.html +++ b/content/media/webaudio/test/test_pannerNode.html @@ -18,9 +18,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination; diff --git a/content/media/webaudio/test/test_singleSourceDest.html b/content/media/webaudio/test/test_singleSourceDest.html index 87e3ef295b7..b15a5a59a35 100644 --- a/content/media/webaudio/test/test_singleSourceDest.html +++ b/content/media/webaudio/test/test_singleSourceDest.html @@ -14,9 +14,9 @@ addLoadEvent(function() { SpecialPowers.setBoolPref("media.webaudio.enabled", true); var context = new AudioContext(); - var buffer = context.createBuffer(1, 2048, 44100); + var buffer = context.createBuffer(1, 2048, context.sampleRate); for (var i = 0; i < 2048; ++i) { - buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / 44100); + buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate); } var destination = context.destination;