tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

k-rate-biquad.html (3294B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Test k-rate AudioParams of BiquadFilterNode</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7    <script src="automation-rate-testing.js"></script>
      8  </head>
      9 
     10  <body>
     11    <script>
     12 
     13      promise_test(async () => {
     14        // Arbitrary sample rate and duration.
     15        const sampleRate = 8000;
     16        const testDuration = 1;
     17        const context = new OfflineAudioContext({
     18          numberOfChannels: 3,
     19          sampleRate: sampleRate,
     20          length: testDuration * sampleRate,
     21        });
     22 
     23        await doTest_W3TH(context, {
     24          nodeName: 'BiquadFilterNode',
     25          nodeOptions: {type: 'lowpass'},
     26          prefix: 'All k-rate params',
     27          // Set all AudioParams to k-rate
     28          rateSettings: [
     29            {name: 'Q', value: 'k-rate'},
     30            {name: 'detune', value: 'k-rate'},
     31            {name: 'frequency', value: 'k-rate'},
     32            {name: 'gain', value: 'k-rate'},
     33          ],
     34          // Automate just the frequency
     35          automations: [{
     36            name: 'frequency',
     37            methods: [
     38              {name: 'setValueAtTime', options: [350, 0]},
     39              {name: 'linearRampToValueAtTime', options: [0, testDuration]}
     40            ]
     41          }]
     42        });
     43      }, 'Biquad k-rate AudioParams (all)');
     44 
     45      // Define a test where we verify that a k-rate audio param produces
     46      // different results from an a-rate audio param for each of the audio
     47      // params of a biquad.
     48      //
     49      // Each entry gives the name of the AudioParam, an initial value to be
     50      // used with setValueAtTime, and a final value to be used with
     51      // linearRampToValueAtTime. (See |doTest_W3TH| for details as well.)
     52 
     53      [{name: 'Q',
     54        initial: 1,
     55        final: 10
     56       },
     57       {name: 'detune',
     58        initial: 0,
     59        final: 1200
     60       },
     61       {name: 'frequency',
     62        initial: 350,
     63        final: 0
     64       },
     65       {name: 'gain',
     66        initial: 10,
     67        final: 0
     68       }].forEach(paramProperty => {
     69        promise_test(async () => {
     70          // Arbitrary sample rate and duration.
     71          const sampleRate = 8000;
     72          const testDuration = 1;
     73          const context = new OfflineAudioContext({
     74            numberOfChannels: 3,
     75            sampleRate: sampleRate,
     76            length: testDuration * sampleRate
     77          });
     78 
     79          await doTest_W3TH(context, {
     80            nodeName: 'BiquadFilterNode',
     81            nodeOptions: {type: 'peaking', Q: 1, gain: 10},
     82            prefix: `k-rate ${paramProperty.name}`,
     83            // Just set the frequency to k-rate
     84            rateSettings: [
     85              {name: paramProperty.name, value: 'k-rate'},
     86            ],
     87            // Automate just the given AudioParam
     88            automations: [{
     89              name: paramProperty.name,
     90              methods: [
     91                {name: 'setValueAtTime', options: [paramProperty.initial, 0]},
     92                {
     93                  name: 'linearRampToValueAtTime',
     94                  options: [paramProperty.final, testDuration],
     95                }
     96              ]
     97            }]
     98          });
     99        }, `Biquad k-rate ${paramProperty.name}`);
    100      });
    101    </script>
    102  </body>
    103 </html>