Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|
hongchan
2015/08/07 17:32:51
<!DOCTYPE html>
Let's make it all the header cons
Raymond Toy
2015/08/07 18:52:27
Not relevant to this CL. Let's do that in a separa
| |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="resources/compatibility.js"></script> | 4 <script src="resources/compatibility.js"></script> |
| 5 <script src="resources/audio-testing.js"></script> | 5 <script src="resources/audio-testing.js"></script> |
| 6 <script src="resources/audioparam-testing.js"></script> | 6 <script src="resources/audioparam-testing.js"></script> |
| 7 <script src="../resources/js-test.js"></script> | 7 <script src="../resources/js-test.js"></script> |
|
hongchan
2015/08/07 17:32:51
Technically it does not matter, but js-test.js sho
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 8 </head> | 8 </head> |
| 9 | 9 |
| 10 <body> | 10 <body> |
| 11 <div id="description"></div> | 11 <div id="description"></div> |
| 12 <div id="console"></div> | 12 <div id="console"></div> |
|
hongchan
2015/08/07 17:32:51
These two elements are programmatically injected b
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 13 | 13 |
| 14 <script> | 14 <script> |
| 15 description("Test AudioParam setValueCurveAtTime() functionality."); | 15 description("Test AudioParam setValueCurveAtTime() functionality."); |
| 16 | 16 |
| 17 // Play a long DC signal out through an AudioGainNode and for each time interval call | 17 // Play a long DC signal out through an AudioGainNode and for each time interval call |
| 18 // setValueCurveAtTime() to set the values for the duration of the interval. Ea ch curve is a sine | 18 // setValueCurveAtTime() to set the values for the duration of the interval. Ea ch curve is a sine |
| 19 // wave, and we assume that the time interval is not an exact multiple of the pe riod. This causes a | 19 // wave, and we assume that the time interval is not an exact multiple of the pe riod. This causes a |
| 20 // discontinuity between time intervals which is used to test timing. | 20 // discontinuity between time intervals which is used to test timing. |
| 21 | 21 |
| 22 // Number of tests to run. | 22 // Number of tests to run. |
| 23 var numberOfTests = 20; | 23 var numberOfTests = 20; |
| 24 | 24 |
| 25 // Max allowed difference between the rendered data and the expected result. (T he error is zero | 25 // Max allowed difference between the rendered data and the expected result. Be cause of the linear |
| 26 // because the rendered curve should really be exactly the same as the reference .) | 26 // interpolation, the rendered curve isn't exactly the same as the reference. T his value is |
| 27 // experimentally determined. | |
| 27 var maxAllowedError = 0; | 28 var maxAllowedError = 0; |
| 28 | 29 |
| 29 // The amplitude of the sine wave. | 30 // The amplitude of the sine wave. |
| 30 var sineAmplitude = 1; | 31 var sineAmplitude = 1; |
| 31 | 32 |
| 32 // Frequency of the sine wave. | 33 // Frequency of the sine wave. |
| 33 var freqHz = 440; | 34 var freqHz = 440; |
|
hongchan
2015/08/07 17:32:51
Frequency uses Hz as unit. So I don't think we nee
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 34 | 35 |
| 35 // Curve to use for setValueCurveAtTime(). | 36 // Curve to use for setValueCurveAtTime(). |
| 36 var curve; | 37 var curve; |
| 37 | 38 |
| 38 // Sets the curve data for the entire time interval. | 39 // Sets the curve data for the entire time interval. |
| 39 function automation(value, startTime, endTime) | 40 function automation(value, startTime, endTime) |
|
hongchan
2015/08/07 17:32:51
Let's have the curly brace after the function defi
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 40 { | 41 { |
| 41 gainNode.gain.setValueCurveAtTime(curve, startTime, endTime - startTime); | 42 gainNode.gain.setValueCurveAtTime(curve, startTime, endTime - startTime); |
|
hongchan
2015/08/07 17:32:51
Personally I am not a big fan of this pattern. |ga
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Create a sine wave of the specified duration. | 45 // Create a sine wave of the specified duration. |
| 45 function createReferenceSineArray(startTime, endTime, startValue, endValue, samp leRate) | 46 function createReferenceSineArray(startTime, endTime, startValue, endValue, samp leRate) |
| 46 { | 47 { |
|
hongchan
2015/08/07 17:32:51
ditto. Let's move one line up the curly brace.
Raymond Toy
2015/08/07 18:52:27
Same comment as above.
| |
| 47 // Ignore |startValue| and |endValue| for the sine wave. | 48 // Ignore |startValue| and |endValue| for the sine wave. |
| 48 return createSineWaveArray(endTime - startTime, freqHz, sineAmplitude, sampl eRate); | 49 return createSineWaveArray(endTime - startTime, freqHz, sineAmplitude, sampl eRate); |
| 49 } | 50 } |
| 50 | 51 |
| 51 function runTest() | 52 function runTest() |
| 52 { | 53 { |
| 53 // The curve of values to use. | 54 // The curve of values to use. |
| 54 curve = createSineWaveArray(timeInterval, freqHz, sineAmplitude, sampleRate) ; | 55 curve = createSineWaveArray(timeInterval, freqHz, sineAmplitude, sampleRate) ; |
| 55 | 56 |
| 56 createAudioGraphAndTest(numberOfTests, | 57 createAudioGraphAndTest(numberOfTests, |
| 57 sineAmplitude, | 58 sineAmplitude, |
| 58 function(k) { | 59 function(k) { |
| 59 // Don't need to set the value. | 60 // Don't need to set the value. |
| 60 }, | 61 }, |
| 61 automation, | 62 automation, |
| 62 "setValueCurveAtTime()", | 63 "setValueCurveAtTime()", |
| 63 maxAllowedError, | 64 maxAllowedError, |
| 64 createReferenceSineArray, | 65 createReferenceSineArray, |
| 65 2 * Math.PI * sineAmplitude * freqHz / sampleRate); | 66 2 * Math.PI * sineAmplitude * freqHz / sampleRate); |
| 66 } | 67 } |
| 67 | 68 |
| 68 runTest(); | 69 runTest(); |
| 69 successfullyParsed = true; | 70 successfullyParsed = true; |
| 70 | 71 |
| 71 </script> | 72 </script> |
| 72 | 73 |
| 73 </body> | 74 </body> |
| 74 </html> | 75 </html> |
| OLD | NEW |