| 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 <title>Test OscillatorNode with Negative Frequency</title> | 8 <title>Test OscillatorNode with Negative Frequency</title> |
| 8 </head> | 9 </head> |
| 9 | 10 |
| 10 <body> | 11 <body> |
| 11 <script> | 12 <script> |
| 12 description("Test OscillatorNode with Negative Frequency."); | |
| 13 window.jsTestIsAsync = true; | |
| 14 | |
| 15 // Some arbitrary sample rate for the offline context. | 13 // Some arbitrary sample rate for the offline context. |
| 16 var sampleRate = 48000; | 14 var sampleRate = 48000; |
| 17 var renderDuration = 1; | 15 var renderDuration = 1; |
| 18 var renderFrames = renderDuration * sampleRate; | 16 var renderFrames = renderDuration * sampleRate; |
| 19 | 17 |
| 20 var audit = Audit.createTaskRunner(); | 18 var audit = Audit.createTaskRunner(); |
| 21 | 19 |
| 22 audit.defineTask("sine", function (done) { | 20 audit.defineTask("sine", function (done) { |
| 23 runTest({ | 21 runTest({ |
| 24 message: "Sum of positive and negative frequency sine oscillators", | 22 message: "Sum of positive and negative frequency sine oscillators", |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 var actual = buffer.getChannelData(1); | 135 var actual = buffer.getChannelData(1); |
| 138 | 136 |
| 139 Should("Sum of positive and negative frequency custom oscillators", | 137 Should("Sum of positive and negative frequency custom oscillators", |
| 140 actual, { | 138 actual, { |
| 141 precision: 6 | 139 precision: 6 |
| 142 }) | 140 }) |
| 143 .beCloseToArray(expected, 4.7684e-7); | 141 .beCloseToArray(expected, 4.7684e-7); |
| 144 }).then(done); | 142 }).then(done); |
| 145 }); | 143 }); |
| 146 | 144 |
| 147 | |
| 148 // All done! | |
| 149 audit.defineTask("finish", function (done) { | |
| 150 finishJSTest(); | |
| 151 done(); | |
| 152 }); | |
| 153 | |
| 154 audit.runTasks(); | 145 audit.runTasks(); |
| 155 | 146 |
| 156 function runTest(options) { | 147 function runTest(options) { |
| 157 // To test if negative frequencies work, create two oscillators. One | 148 // To test if negative frequencies work, create two oscillators. One |
| 158 // has a positive frequency and the other has a negative frequency. | 149 // has a positive frequency and the other has a negative frequency. |
| 159 // Sum the oscillator outputs; the output should be zero because all of | 150 // Sum the oscillator outputs; the output should be zero because all of |
| 160 // the builtin oscillator types are odd functions of frequency. | 151 // the builtin oscillator types are odd functions of frequency. |
| 161 var context = new OfflineAudioContext(1, renderFrames, sampleRate); | 152 var context = new OfflineAudioContext(1, renderFrames, sampleRate); |
| 162 | 153 |
| 163 var oscPositive = context.createOscillator(); | 154 var oscPositive = context.createOscillator(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 190 var zero = new Float32Array(result.length); | 181 var zero = new Float32Array(result.length); |
| 191 zero.fill(0); | 182 zero.fill(0); |
| 192 Should(options.message, result, { | 183 Should(options.message, result, { |
| 193 verbose: true | 184 verbose: true |
| 194 }).beCloseToArray(zero, options.threshold || 0); | 185 }).beCloseToArray(zero, options.threshold || 0); |
| 195 }); | 186 }); |
| 196 } | 187 } |
| 197 </script> | 188 </script> |
| 198 </body> | 189 </body> |
| 199 </html> | 190 </html> |
| OLD | NEW |