| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../resources/js-test.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="../resources/audit-util.js"></script> | 6 <script src="../resources/audit-util.js"></script> |
| 6 <script src="../resources/audio-testing.js"></script> | 7 <script src="../resources/audio-testing.js"></script> |
| 7 <title>Test Clamping of Automations</title> | 8 <title>Test Clamping of Automations</title> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <script> | 12 <script> |
| 12 description("Test Clamping of Automations."); | |
| 13 window.jsTestIsAsync = true; | |
| 14 | 13 |
| 15 // Some arbitrary sample rate for the offline context. | 14 // Some arbitrary sample rate for the offline context. |
| 16 var sampleRate = 48000; | 15 var sampleRate = 48000; |
| 17 | 16 |
| 18 // Duration of test (fairly arbitrary). | 17 // Duration of test (fairly arbitrary). |
| 19 var renderDuration = 1; | 18 var renderDuration = 1; |
| 20 var renderFrames = renderDuration * sampleRate; | 19 var renderFrames = renderDuration * sampleRate; |
| 21 | 20 |
| 22 var audit = Audit.createTaskRunner(); | 21 var audit = Audit.createTaskRunner(); |
| 23 | 22 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 var actualClampStart = result.findIndex(x => x === 0); | 86 var actualClampStart = result.findIndex(x => x === 0); |
| 88 var actualClampEnd = actualClampStart + result.slice(actualClampStart)
.findIndex( | 87 var actualClampEnd = actualClampStart + result.slice(actualClampStart)
.findIndex( |
| 89 x => x != 0); | 88 x => x != 0); |
| 90 | 89 |
| 91 // Verify that the expected clamping range is a subset of the actual r
ange. | 90 // Verify that the expected clamping range is a subset of the actual r
ange. |
| 92 success = Should("Actual Clamp start", | 91 success = Should("Actual Clamp start", |
| 93 actualClampStart).beLessThanOrEqualTo(clampStartFrame) && success; | 92 actualClampStart).beLessThanOrEqualTo(clampStartFrame) && success; |
| 94 success == Should("Actual Clamp end", | 93 success == Should("Actual Clamp end", |
| 95 actualClampEnd).beGreaterThanOrEqualTo(clampEndFrame) && success; | 94 actualClampEnd).beGreaterThanOrEqualTo(clampEndFrame) && success; |
| 96 | 95 |
| 97 if (success) | 96 Should("Clamping of BiquadFilter.frequency automation performed", |
| 98 testPassed("Clamping of BiquadFilter.frequency automation performed
correctly.") | 97 success) |
| 99 else | 98 .summarize("correctly", "incorrectly"); |
| 100 testFailed( | |
| 101 "Clamping of BiquadFilter.frequency automation performed incorrect
ly.") | |
| 102 | |
| 103 }).then(done); | 99 }).then(done); |
| 104 }); | 100 }); |
| 105 | 101 |
| 106 // All done! | 102 // All done! |
| 107 audit.defineTask("finish", function (done) { | 103 audit.defineTask("finish", function (done) { |
| 108 finishJSTest(); | |
| 109 done(); | 104 done(); |
| 110 }); | 105 }); |
| 111 | 106 |
| 112 audit.runTasks(); | 107 audit.runTasks(); |
| 113 | 108 |
| 114 function solveLinearRamp(v, v0, t0, v1, t1) { | 109 function solveLinearRamp(v, v0, t0, v1, t1) { |
| 115 // Solve the linear ramp equation for the time t at which the ramp | 110 // Solve the linear ramp equation for the time t at which the ramp |
| 116 // reaches the value v. The linear ramp equation (from the spec) is | 111 // reaches the value v. The linear ramp equation (from the spec) is |
| 117 // | 112 // |
| 118 // v(t) = v0 + (v1 - v0) * (t - t0)/(t1 - t0) | 113 // v(t) = v0 + (v1 - v0) * (t - t0)/(t1 - t0) |
| 119 // | 114 // |
| 120 // Find t such that | 115 // Find t such that |
| 121 // | 116 // |
| 122 // v = v0 + (v1 - v0) * (t - t0)/(t1 - t0) | 117 // v = v0 + (v1 - v0) * (t - t0)/(t1 - t0) |
| 123 // | 118 // |
| 124 // Then | 119 // Then |
| 125 // | 120 // |
| 126 // t = (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0) | 121 // t = (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0) |
| 127 // | 122 // |
| 128 return (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0); | 123 return (t0 * v1 - t1 * v0 + (t1 - t0) * v) / (v1 - v0); |
| 129 } | 124 } |
| 130 </script> | 125 </script> |
| 131 </body> | 126 </body> |
| 132 </html> | 127 </html> |
| OLD | NEW |