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