blob: d482633edb22d2b338b2b071a5b560bf0bf95286 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script src="resources/compatibility.js"></script>
<script src="resources/audio-testing.js"></script>
<script src="resources/audiobuffersource-testing.js"></script>
<script src="resources/buffer-loader.js"></script>
</head>
<body>
<script>
description('AudioBufferSourceNode: oscillator-driven playbackRate modulation.');
window.jsTestIsAsync = true;
var sampleRate = 44100;
var duration = 0.25;
var context = new OfflineAudioContext(1, sampleRate * duration, sampleRate);
var referenceBuffer;
var audit = Audit.createTaskRunner();
// Task: Load the reference file asynchronously. In order to create a new
// reference file, use the task 'generate-reference' below.
audit.defineTask('load-reference', function (done) {
var loader = new BufferLoader(context, [
'audiobuffersource-playbackrate-modulation-expected.wav'
], function (bufferList) {
referenceBuffer = bufferList[0];
done();
});
loader.load();
});
// Task: Render the actual buffer and compare with the reference.
audit.defineTask('generate-verify', function (done) {
// With this setting, the playback rate will be changing continuously and
// repeatedly within the range of [0, 200] around 100Hz, based on the
// input from the oscillator.
createSawtoothWithModulation(context, 'playbackRate', 100, 100);
context.startRendering().then(function (renderedBuffer) {
var actual = renderedBuffer.getChannelData(0);
var expected = referenceBuffer.getChannelData(0);
// Compare two buffers with arbitrary (yet reasonable) constraints.
// There parameters are determined by try bot experiments.
compareBuffersWithConstraints(actual, expected, {
thresholdSNR: 92.72,
thresholdDiffULP: 0.985,
thresholdDiffCount: 0,
bitDepth: 16
});
}).then(done);
});
// Task: Create a new reference audio file. See .runTasks() below to run
// this task.
audit.defineTask('generate-reference', function (done) {
if (!window.testRunner) {
done();
return;
}
// With this setting, the playback rate will be changing continuously and
// repeatedly within the range of [0, 200] around 100Hz, based on the
// input from the oscillator.
createSawtoothWithModulation(context, 'playbackRate', 100, 100);
// |finishAudioTest| will automatically create a reference audio file from
// the OAC rendering if the reference file does not exist.
context.oncomplete = finishAudioTest;
context.startRendering();
testRunner.waitUntilDone();
done();
});
audit.defineTask('finish', function (done) {
finishJSTest();
done();
});
window.onload = function () {
audit.runTasks(
'load-reference',
'generate-verify',
'finish'
);
};
// Use this task to generate a new reference audio file. Make sure to
// comment out .runTasks() above before use this.
// audit.runTasks('generate-reference');
successfullyParsed = true;
</script>
</body>
</html>