tor-browser

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

feedback-delay-time.html (1449B)


      1 <!DOCTYPE html>
      2 <html class="a">
      3  <head>
      4    <title>Feedback cycle with delay in audio node graph</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7  </head>
      8  <body>
      9    <script>
     10      function doTest() {
     11        var off = new OfflineAudioContext(1, 512, 48000);
     12        var b = off.createBuffer(1, 1, 48000);
     13        b.getChannelData(0)[0] = 1;
     14        var impulse = new AudioBufferSourceNode(off, {buffer: b});
     15        impulse.start(0);
     16        var delay = new DelayNode(off, {delayTime: 128 / 48000});
     17        var fb = new GainNode(off);
     18        impulse.connect(fb).connect(delay).connect(fb).connect(off.destination);
     19        var samples;
     20        return off.startRendering().then((b) => {
     21          return Promise.resolve(b.getChannelData(0));
     22        });
     23      }
     24 
     25      promise_test(() => {
     26        return doTest().then(samples => {
     27          for (var i = 0; i < samples.length; i++) {
     28            if ((i % 128) != 0) {
     29              assert_equals(
     30                  samples[i], 0.0,
     31                  'Non-silent audio found in between delayed impulses');
     32            } else {
     33              assert_equals(
     34                  samples[i], 1.0,
     35                  'Silent audio found instead of a delayed impulse');
     36            }
     37          }
     38        });
     39      }, 'Test that a DelayNode allows a feedback loop of a single rendering quantum');
     40    </script>
     41  </body>
     42 </html>