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