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