tor-browser

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

convolution-mono-mono.html (2279B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>
      5      convolution-mono-mono.html
      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    <script src="/webaudio/resources/convolution-testing.js"></script>
     12  </head>
     13  <body>
     14    <script id="layout-test-code">
     15      let audit = Audit.createTaskRunner();
     16 
     17      // description("Tests ConvolverNode processing a mono channel with mono
     18      // impulse response.");
     19 
     20      // To test the convolver, we convolve two square pulses together to
     21      // produce a triangular pulse.  To verify the result is correct we
     22      // check several parts of the result.  First, we make sure the initial
     23      // part of the result is zero (due to the latency in the convolver).
     24      // Next, the triangular pulse should match the theoretical result to
     25      // within some roundoff.  After the triangular pulse, the result
     26      // should be exactly zero, but round-off prevents that.  We make sure
     27      // the part after the pulse is sufficiently close to zero.  Finally,
     28      // the result should be exactly zero because the inputs are exactly
     29      // zero.
     30      audit.define('test', function(task, should) {
     31        // Create offline audio context.
     32        let context = new OfflineAudioContext(
     33            2, sampleRate * renderLengthSeconds, sampleRate);
     34 
     35        let squarePulse = createSquarePulseBuffer(context, pulseLengthFrames);
     36        let trianglePulse =
     37            createTrianglePulseBuffer(context, 2 * pulseLengthFrames);
     38 
     39        let bufferSource = context.createBufferSource();
     40        bufferSource.buffer = squarePulse;
     41 
     42        let convolver = context.createConvolver();
     43        convolver.normalize = false;
     44        convolver.buffer = squarePulse;
     45 
     46        bufferSource.connect(convolver);
     47        convolver.connect(context.destination);
     48 
     49        bufferSource.start(0);
     50 
     51        context.startRendering()
     52            .then(buffer => {
     53              checkConvolvedResult(buffer, trianglePulse, should);
     54            })
     55            .then(task.done.bind(task));
     56        ;
     57      });
     58 
     59      audit.run();
     60    </script>
     61  </body>
     62 </html>