| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Test Custom Oscillator at Very Low Frequency</title> | 4 <title>Test Custom Oscillator at Very Low Frequency</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 </head> | 8 </head> |
| 9 | 9 |
| 10 <body> | 10 <body> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 for (var k = 0; k < actual.length; ++k) { | 46 for (var k = 0; k < actual.length; ++k) { |
| 47 var x = Math.cos(omega * k); | 47 var x = Math.cos(omega * k); |
| 48 var diff = x - actual[k]; | 48 var diff = x - actual[k]; |
| 49 signal += x * x; | 49 signal += x * x; |
| 50 noise += diff * diff; | 50 noise += diff * diff; |
| 51 } | 51 } |
| 52 | 52 |
| 53 var snr = 10 * Math.log10(signal / noise); | 53 var snr = 10 * Math.log10(signal / noise); |
| 54 | 54 |
| 55 Should("SNR of " + desiredFrequencyHz + " Hz sine wave", snr).beGreaterT
hanOrEqualTo(snrThreshold); | 55 Should("SNR of " + desiredFrequencyHz + " Hz sine wave", snr, { |
| 56 brief: true |
| 57 }).beGreaterThanOrEqualTo(snrThreshold); |
| 56 testPassed("PeriodicWave coefficients that must be ignored were correctl
y ignored."); | 58 testPassed("PeriodicWave coefficients that must be ignored were correctl
y ignored."); |
| 57 } | 59 } |
| 58 | 60 |
| 59 function runTest() { | 61 function runTest() { |
| 60 context = new OfflineAudioContext(1, sampleRate, sampleRate); | 62 context = new OfflineAudioContext(1, sampleRate, sampleRate); |
| 61 osc = context.createOscillator(); | 63 osc = context.createOscillator(); |
| 62 | 64 |
| 63 // Create the custom oscillator. For simplicity of testing, we use just
a cosine wave, but | 65 // Create the custom oscillator. For simplicity of testing, we use just
a cosine wave, but |
| 64 // the initial elements of the real and imaginary parts are explicitly s
et to non-zero to | 66 // the initial elements of the real and imaginary parts are explicitly s
et to non-zero to |
| 65 // test that they are ignored. | 67 // test that they are ignored. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 context.startRendering().then(function (buffer) { | 80 context.startRendering().then(function (buffer) { |
| 79 checkCosineResult(buffer, desiredFrequencyHz, sampleRate); | 81 checkCosineResult(buffer, desiredFrequencyHz, sampleRate); |
| 80 }).then(finishJSTest); | 82 }).then(finishJSTest); |
| 81 }; | 83 }; |
| 82 | 84 |
| 83 runTest(); | 85 runTest(); |
| 84 successfullyParsed = true; | 86 successfullyParsed = true; |
| 85 </script> | 87 </script> |
| 86 </body> | 88 </body> |
| 87 </html> | 89 </html> |
| OLD | NEW |