| 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 <script src="../resources/audioparam-testing.js"></script> | 8 <script src="../resources/audioparam-testing.js"></script> |
| 8 <title>SetTarget Followed by Linear or Exponential Ramp Is Continuous</title
> | 9 <title>SetTarget Followed by Linear or Exponential Ramp Is Continuous</title
> |
| 9 </head> | 10 </head> |
| 10 | 11 |
| 11 <body> | 12 <body> |
| 12 <script> | 13 <script> |
| 13 description("Test SetTarget Followed by Linear or Exponential Ramp"); | |
| 14 window.jsTestIsAsync = true; | |
| 15 | 14 |
| 16 var sampleRate = 48000; | 15 var sampleRate = 48000; |
| 17 var renderQuantum = 128; | 16 var renderQuantum = 128; |
| 18 // Test doesn't need to run for very long. | 17 // Test doesn't need to run for very long. |
| 19 var renderDuration = 0.1; | 18 var renderDuration = 0.1; |
| 20 // Where the ramp should end | 19 // Where the ramp should end |
| 21 var rampEndTime = renderDuration - .05; | 20 var rampEndTime = renderDuration - .05; |
| 22 var renderFrames = renderDuration * sampleRate; | 21 var renderFrames = renderDuration * sampleRate; |
| 23 var timeConstant = 0.01; | 22 var timeConstant = 0.01; |
| 24 | 23 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 audioparam.exponentialRampToValueAtTime(endValue, endTime); | 76 audioparam.exponentialRampToValueAtTime(endValue, endTime); |
| 78 }, | 77 }, |
| 79 referenceFunction: exponentialResult, | 78 referenceFunction: exponentialResult, |
| 80 automationTime: 4 * renderQuantum / sampleRate, | 79 automationTime: 4 * renderQuantum / sampleRate, |
| 81 thresholdSetTarget: 3.43632e-7, | 80 thresholdSetTarget: 3.43632e-7, |
| 82 thresholdRamp: 4.29154e-6 | 81 thresholdRamp: 4.29154e-6 |
| 83 }).then(done); | 82 }).then(done); |
| 84 }); | 83 }); |
| 85 | 84 |
| 86 audit.defineTask("finish", function (done) { | 85 audit.defineTask("finish", function (done) { |
| 87 finishJSTest(); | |
| 88 done(); | 86 done(); |
| 89 }); | 87 }); |
| 90 | 88 |
| 91 audit.runTasks(); | 89 audit.runTasks(); |
| 92 | 90 |
| 93 function computeExpectedResult(automationTime, timeConstant, endValue, end
Time, rampFunction) { | 91 function computeExpectedResult(automationTime, timeConstant, endValue, end
Time, rampFunction) { |
| 94 // The result is a constant value of 1 for one rendering quantum, then a
SetTarget event | 92 // The result is a constant value of 1 for one rendering quantum, then a
SetTarget event |
| 95 // lasting to |automationTime|, at which point a ramp starts which ends
at |endValue| | 93 // lasting to |automationTime|, at which point a ramp starts which ends
at |endValue| |
| 96 // at |endTime|. Then the rest of curve should be held constant at |end
Value|. | 94 // at |endTime|. Then the rest of curve should be held constant at |end
Value|. |
| 97 var initialPart = new Array(renderQuantum); | 95 var initialPart = new Array(renderQuantum); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 .beCloseToArray(expected.initialPart, 0) && success; | 200 .beCloseToArray(expected.initialPart, 0) && success; |
| 203 | 201 |
| 204 // Verify the SetTarget part of the curve, if the SetTarget did actual
ly run. | 202 // Verify the SetTarget part of the curve, if the SetTarget did actual
ly run. |
| 205 startIndex += length; | 203 startIndex += length; |
| 206 length = expected.setTargetPart.length; | 204 length = expected.setTargetPart.length; |
| 207 if (length) { | 205 if (length) { |
| 208 success = Should(prefix + ": SetTarget part", result.slice(startInde
x, startIndex + | 206 success = Should(prefix + ": SetTarget part", result.slice(startInde
x, startIndex + |
| 209 length)) | 207 length)) |
| 210 .beCloseToArray(expected.setTargetPart, thresholdSetTarget) && suc
cess; | 208 .beCloseToArray(expected.setTargetPart, thresholdSetTarget) && suc
cess; |
| 211 } else { | 209 } else { |
| 212 testPassed("SetTarget part was correctly replaced by the ramp"); | 210 Should("SetTarget part", !length) |
| 211 .summarize("was correctly replaced by the ramp", |
| 212 "was incorrectly replaced by the ramp"); |
| 213 } | 213 } |
| 214 | 214 |
| 215 // Verify the ramp part of the curve | 215 // Verify the ramp part of the curve |
| 216 startIndex += length; | 216 startIndex += length; |
| 217 length = expected.rampPart.length; | 217 length = expected.rampPart.length; |
| 218 success = Should(prefix, result.slice(startIndex, startIndex + length)
) | 218 success = Should(prefix, result.slice(startIndex, startIndex + length)
) |
| 219 .beCloseToArray(expected.rampPart, thresholdRamp) && success; | 219 .beCloseToArray(expected.rampPart, thresholdRamp) && success; |
| 220 | 220 |
| 221 // Verify that the end of the curve after the ramp (if any) is a const
ant. | 221 // Verify that the end of the curve after the ramp (if any) is a const
ant. |
| 222 startIndex += length; | 222 startIndex += length; |
| 223 success = Should(prefix + ": Tail part", result.slice(startIndex)) | 223 success = Should(prefix + ": Tail part", result.slice(startIndex)) |
| 224 .beCloseToArray(expected.tailPart, 0) && success; | 224 .beCloseToArray(expected.tailPart, 0) && success; |
| 225 | 225 |
| 226 if (success) | 226 Should(prefix, success) |
| 227 testPassed(prefix + " preceded by SetTarget is continuous.\n"); | 227 .summarize("preceded by SetTarget is continuous", |
| 228 else | 228 "preceded by SetTarget was not continuous"); |
| 229 testFailed(prefix + " preceded by SetTarget was not continuous.\n"); | |
| 230 }); | 229 }); |
| 231 } | 230 } |
| 232 </script> | 231 </script> |
| 233 </body> | 232 </body> |
| 234 </html> | 233 </html> |
| OLD | NEW |