| OLD | NEW |
| 1 // Notes about generated waveforms: | 1 // Notes about generated waveforms: |
| 2 // | 2 // |
| 3 // QUESTION: Why does the wave shape not look like the exact shape (sharp edges)
? | 3 // QUESTION: Why does the wave shape not look like the exact shape (sharp edges)
? |
| 4 // ANSWER: Because a shape with sharp edges has infinitely high frequency conten
t. | 4 // ANSWER: Because a shape with sharp edges has infinitely high frequency conten
t. |
| 5 // Since a digital audio signal must be band-limited based on the nyquist freque
ncy (half the sample-rate) | 5 // Since a digital audio signal must be band-limited based on the nyquist freque
ncy (half the sample-rate) |
| 6 // in order to avoid aliasing, this creates more rounded edges and "ringing" in
the | 6 // in order to avoid aliasing, this creates more rounded edges and "ringing" in
the |
| 7 // appearance of the waveform. See Nyquist-Shannon sampling theorem: | 7 // appearance of the waveform. See Nyquist-Shannon sampling theorem: |
| 8 // http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem | 8 // http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem |
| 9 // | 9 // |
| 10 // QUESTION: Why does the very end of the generated signal appear to get slightl
y weaker? | 10 // QUESTION: Why does the very end of the generated signal appear to get slightl
y weaker? |
| 11 // ANSWER: This is an artifact of the algorithm to avoid aliasing. | 11 // ANSWER: This is an artifact of the algorithm to avoid aliasing. |
| 12 // | 12 // |
| 13 // QUESTION: Since the tests compare the actual result with an expected referenc
e file, how are the | 13 // QUESTION: Since the tests compare the actual result with an expected referenc
e file, how are the |
| 14 // reference files created? | 14 // reference files created? |
| 15 // ANSWER: Create an html with the following contents in the webaudio directory.
Then run a layout | 15 // ANSWER: Create an html with the following contents in the webaudio directory.
Then run a layout |
| 16 // test on this file. A new file names "<file>-actual.wav" is created that cont
ains the new result | 16 // test on this file. A new file names "<file>-actual.wav" is created that cont
ains the new result |
| 17 // that can be used as the new expected reference file. Replace the "sine" belo
w with the | 17 // that can be used as the new expected reference file. Replace the "sine" belo
w with the |
| 18 // oscillator type that you want to use. | 18 // oscillator type that you want to use. |
| 19 // | 19 // |
| 20 // <!doctype html> | 20 // <!doctype html> |
| 21 // <html> | 21 // <html> |
| 22 // <head> | 22 // <head> |
| 23 // <script src="resources/compatibility.js"></script> | 23 // <script src="../resources/testharness.js"></script> |
| 24 // <script src="resources/buffer-loader.js"></script> | 24 // <script src="resources/oscillator-testing.js"></script> |
| 25 // <script src="../resources/js-test.js"></script> | 25 // <script src="resources/audit-util.js"></script> |
| 26 // <script src="resources/oscillator-testing.js"></script> | |
| 27 // <script src="resources/audio-testing.js"></script> | |
| 28 // </head> | 26 // </head> |
| 29 // <body> | 27 // <body> |
| 30 // <script> | 28 // <script> |
| 31 // OscillatorTestingUtils.createNewReference("sine"); | 29 // OscillatorTestingUtils.createNewReference("sine"); |
| 32 // </script> | 30 // </script> |
| 33 // </body> | 31 // </body> |
| 34 // </html> | 32 // </html> |
| 35 | 33 |
| 36 OscillatorTestingUtils = (function () { | 34 OscillatorTestingUtils = (function () { |
| 37 | 35 |
| 38 var sampleRate = 44100.0; | 36 var sampleRate = 44100.0; |
| 39 var nyquist = 0.5 * sampleRate; | 37 var nyquist = 0.5 * sampleRate; |
| 40 var lengthInSeconds = 4; | 38 var lengthInSeconds = 4; |
| 41 var lowFrequency = 10; | 39 var lowFrequency = 10; |
| 42 var highFrequency = nyquist + 2000; // go slightly higher than nyquist to make s
ure we generate silence there | 40 var highFrequency = nyquist + 2000; // go slightly higher than nyquist to make s
ure we generate silence there |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 thresholdSNR: thresholdSNR, | 186 thresholdSNR: thresholdSNR, |
| 189 thresholdDiff: thresholdDiff, | 187 thresholdDiff: thresholdDiff, |
| 190 thresholdDiffCount: thresholdDiffCount, | 188 thresholdDiffCount: thresholdDiffCount, |
| 191 waveScaleFactor: waveScaleFactor, | 189 waveScaleFactor: waveScaleFactor, |
| 192 setThresholds: setThresholds, | 190 setThresholds: setThresholds, |
| 193 runTest: runTest, | 191 runTest: runTest, |
| 194 createNewReference: createNewReference, | 192 createNewReference: createNewReference, |
| 195 }; | 193 }; |
| 196 | 194 |
| 197 }()); | 195 }()); |
| OLD | NEW |