diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html')
-rw-r--r-- | testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html new file mode 100644 index 0000000000..de8406244b --- /dev/null +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/audioparam-setValueCurveAtTime.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html> + <head> + <title> + Test AudioParam.setValueCurveAtTime + </title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/webaudio/resources/audit-util.js"></script> + <script src="/webaudio/resources/audit.js"></script> + <script src="/webaudio/resources/audioparam-testing.js"></script> + </head> + <body> + <script id="layout-test-code"> + let audit = Audit.createTaskRunner(); + + // 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. + let numberOfTests = 20; + + // Max allowed difference between the rendered data and the expected + // result. Because of the linear interpolation, the rendered curve isn't + // exactly the same as the reference. This value is experimentally + // determined. + let maxAllowedError = 3.7194e-6; + + // The amplitude of the sine wave. + let sineAmplitude = 1; + + // Frequency of the sine wave. + let freqHz = 440; + + // Curve to use for setValueCurveAtTime(). + let curve; + + // Sets the curve data for the entire time interval. + function automation(value, startTime, endTime) { + gainNode.gain.setValueCurveAtTime( + curve, startTime, endTime - startTime); + } + + audit.define( + { + label: 'test', + description: 'AudioParam setValueCurveAtTime() functionality.' + }, + function(task, should) { + // The curve of values to use. + curve = createSineWaveArray( + timeInterval, freqHz, sineAmplitude, sampleRate); + + createAudioGraphAndTest( + task, should, numberOfTests, sineAmplitude, + function(k) { + // Don't need to set the value. + }, + automation, 'setValueCurveAtTime()', maxAllowedError, + createReferenceSineArray, + 2 * Math.PI * sineAmplitude * freqHz / sampleRate, + differenceErrorMetric); + }); + + audit.run(); + </script> + </body> +</html> |