Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: timelapse
Fetching contributors…

Cannot retrieve contributors at this time

75 lines (59 sloc) 2.396 kb
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script src="resources/audio-testing.js"></script>
<script src="resources/audioparam-testing.js"></script>
<script src="../resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Test AudioParam setValueCurveAtTime() functionality.");
// Play a long DC signal out through an AudioGainNode and for each time interval call
// setValueCurveAtTime() to set the values for the duration of the interval. Each curve is a sine
// wave, and we assume that the time interval is not an exact multiple of the period. This causes a
// discontinuity between time intervals which is used to test timing.
// Number of tests to run.
var numberOfTests = 20;
// Max allowed difference between the rendered data and the expected result. (The error is zero
// because the rendered curve should really be exactly the same as the reference.)
var maxAllowedError = 0;
// The amplitude of the sine wave.
var sineAmplitude = 1;
// Frequency of the sine wave.
var freqHz = 440;
// Curve to use for setValueCurveAtTime().
var curve;
// Sets the curve data for the entire time interval.
function automation(value, startTime, endTime)
{
gainNode.gain.setValueCurveAtTime(curve, startTime, endTime - startTime);
}
// Create a sine wave of the specified duration.
function createReferenceSineArray(startTime, endTime, startValue, endValue, sampleRate)
{
// Ignore |startValue| and |endValue| for the sine wave.
return createSineWaveArray(endTime - startTime, freqHz, sineAmplitude, sampleRate);
}
function runTest()
{
// The curve of values to use.
curve = createSineWaveArray(timeInterval, freqHz, sineAmplitude, sampleRate);
createAudioGraphAndTest(numberOfTests,
sineAmplitude,
function(k) {
// Don't need to set the value.
},
automation,
"setValueCurveAtTime()",
maxAllowedError,
createReferenceSineArray,
2 * Math.PI * sineAmplitude * freqHz / sampleRate);
}
runTest();
successfullyParsed = true;
</script>
<script src="../resources/js-test-post.js"></script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.