Chromium Code Reviews| 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/compatibility.js"></script> | 6 <script src="../resources/compatibility.js"></script> |
| 6 <script src="../resources/audit-util.js"></script> | 7 <script src="../resources/audit-util.js"></script> |
| 7 <script src="../resources/audio-testing.js"></script> | 8 <script src="../resources/audio-testing.js"></script> |
| 8 <script src="../resources/realtimeanalyser-testing.js"></script> | 9 <script src="../resources/realtimeanalyser-testing.js"></script> |
| 9 <script src="../resources/fft.js"></script> | 10 <script src="../resources/fft.js"></script> |
| 10 <title>Test Analyser getFloatFrequencyData and getByteFrequencyData, No Smoo thing</title> | 11 <title>Test Analyser getFloatFrequencyData and getByteFrequencyData, No Smoo thing</title> |
| 11 </head> | 12 </head> |
| 12 | 13 |
| 13 <body> | 14 <body> |
| 14 <script> | 15 <script> |
| 15 description("Test AnalyserNode getFloatFrequencyData and getByteFrequencyD ata, no Smoothing"); | |
| 16 window.jsTestIsAsync = true; | 16 window.jsTestIsAsync = true; |
|
hongchan
2016/12/20 23:04:31
ditto.
| |
| 17 | 17 |
| 18 // Use a power of two to eliminate any round-off in the computation of the times for | 18 // Use a power of two to eliminate any round-off in the computation of the times for |
| 19 // context.suspend(). | 19 // context.suspend(). |
| 20 var sampleRate = 32768; | 20 var sampleRate = 32768; |
| 21 | 21 |
| 22 // The largest FFT size for the analyser node is 32768. We want to render longer than this so | 22 // The largest FFT size for the analyser node is 32768. We want to render longer than this so |
| 23 // that we have at least one complete buffer of data of 32768 samples. | 23 // that we have at least one complete buffer of data of 32768 samples. |
| 24 var renderFrames = 2 * 32768; | 24 var renderFrames = 2 * 32768; |
| 25 var renderDuration = renderFrames / sampleRate; | 25 var renderDuration = renderFrames / sampleRate; |
| 26 | 26 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 var name = testConfig[k].order + "-order FFT"; | 75 var name = testConfig[k].order + "-order FFT"; |
| 76 (function (config) { | 76 (function (config) { |
| 77 audit.defineTask(name, function (done) { | 77 audit.defineTask(name, function (done) { |
| 78 basicFFTTest(config).then(done); | 78 basicFFTTest(config).then(done); |
| 79 }); | 79 }); |
| 80 })(testConfig[k]); | 80 })(testConfig[k]); |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Just print a summary of the result of the above tests. | 83 // Just print a summary of the result of the above tests. |
| 84 audit.defineTask("summarize basic tests", function (done) { | 84 audit.defineTask("summarize basic tests", function (done) { |
| 85 if (basicTestsPassed) | 85 Should("Basic frequency data computed", basicTestsPassed) |
| 86 testPassed("Basic frequency data computed correctly.\n"); | 86 .summarize("correctly", "incorrectly"); |
| 87 else | |
| 88 testFailed("Basic frequency data computed incorrectly.\n"); | |
| 89 done(); | 87 done(); |
| 90 }); | 88 }); |
| 91 | 89 |
| 92 // Test that smoothing isn't done and we have the expected data, calling g etFloatFrequencyData | 90 // Test that smoothing isn't done and we have the expected data, calling g etFloatFrequencyData |
| 93 // twice at different times. | 91 // twice at different times. |
| 94 audit.defineTask("no smoothing", function (done) { | 92 audit.defineTask("no smoothing", function (done) { |
| 95 // Use 128-point FFT for the test. The actual order doesn't matter (but the error threshold | 93 // Use 128-point FFT for the test. The actual order doesn't matter (but the error threshold |
| 96 // depends on the order). | 94 // depends on the order). |
| 97 var options = { | 95 var options = { |
| 98 order: 7, | 96 order: 7, |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 125 | 123 |
| 126 // Grab the time domain and frequency domain data | 124 // Grab the time domain and frequency domain data |
| 127 analyser.getFloatTimeDomainData(timeData); | 125 analyser.getFloatTimeDomainData(timeData); |
| 128 analyser.getFloatFrequencyData(freqData); | 126 analyser.getFloatFrequencyData(freqData); |
| 129 | 127 |
| 130 var expected = computeFFTMagnitude(timeData, options.order).map(linear ToDb); | 128 var expected = computeFFTMagnitude(timeData, options.order).map(linear ToDb); |
| 131 var comparison = compareFloatFreq(Math.pow(2, options.order) + "-point float FFT", | 129 var comparison = compareFloatFreq(Math.pow(2, options.order) + "-point float FFT", |
| 132 freqData, expected, options); | 130 freqData, expected, options); |
| 133 basicTestsPassed = basicTestsPassed && comparison.success; | 131 basicTestsPassed = basicTestsPassed && comparison.success; |
| 134 | 132 |
| 135 if (comparison.success) | 133 Should("Smoothing constant of 0", comparison.success) |
| 136 testPassed("Smoothing constant of 0 correctly handled.\n"); | 134 .summarize("correctly handled", "incorrectly handled"); |
| 137 else | |
| 138 testFailed("Smoothing constant of 0 incorrectly handled.\n"); | |
| 139 }).then(context.resume.bind(context)); | 135 }).then(context.resume.bind(context)); |
| 140 | 136 |
| 141 context.startRendering().then(done); | 137 context.startRendering().then(done); |
| 142 }); | 138 }); |
| 143 | 139 |
| 144 audit.defineTask("finish", function (done) { | 140 audit.defineTask("finish", function (done) { |
| 145 finishJSTest(); | |
| 146 done(); | 141 done(); |
| 147 }); | 142 }); |
| 148 | 143 |
| 149 audit.runTasks(); | 144 audit.runTasks(); |
| 150 | 145 |
| 151 // Run a simple test of the AnalyserNode's frequency domain data. Both th e float and byte | 146 // Run a simple test of the AnalyserNode's frequency domain data. Both th e float and byte |
| 152 // frequency data are tested. The byte tests depend on the float tests be ing correct. | 147 // frequency data are tested. The byte tests depend on the float tests be ing correct. |
| 153 // | 148 // |
| 154 // The parameters of the test are given by |options| which is a property b ag consisting of the | 149 // The parameters of the test are given by |options| which is a property b ag consisting of the |
| 155 // following: | 150 // following: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 basicTestsPassed = Should(analyser.fftSize + "-point byte FFT", byteFr eqData) | 201 basicTestsPassed = Should(analyser.fftSize + "-point byte FFT", byteFr eqData) |
| 207 .beCloseToArray(expectedByteData, 0) && basicTestsPassed; | 202 .beCloseToArray(expectedByteData, 0) && basicTestsPassed; |
| 208 | 203 |
| 209 }).then(context.resume.bind(context)); | 204 }).then(context.resume.bind(context)); |
| 210 | 205 |
| 211 return context.startRendering(); | 206 return context.startRendering(); |
| 212 } | 207 } |
| 213 </script> | 208 </script> |
| 214 </body> | 209 </body> |
| 215 </html> | 210 </html> |
| OLD | NEW |