Index: third_party/WebKit/LayoutTests/webaudio/audioparam-automation-clamping.html |
diff --git a/third_party/WebKit/LayoutTests/webaudio/audioparam-automation-clamping.html b/third_party/WebKit/LayoutTests/webaudio/audioparam-automation-clamping.html |
deleted file mode 100644 |
index e994fb2dcc3e2001c4a149a9632aed991a370578..0000000000000000000000000000000000000000 |
--- a/third_party/WebKit/LayoutTests/webaudio/audioparam-automation-clamping.html |
+++ /dev/null |
@@ -1,133 +0,0 @@ |
-<!doctype html> |
-<html> |
- <head> |
- <script src="../resources/js-test.js"></script> |
- <script src="resources/compatibility.js"></script> |
- <script src="resources/audit-util.js"></script> |
- <script src="resources/audio-testing.js"></script> |
- <title>Test Clamping of Automations</title> |
- </head> |
- |
- <body> |
- <script> |
- description("Test Clamping of Automations."); |
- window.jsTestIsAsync = true; |
- |
- // Some arbitrary sample rate for the offline context. |
- var sampleRate = 48000; |
- |
- // Duration of test (fairly arbitrary). |
- var renderDuration = 1; |
- var renderFrames = renderDuration * sampleRate; |
- |
- var audit = Audit.createTaskRunner(); |
- |
- audit.defineTask("clamp", function (done) { |
- // Test clamping of automations. Most AudioParam limits are essentially |
- // unbounded, so clamping doesn't happen. For most other AudioParams, |
- // the behavior is sufficiently complicated with complicated outputs |
- // that testing them is hard. However the output behavior of the |
- // frequency parameter for a BiquadFilter is relatively simple. Use |
- // that as the test. |
- var context = new OfflineAudioContext(1, renderFrames, sampleRate); |
- |
- var source = context.createBufferSource(); |
- source.buffer = createConstantBuffer(context, 1, 1); |
- source.loop = true; |
- |
- var filter = context.createBiquadFilter(); |
- filter.type = "lowpass"; |
- |
- source.connect(filter); |
- filter.connect(context.destination); |
- |
- var V0 = 880; |
- var T0 = 0; |
- filter.frequency.setValueAtTime(V0, T0); |
- |
- var V1 = -1000; |
- var T1 = renderDuration / 4; |
- filter.frequency.linearRampToValueAtTime(V1, T1); |
- |
- var V2 = 880; |
- var T2 = renderDuration / 2; |
- filter.frequency.linearRampToValueAtTime(V2, T2); |
- |
- source.start(); |
- |
- context.startRendering().then(function (buffer) { |
- var result = buffer.getChannelData(0); |
- var success = true; |
- |
- // When the cutoff frequency of a lowpass filter is 0, nothing gets |
- // through. Hence the output of the filter between the clamping |
- // period should be exactly zero. This tests passes if the output is 0 |
- // during the expected range. |
- // |
- // Compute when the frequency value of the biquad goes to 0. In |
- // general, t = (T0*V1 -T1*V0)/(V1-V0) (using the notation from the |
- // spec.) |
- var clampStartTime = solveLinearRamp(0, V0, T0, V1, T1); |
- var clampEndTime = solveLinearRamp(0, V1, T1, V2, T2); |
- |
- var clampStartFrame = Math.ceil(clampStartTime * sampleRate); |
- var clampEndFrame = Math.floor(clampEndTime * sampleRate); |
- |
- var clampedSignal = result.slice(clampStartFrame, clampEndFrame + 1); |
- var expectedSignal = new Float32Array(clampedSignal.length); |
- expectedSignal.fill(0); |
- |
- // Output should be zero. |
- success = Should("Clamped signal in frame range [" + clampStartFrame + ", " + |
- clampEndFrame + "]", |
- clampedSignal, { |
- verbose: true, |
- }).beCloseToArray(expectedSignal, 0); |
- |
- // Find the actual clamp range based on the output values. |
- var actualClampStart = result.findIndex(x => x === 0); |
- var actualClampEnd = actualClampStart + result.slice(actualClampStart).findIndex( |
- x => x != 0); |
- |
- // Verify that the expected clamping range is a subset of the actual range. |
- success = Should("Actual Clamp start", |
- actualClampStart).beLessThanOrEqualTo(clampStartFrame) && success; |
- success == Should("Actual Clamp end", |
- actualClampEnd).beGreaterThanOrEqualTo(clampEndFrame) && success; |
- |
- if (success) |
- testPassed("Clamping of BiquadFilter.frequency automation performed correctly.") |
- else |
- testFailed( |
- "Clamping of BiquadFilter.frequency automation performed incorrectly.") |
- |
- }).then(done); |
- }); |
- |
- // All done! |
- audit.defineTask("finish", function (done) { |
- finishJSTest(); |
- done(); |
- }); |
- |
- audit.runTasks(); |
- |
- function solveLinearRamp(v, v0, t0, v1, t1) { |
- // Solve the linear ramp equation for the time t at which the ramp |
- // reaches the value v. The linear ramp equation (from the spec) is |
- // |
- // v(t) = v0 + (v1 - v0) * (t - t0)/(t1 - t0) |
- // |
- // Find t such that |
- // |
- // v = v0 + (v1 - v0) * (t - t0)/(t1 - t0) |
- // |
- // Then |
- // |
- // t = (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0) |
- // |
- return (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0); |
- } |
- </script> |
- </body> |
-</html> |