1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN">
4 <script src=
"resources/compatibility.js"></script>
5 <script src=
"resources/audio-testing.js"></script>
6 <script src=
"resources/audioparam-testing.js"></script>
7 <script src=
"../resources/js-test.js"></script>
11 <div id=
"description"></div>
12 <div id=
"console"></div>
15 description("Test AudioParam setValueCurveAtTime() functionality.");
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. Each curve is a sine
19 // wave, and we assume that the time interval is not an exact multiple of the period. This causes a
20 // discontinuity between time intervals which is used to test timing.
22 // Number of tests to run.
23 var numberOfTests
= 20;
25 // Max allowed difference between the rendered data and the expected result. Because of the linear
26 // interpolation, the rendered curve isn't exactly the same as the reference. This value is
27 // experimentally determined.
28 var maxAllowedError
= 4.657e-10;
30 // The amplitude of the sine wave.
31 var sineAmplitude
= 1;
33 // Frequency of the sine wave.
36 // Curve to use for setValueCurveAtTime().
39 // Sets the curve data for the entire time interval.
40 function automation(value
, startTime
, endTime
)
42 gainNode
.gain
.setValueCurveAtTime(curve
, startTime
, endTime
- startTime
);
45 // Create a sine wave of the specified duration.
46 function createReferenceSineArray(startTime
, endTime
, startValue
, endValue
, sampleRate
)
48 // Ignore |startValue| and |endValue| for the sine wave.
49 return createSineWaveArray(endTime
- startTime
, freqHz
, sineAmplitude
, sampleRate
);
54 // The curve of values to use.
55 curve
= createSineWaveArray(timeInterval
, freqHz
, sineAmplitude
, sampleRate
);
57 createAudioGraphAndTest(numberOfTests
,
60 // Don't need to set the value.
63 "setValueCurveAtTime()",
65 createReferenceSineArray
,
66 2 * Math
.PI
* sineAmplitude
* freqHz
/ sampleRate
);
70 successfullyParsed
= true;