tor-browser

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

test_gainNodePassThrough.html (1145B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <title>Test GainNode with passthrough</title>
      5  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      6  <script type="text/javascript" src="webaudio.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 <pre id="test">
     11 <script class="testbody" type="text/javascript">
     12 
     13 var gTest = {
     14  length: 2048,
     15  numberOfChannels: 1,
     16  createGraph(context) {
     17    var source = context.createBufferSource();
     18 
     19    var gain = context.createGain();
     20 
     21    source.buffer = this.buffer;
     22 
     23    source.connect(gain);
     24 
     25    gain.gain.value = 0.5;
     26 
     27    var gainWrapped = SpecialPowers.wrap(gain);
     28    ok("passThrough" in gainWrapped, "GainNode should support the passThrough API");
     29    gainWrapped.passThrough = true;
     30 
     31    source.start(0);
     32    return gain;
     33  },
     34  createExpectedBuffers(context) {
     35    this.buffer = context.createBuffer(1, 2048, context.sampleRate);
     36    for (var i = 0; i < 2048; ++i) {
     37      this.buffer.getChannelData(0)[i] = Math.sin(440 * 2 * Math.PI * i / context.sampleRate);
     38    }
     39 
     40    return [this.buffer];
     41  },
     42 };
     43 
     44 runTest();
     45 
     46 </script>
     47 </pre>
     48 </body>
     49 </html>