| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test Interpolation for AudioParam.setValueCurveAtTime</title> | 4 <title>Test Interpolation for AudioParam.setValueCurveAtTime</title> |
| 5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
| 6 <script src="resources/compatibility.js"></script> | 6 <script src="resources/compatibility.js"></script> |
| 7 <script src="resources/audio-testing.js"></script> | 7 <script src="resources/audio-testing.js"></script> |
| 8 <title>Test Interpolation for AudioParam.setValueCurveAtTime</title> | 8 <title>Test Interpolation for AudioParam.setValueCurveAtTime</title> |
| 9 </head> | 9 </head> |
| 10 | 10 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 gain.gain.value = 0; | 202 gain.gain.value = 0; |
| 203 gain.gain.setValueCurveAtTime(curve, config.curveStartTime, config.curve
Duration); | 203 gain.gain.setValueCurveAtTime(curve, config.curveStartTime, config.curve
Duration); |
| 204 // This is to verify that setValueCurveAtTime ends appropriately. | 204 // This is to verify that setValueCurveAtTime ends appropriately. |
| 205 gain.gain.setValueAtTime(1, config.fullGainTime); | 205 gain.gain.setValueAtTime(1, config.fullGainTime); |
| 206 | 206 |
| 207 source.connect(gain); | 207 source.connect(gain); |
| 208 gain.connect(context.destination); | 208 gain.connect(context.destination); |
| 209 source.start(); | 209 source.start(); |
| 210 | 210 |
| 211 // Some consistency checks on the test parameters | 211 // Some consistency checks on the test parameters |
| 212 Should("Check: Curve end time", config.curveStartTime + config.curveDura
tion) | 212 Should("Check: Curve end time", config.curveStartTime + config.curveDura
tion, { |
| 213 brief: true |
| 214 }) |
| 213 .beLessThanOrEqualTo(testDurationSec); | 215 .beLessThanOrEqualTo(testDurationSec); |
| 214 Should("Check: Full gain start time", config.fullGainTime).beLessThanOrE
qualTo(testDurationSec); | 216 Should("Check: Full gain start time", config.fullGainTime, { |
| 215 Should("Check: Full gain start time", config.fullGainTime).beGreaterThan
OrEqualTo(config.curveStartTime + config.curveDuration); | 217 brief: true |
| 218 }).beLessThanOrEqualTo(testDurationSec); |
| 219 Should("Check: Full gain start time", config.fullGainTime, { |
| 220 brief: true |
| 221 }).beGreaterThanOrEqualTo(config.curveStartTime + config.curveDuration); |
| 216 | 222 |
| 217 // Rock and roll! | 223 // Rock and roll! |
| 218 return context.startRendering().then(checkResult(config)); | 224 return context.startRendering().then(checkResult(config)); |
| 219 } | 225 } |
| 220 | 226 |
| 221 // Return a function to check that the rendered result matches the expecte
d result. | 227 // Return a function to check that the rendered result matches the expecte
d result. |
| 222 function checkResult(config) { | 228 function checkResult(config) { |
| 223 return function (renderedBuffer) { | 229 return function (renderedBuffer) { |
| 224 var success = true; | 230 var success = true; |
| 225 | 231 |
| 226 actualResult = renderedBuffer.getChannelData(0); | 232 actualResult = renderedBuffer.getChannelData(0); |
| 227 expectedResult = computeExpectedResult(config); | 233 expectedResult = computeExpectedResult(config); |
| 228 | 234 |
| 229 // Compute the SNR and max absolute difference between the actual and
expected result. | 235 // Compute the SNR and max absolute difference between the actual and
expected result. |
| 230 var SNR = 10*Math.log10(computeSNR(actualResult, expectedResult)); | 236 var SNR = 10*Math.log10(computeSNR(actualResult, expectedResult)); |
| 231 var maxDiff = -1; | 237 var maxDiff = -1; |
| 232 var posn = -1; | 238 var posn = -1; |
| 233 | 239 |
| 234 for (var k = 0; k < actualResult.length; ++k) { | 240 for (var k = 0; k < actualResult.length; ++k) { |
| 235 var diff = Math.abs(actualResult[k] - expectedResult[k]); | 241 var diff = Math.abs(actualResult[k] - expectedResult[k]); |
| 236 if (maxDiff < diff) { | 242 if (maxDiff < diff) { |
| 237 maxDiff = diff; | 243 maxDiff = diff; |
| 238 posn = k; | 244 posn = k; |
| 239 } | 245 } |
| 240 } | 246 } |
| 241 | 247 |
| 242 success = success && Should("SNR", SNR).beGreaterThanOrEqualTo(config.
snrThreshold); | 248 success = success && Should("SNR", SNR, { |
| 249 brief: true |
| 250 }).beGreaterThanOrEqualTo(config.snrThreshold); |
| 243 | 251 |
| 244 if (maxDiff <= config.maxErrorThreshold) { | 252 if (maxDiff <= config.maxErrorThreshold) { |
| 245 testPassed("Max difference is less than or equal to " + config.maxEr
rorThreshold + "."); | 253 testPassed("Max difference is less than or equal to " + config.maxEr
rorThreshold + "."); |
| 246 } else { | 254 } else { |
| 247 testFailed("Max difference (" + maxDiff + ") NOT less than or equal
to " + | 255 testFailed("Max difference (" + maxDiff + ") NOT less than or equal
to " + |
| 248 config.maxErrorThreshold + " at frame " + posn + "."); | 256 config.maxErrorThreshold + " at frame " + posn + "."); |
| 249 success = false; | 257 success = false; |
| 250 } | 258 } |
| 251 | 259 |
| 252 var message = "Test: curve length = " + config.curveLength + "; durati
on frames = " + | 260 var message = "Test: curve length = " + config.curveLength + "; durati
on frames = " + |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 301 |
| 294 return expected; | 302 return expected; |
| 295 } | 303 } |
| 296 | 304 |
| 297 audit.runTasks(); | 305 audit.runTasks(); |
| 298 | 306 |
| 299 successfullyParsed = true; | 307 successfullyParsed = true; |
| 300 </script> | 308 </script> |
| 301 </body> | 309 </body> |
| 302 </html> | 310 </html> |
| OLD | NEW |