| 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/js-test.js"></script> |
| 5 <script src="resources/compatibility.js"></script> | 5 <script src="resources/compatibility.js"></script> |
| 6 <script src="resources/audio-testing.js"></script> | 6 <script src="resources/audio-testing.js"></script> |
| 7 <title>Test Analyser.getByteTimeDomainData()</title> | 7 <title>Test Analyser.getByteTimeDomainData()</title> |
| 8 </head> | 8 </head> |
| 9 | 9 |
| 10 <body> | 10 <body> |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 var value = Math.fround(128 * Math.fround(1 + floatData[k])); | 64 var value = Math.fround(128 * Math.fround(1 + floatData[k])); |
| 65 // Clip the result to lie in the range [0, 255]. | 65 // Clip the result to lie in the range [0, 255]. |
| 66 expected[k] = Math.floor(Math.min(255, Math.max(0, value))); | 66 expected[k] = Math.floor(Math.min(255, Math.max(0, value))); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Find the first index of the first sample that exceeds +1 or -1. Th
e test MUST have at | 69 // Find the first index of the first sample that exceeds +1 or -1. Th
e test MUST have at |
| 70 // least one such value. | 70 // least one such value. |
| 71 var indexMax = floatData.findIndex(function (x) { return x > 1; }); | 71 var indexMax = floatData.findIndex(function (x) { return x > 1; }); |
| 72 var indexMin = floatData.findIndex(function (x) { return x < -1; }); | 72 var indexMin = floatData.findIndex(function (x) { return x < -1; }); |
| 73 | 73 |
| 74 Should("Index of first sample greater than +1", indexMax).beGreaterTha
nOrEqualTo(0); | 74 Should("Index of first sample greater than +1", indexMax, { |
| 75 Should("Index of first sample less than -1", indexMin).beGreaterThanOr
EqualTo(0); | 75 brief: true |
| 76 }).beGreaterThanOrEqualTo(0); |
| 77 Should("Index of first sample less than -1", indexMin, { |
| 78 brief: true |
| 79 }).beGreaterThanOrEqualTo(0); |
| 76 | 80 |
| 77 // Verify explicitly that clipping happened correctly at the above ind
ices. | 81 // Verify explicitly that clipping happened correctly at the above ind
ices. |
| 78 Should("Clip " + floatData[indexMax].toPrecision(6) + ": byteData[" +
indexMax + "]", | 82 Should("Clip " + floatData[indexMax].toPrecision(6) + ": byteData[" +
indexMax + "]", |
| 79 byteData[indexMax]).beEqualTo(255); | 83 byteData[indexMax]).beEqualTo(255); |
| 80 Should("Clip " + floatData[indexMin].toPrecision(6) + ": byteData[" +
indexMin + "]", | 84 Should("Clip " + floatData[indexMin].toPrecision(6) + ": byteData[" +
indexMin + "]", |
| 81 byteData[indexMin]).beEqualTo(0); | 85 byteData[indexMin]).beEqualTo(0); |
| 82 | 86 |
| 83 // Verify that all other samples are computed correctly. | 87 // Verify that all other samples are computed correctly. |
| 84 Should("Byte data", byteData, { | 88 Should("Byte data", byteData).beEqualToArray(expected); |
| 85 verbose: true | |
| 86 }).beEqualToArray(expected); | |
| 87 }).then(context.resume.bind(context)) | 89 }).then(context.resume.bind(context)) |
| 88 | 90 |
| 89 src.start(); | 91 src.start(); |
| 90 context.startRendering().then(done); | 92 context.startRendering().then(done); |
| 91 }); | 93 }); |
| 92 | 94 |
| 93 audit.defineTask("finish", function (done) { | 95 audit.defineTask("finish", function (done) { |
| 94 finishJSTest(); | 96 finishJSTest(); |
| 95 done(); | 97 done(); |
| 96 }); | 98 }); |
| 97 | 99 |
| 98 audit.runTasks(); | 100 audit.runTasks(); |
| 99 </script> | 101 </script> |
| 100 </body> | 102 </body> |
| 101 </html> | 103 </html> |
| OLD | NEW |