tor-browser

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

test_convolverNode_mono_mono.html (2297B)


      1 <!DOCTYPE html>
      2 
      3 <html>
      4 <head>
      5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6 <script type="text/javascript" src="webaudio.js"></script>
      7 <script type="text/javascript" src="layouttest-glue.js"></script>
      8 <script type="text/javascript" src="blink/audio-testing.js"></script>
      9 <script type="text/javascript" src="blink/convolution-testing.js"></script>
     10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 
     13 <body>
     14 
     15 <div id="description"></div>
     16 <div id="console"></div>
     17 
     18 <script>
     19 description("Tests ConvolverNode processing a mono channel with mono impulse response.");
     20 SimpleTest.waitForExplicitFinish();
     21 
     22 // To test the convolver, we convolve two square pulses together to
     23 // produce a triangular pulse.  To verify the result is correct we
     24 // check several parts of the result.  First, we make sure the initial
     25 // part of the result is zero (due to the latency in the convolver).
     26 // Next, the triangular pulse should match the theoretical result to
     27 // within some roundoff.  After the triangular pulse, the result
     28 // should be exactly zero, but round-off prevents that.  We make sure
     29 // the part after the pulse is sufficiently close to zero.  Finally,
     30 // the result should be exactly zero because the inputs are exactly
     31 // zero.
     32 function runTest() {
     33    if (window.testRunner) {
     34        window.testRunner.dumpAsText();
     35        window.testRunner.waitUntilDone();
     36    }
     37 
     38    window.jsTestIsAsync = true;
     39 
     40    // Create offline audio context.
     41    var context = new OfflineAudioContext(2, sampleRate * renderLengthSeconds, sampleRate);
     42 
     43    var squarePulse = createSquarePulseBuffer(context, pulseLengthFrames);
     44    var trianglePulse = createTrianglePulseBuffer(context, 2 * pulseLengthFrames);
     45 
     46    var bufferSource = context.createBufferSource();
     47    bufferSource.buffer = squarePulse;
     48 
     49    var convolver = context.createConvolver();
     50    convolver.normalize = false;
     51    convolver.buffer = squarePulse;
     52 
     53    bufferSource.connect(convolver);
     54    convolver.connect(context.destination);
     55 
     56    bufferSource.start(0);
     57 
     58    context.oncomplete = checkConvolvedResult(trianglePulse);
     59    context.startRendering();
     60 }
     61 
     62 function finishJSTest() {
     63  SimpleTest.finish();
     64 }
     65 
     66 runTest();
     67 
     68 </script>
     69 
     70 <script src="../fast/js/resources/js-test-post.js"></script>
     71 </body>
     72 </html>