Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/webaudio/resources/oscillator-testing.js |
| diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/oscillator-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/oscillator-testing.js |
| index 6da5a74d85317668b1b3a079da170a01bda9b422..05bf2830bf9b4a4c7cd80ae73632ba6d3743d5e9 100644 |
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/oscillator-testing.js |
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/oscillator-testing.js |
| @@ -85,13 +85,11 @@ function generateExponentialOscillatorSweep(context, oscillatorType) { |
| function calculateSNR(sPower, nPower) |
| { |
| - if (nPower == 0 && sPower > 0) { |
| - return 1000; |
| - } |
| return 10 * Math.log10(sPower / nPower); |
| } |
| function loadReferenceAndRunTest(context, oscType, task, should) { |
| + /* |
| var bufferLoader = new BufferLoader( |
| context, |
| [ "../Oscillator/oscillator-" + oscType + "-expected.wav" ], |
| @@ -106,10 +104,24 @@ function loadReferenceAndRunTest(context, oscType, task, should) { |
| }); |
| bufferLoader.load(); |
| + */ |
|
hongchan
2017/03/09 18:00:13
Remove the commented-out section.
Raymond Toy
2017/03/09 18:09:49
Done.
|
| + Audit.loadFileFromUrl("../Oscillator/oscillator-" + oscType + "-expected.wav") |
|
hongchan
2017/03/09 18:00:13
Wrap this line.
Raymond Toy
2017/03/09 18:09:49
Done.
|
| + .then(response => { |
| + return context.decodeAudioData(response); |
| + }) |
| + .then(audioBuffer => { |
| + reference = audioBuffer.getChannelData(0); |
| + generateExponentialOscillatorSweep(context, oscType); |
| + return context.startRendering(); |
| + }) |
| + .then(resultBuffer => { |
| + checkResult(resultBuffer, should, oscType); |
| + }) |
| + .then(() => task.done()); |
| } |
| -function checkResult (event, should, oscType) { |
| - let renderedData = event.renderedBuffer.getChannelData(0); |
| +function checkResult (renderedBuffer, should, oscType) { |
| + let renderedData = renderedBuffer.getChannelData(0); |
| // Compute signal to noise ratio between the result and the reference. Also keep track |
| // of the max difference (and position). |
| @@ -127,7 +139,7 @@ function checkResult (event, should, oscType) { |
| } |
| // The reference file is a 16-bit WAV file, so we will almost never get an exact match |
| // between it and the actual floating-point result. |
| - if (diff > 1/waveScaleFactor) { |
| + if (diff > 0) { |
| diffCount++; |
| } |
| } |
| @@ -135,8 +147,8 @@ function checkResult (event, should, oscType) { |
| var snr = calculateSNR(signalPower, noisePower); |
| should(snr, "SNR") |
| .beGreaterThanOrEqualTo(thresholdSNR); |
| - should(maxError * waveScaleFactor, "Maximum difference in ulp (16-bits)") |
| - .beLessThanOrEqualTo(thresholdDiff * waveScaleFactor); |
| + should(maxError, "Maximum difference") |
| + .beLessThanOrEqualTo(thresholdDiff); |
| should(diffCount, |
| "Number of differences between actual and expected result out of " |
| @@ -144,13 +156,13 @@ function checkResult (event, should, oscType) { |
| .beLessThanOrEqualTo(thresholdDiffCount); |
| var filename = "oscillator-" + oscType + "-actual.wav"; |
| - if (downloadAudioBuffer(event.renderedBuffer, filename)) |
| + if (downloadAudioBuffer(renderedBuffer, filename, true)) |
| should(true, "Saved reference file").message(filename, ""); |
| } |
| function setThresholds(thresholds) { |
| thresholdSNR = thresholds.snr; |
| - thresholdDiff = thresholds.maxDiff / waveScaleFactor; |
| + thresholdDiff = thresholds.maxDiff; |
| thresholdDiffCount = thresholds.diffCount; |
| } |
| @@ -158,19 +170,6 @@ function runTest(context, oscType, description, task, should) { |
| loadReferenceAndRunTest(context, oscType, task, should); |
| } |
| -function createNewReference(oscType) { |
| - if (!window.testRunner) |
| - return; |
| - |
| - context = new OfflineAudioContext(1, sampleRate * lengthInSeconds, sampleRate); |
| - generateExponentialOscillatorSweep(context, oscType); |
| - |
| - context.oncomplete = finishAudioTest; |
| - context.startRendering(); |
| - |
| - testRunner.waitUntilDone(); |
| -} |
| - |
| return { |
| sampleRate: sampleRate, |
| lengthInSeconds: lengthInSeconds, |
| @@ -180,7 +179,6 @@ return { |
| waveScaleFactor: waveScaleFactor, |
| setThresholds: setThresholds, |
| runTest: runTest, |
| - createNewReference: createNewReference, |
| }; |
| }()); |