| Index: third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
|
| diff --git a/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js b/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
|
| index 923bb7dd5cc99b7d481b30abe27d4bcac4672990..b8b866fb85ce9d41c7dea99edba64ac38a987782 100644
|
| --- a/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
|
| +++ b/third_party/WebKit/LayoutTests/webaudio/resources/waveshaper-testing.js
|
| @@ -51,9 +51,7 @@ function generateWaveShapingCurve() {
|
| return curve;
|
| }
|
|
|
| -function checkShapedCurve(event) {
|
| - var buffer = event.renderedBuffer;
|
| -
|
| +function checkShapedCurve(buffer, should) {
|
| var outputData = buffer.getChannelData(0);
|
| var n = buffer.length;
|
|
|
| @@ -114,15 +112,9 @@ function checkShapedCurve(event) {
|
|
|
| // console.log("worstDeltaInDecibels: " + worstDeltaInDecibels);
|
|
|
| - var success = worstDeltaInDecibels < acceptableAliasingThresholdDecibels;
|
| -
|
| - if (success) {
|
| - testPassed(oversample + " WaveShaperNode oversampling within acceptable tolerance.");
|
| - } else {
|
| - testFailed(oversample + " WaveShaperNode oversampling not within acceptable tolerance. Error = " + worstDeltaInDecibels + " dBFS");
|
| - }
|
| -
|
| - finishJSTest();
|
| + should(worstDeltaInDecibels, oversample +
|
| + " WaveshaperNode oversampling error (in dBFS)")
|
| + .beLessThan(acceptableAliasingThresholdDecibels);
|
| }
|
|
|
| function createImpulseBuffer(context, sampleFrameLength) {
|
| @@ -145,31 +137,33 @@ function runWaveShaperOversamplingTest(testParams) {
|
| fundamentalFrequency = testParams.fundamentalFrequency;
|
| acceptableAliasingThresholdDecibels = testParams.acceptableAliasingThresholdDecibels;
|
|
|
| - if (window.testRunner) {
|
| - testRunner.dumpAsText();
|
| - testRunner.waitUntilDone();
|
| - }
|
| + let audit = Audit.createTaskRunner();
|
| +
|
| + audit.define("test", function (task, should) {
|
| + task.describe(testParams.description);
|
|
|
| - window.jsTestIsAsync = true;
|
| + // Create offline audio context.
|
| + var numberOfRenderFrames = sampleRate * lengthInSeconds;
|
| + context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate);
|
|
|
| - // Create offline audio context.
|
| - var numberOfRenderFrames = sampleRate * lengthInSeconds;
|
| - context = new OfflineAudioContext(1, numberOfRenderFrames, sampleRate);
|
| + // source -> waveshaper -> destination
|
| + var source = context.createBufferSource();
|
| + source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeconds, 1);
|
|
|
| - // source -> waveshaper -> destination
|
| - var source = context.createBufferSource();
|
| - source.buffer = createToneBuffer(context, fundamentalFrequency, lengthInSeconds, 1);
|
| + // Apply a non-linear distortion curve.
|
| + waveshaper = context.createWaveShaper();
|
| + waveshaper.curve = generateWaveShapingCurve();
|
| + waveshaper.oversample = oversample;
|
|
|
| - // Apply a non-linear distortion curve.
|
| - waveshaper = context.createWaveShaper();
|
| - waveshaper.curve = generateWaveShapingCurve();
|
| - waveshaper.oversample = oversample;
|
| + source.connect(waveshaper);
|
| + waveshaper.connect(context.destination);
|
|
|
| - source.connect(waveshaper);
|
| - waveshaper.connect(context.destination);
|
| + source.start(0);
|
|
|
| - source.start(0);
|
| + context.startRendering()
|
| + .then(buffer => checkShapedCurve(buffer, should))
|
| + .then(() => task.done());
|
| + });
|
|
|
| - context.oncomplete = checkShapedCurve;
|
| - context.startRendering();
|
| + audit.run();
|
| }
|
|
|