summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html')
-rw-r--r--testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html
new file mode 100644
index 0000000000..85ae4f175f
--- /dev/null
+++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-biquad.html
@@ -0,0 +1,111 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Test k-rate AudioParams of BiquadFilterNode</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="automation-rate-testing.js"></script>
+ </head>
+
+ <body>
+ <script>
+ let audit = Audit.createTaskRunner();
+
+ audit.define(
+ {task: 'BiquadFilter-0', label: 'Biquad k-rate AudioParams (all)'},
+ (task, should) => {
+ // Arbitrary sample rate and duration.
+ let sampleRate = 8000;
+ let testDuration = 1;
+ let context = new OfflineAudioContext({
+ numberOfChannels: 3,
+ sampleRate: sampleRate,
+ length: testDuration * sampleRate
+ });
+
+ doTest(context, should, {
+ nodeName: 'BiquadFilterNode',
+ nodeOptions: {type: 'lowpass'},
+ prefix: 'All k-rate params',
+ // Set all AudioParams to k-rate
+ rateSettings: [
+ {name: 'Q', value: 'k-rate'},
+ {name: 'detune', value: 'k-rate'},
+ {name: 'frequency', value: 'k-rate'},
+ {name: 'gain', value: 'k-rate'},
+ ],
+ // Automate just the frequency
+ automations: [{
+ name: 'frequency',
+ methods: [
+ {name: 'setValueAtTime', options: [350, 0]}, {
+ name: 'linearRampToValueAtTime',
+ options: [0, testDuration]
+ }
+ ]
+ }]
+ }).then(() => task.done());
+ });
+
+ // Define a test where we verify that a k-rate audio param produces
+ // different results from an a-rate audio param for each of the audio
+ // params of a biquad.
+ //
+ // Each entry gives the name of the AudioParam, an initial value to be
+ // used with setValueAtTime, and a final value to be used with
+ // linearRampToValueAtTime. (See |doTest| for details as well.)
+
+ [{name: 'Q',
+ initial: 1,
+ final: 10
+ },
+ {name: 'detune',
+ initial: 0,
+ final: 1200
+ },
+ {name: 'frequency',
+ initial: 350,
+ final: 0
+ },
+ {name: 'gain',
+ initial: 10,
+ final: 0
+ }].forEach(paramProperty => {
+ audit.define('Biquad k-rate ' + paramProperty.name, (task, should) => {
+ // Arbitrary sample rate and duration.
+ let sampleRate = 8000;
+ let testDuration = 1;
+ let context = new OfflineAudioContext({
+ numberOfChannels: 3,
+ sampleRate: sampleRate,
+ length: testDuration * sampleRate
+ });
+
+ doTest(context, should, {
+ nodeName: 'BiquadFilterNode',
+ nodeOptions: {type: 'peaking', Q: 1, gain: 10},
+ prefix: `k-rate ${paramProperty.name}`,
+ // Just set the frequency to k-rate
+ rateSettings: [
+ {name: paramProperty.name, value: 'k-rate'},
+ ],
+ // Automate just the given AudioParam
+ automations: [{
+ name: paramProperty.name,
+ methods: [
+ {name: 'setValueAtTime', options: [paramProperty.initial, 0]}, {
+ name: 'linearRampToValueAtTime',
+ options: [paramProperty.final, testDuration]
+ }
+ ]
+ }]
+ }).then(() => task.done());
+ });
+ });
+
+ audit.run();
+ </script>
+ </body>
+</html>