| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 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/audit.js"></script> |
| 7 <script src="../resources/audioparam-testing.js"></script> | 8 <script src="../resources/audioparam-testing.js"></script> |
| 8 <title>Test AudioParam.setValueCurveAtTime</title> | 9 <title>Test AudioParam.setValueCurveAtTime</title> |
| 9 </head> | 10 </head> |
| 10 | 11 |
| 11 <body> | 12 <body> |
| 12 <div id="description"></div> | |
| 13 <div id="console"></div> | |
| 14 | |
| 15 <script> | 13 <script> |
| 16 description("Test AudioParam setValueCurveAtTime() functionality."); | 14 let audit = Audit.createTaskRunner(); |
| 17 | 15 |
| 18 // Play a long DC signal out through an AudioGainNode and for each time interval
call | 16 // Play a long DC signal out through an AudioGainNode and for each time interval
call |
| 19 // setValueCurveAtTime() to set the values for the duration of the interval. Ea
ch curve is a sine | 17 // setValueCurveAtTime() to set the values for the duration of the interval. Ea
ch curve is a sine |
| 20 // wave, and we assume that the time interval is not an exact multiple of the pe
riod. This causes a | 18 // wave, and we assume that the time interval is not an exact multiple of the pe
riod. This causes a |
| 21 // discontinuity between time intervals which is used to test timing. | 19 // discontinuity between time intervals which is used to test timing. |
| 22 | 20 |
| 23 // Number of tests to run. | 21 // Number of tests to run. |
| 24 var numberOfTests = 20; | 22 let numberOfTests = 20; |
| 25 | 23 |
| 26 // Max allowed difference between the rendered data and the expected result. Be
cause of the linear | 24 // Max allowed difference between the rendered data and the expected result. Be
cause of the linear |
| 27 // interpolation, the rendered curve isn't exactly the same as the reference. T
his value is | 25 // interpolation, the rendered curve isn't exactly the same as the reference. T
his value is |
| 28 // experimentally determined. | 26 // experimentally determined. |
| 29 var maxAllowedError = 3.7194e-6; | 27 let maxAllowedError = 3.7194e-6; |
| 30 | 28 |
| 31 // The amplitude of the sine wave. | 29 // The amplitude of the sine wave. |
| 32 var sineAmplitude = 1; | 30 let sineAmplitude = 1; |
| 33 | 31 |
| 34 // Frequency of the sine wave. | 32 // Frequency of the sine wave. |
| 35 var freqHz = 440; | 33 let freqHz = 440; |
| 36 | 34 |
| 37 // Curve to use for setValueCurveAtTime(). | 35 // Curve to use for setValueCurveAtTime(). |
| 38 var curve; | 36 let curve; |
| 39 | 37 |
| 40 // Sets the curve data for the entire time interval. | 38 // Sets the curve data for the entire time interval. |
| 41 function automation(value, startTime, endTime) | 39 function automation(value, startTime, endTime) |
| 42 { | 40 { |
| 43 gainNode.gain.setValueCurveAtTime(curve, startTime, endTime - startTime); | 41 gainNode.gain.setValueCurveAtTime(curve, startTime, endTime - startTime); |
| 44 } | 42 } |
| 45 | 43 |
| 46 function runTest() | 44 audit.define("test", function (task, should) { |
| 47 { | 45 task.describe("AudioParam setValueCurveAtTime() functionality."); |
| 48 // The curve of values to use. | 46 // The curve of values to use. |
| 49 curve = createSineWaveArray(timeInterval, freqHz, sineAmplitude, sampleRate)
; | 47 curve = createSineWaveArray(timeInterval, freqHz, sineAmplitude, sampleRate)
; |
| 50 | 48 |
| 51 createAudioGraphAndTest(numberOfTests, | 49 createAudioGraphAndTest(task, should, numberOfTests, |
| 52 sineAmplitude, | 50 sineAmplitude, |
| 53 function(k) { | 51 function(k) { |
| 54 // Don't need to set the value. | 52 // Don't need to set the value. |
| 55 }, | 53 }, |
| 56 automation, | 54 automation, |
| 57 "setValueCurveAtTime()", | 55 "setValueCurveAtTime()", |
| 58 maxAllowedError, | 56 maxAllowedError, |
| 59 createReferenceSineArray, | 57 createReferenceSineArray, |
| 60 2 * Math.PI * sineAmplitude * freqHz / sampleRate, | 58 2 * Math.PI * sineAmplitude * freqHz / sampleRate, |
| 61 differenceErrorMetric); | 59 differenceErrorMetric); |
| 62 } | 60 }); |
| 63 | 61 |
| 64 runTest(); | 62 audit.run(); |
| 65 successfullyParsed = true; | |
| 66 | |
| 67 </script> | 63 </script> |
| 68 | 64 |
| 69 </body> | 65 </body> |
| 70 </html> | 66 </html> |
| OLD | NEW |