tor-browser

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

convolver-cascade.html (2004B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      Test Cascade of Mono Convolvers
      6    </title>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="/webaudio/resources/audit-util.js"></script>
     10    <script src="/webaudio/resources/audit.js"></script>
     11  </head>
     12  <body>
     13    <script id="layout-test-code">
     14      let audit = Audit.createTaskRunner();
     15 
     16      // Arbitrary sample rate and reasonably short duration
     17      let sampleRate = 8000;
     18      let duration = 0.25;
     19      let renderFrames = duration * sampleRate;
     20 
     21      audit.define(
     22          {label: 'cascade-mono', description: 'Cascaded mono convolvers'},
     23          (task, should) => {
     24            // Cascade two convolvers with mono responses and verify that the
     25            // output is not silent.
     26            let context = new OfflineAudioContext(1, renderFrames, sampleRate);
     27 
     28            let b0 =
     29                new AudioBuffer({length: 5, sampleRate: context.sampleRate});
     30            b0.getChannelData(0)[1] = 1;
     31            let c0 = new ConvolverNode(
     32                context, {disableNormalization: true, buffer: b0});
     33 
     34            let b1 =
     35                new AudioBuffer({length: 5, sampleRate: context.sampleRate});
     36            b1.getChannelData(0)[2] = 1;
     37 
     38            let c1 = new ConvolverNode(
     39                context, {disableNormalization: true, buffer: b1});
     40 
     41            let src = new OscillatorNode(context);
     42 
     43            src.connect(c0).connect(c1).connect(context.destination);
     44 
     45            src.start();
     46 
     47            context.startRendering()
     48                .then(audioBuffer => {
     49                  // Just verify the output is not silent
     50                  let audio = audioBuffer.getChannelData(0);
     51 
     52                  should(audio, 'Output of cascaded mono convolvers')
     53                      .notBeConstantValueOf(0);
     54                })
     55                .then(() => task.done());
     56          });
     57 
     58      audit.run();
     59    </script>
     60  </body>
     61 </html>