tor-browser

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

test-analyser-gain.html (1554B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <script src="/resources/testharness.js"></script>
      6  <script src="/resources/testharnessreport.js"></script>
      7  <script>
      8 promise_test(function() {
      9  // fftSize <= bufferSize so that the time domain data is full of input after
     10  // processing the buffer.
     11  const fftSize = 32;
     12  const bufferSize = 128;
     13 
     14  var context = new OfflineAudioContext(1, bufferSize, 48000);
     15 
     16  var analyser1 = context.createAnalyser();
     17  analyser1.fftSize = fftSize;
     18  analyser1.connect(context.destination);
     19  var analyser2 = context.createAnalyser();
     20  analyser2.fftSize = fftSize;
     21 
     22  var gain = context.createGain();
     23  gain.gain.value = 2.0;
     24  gain.connect(analyser1);
     25  gain.connect(analyser2);
     26 
     27  // Create a DC input to make getFloatTimeDomainData() output consistent at
     28  // any time.
     29  var buffer = context.createBuffer(1, 1, context.sampleRate);
     30  buffer.getChannelData(0)[0] = 1.0 / gain.gain.value;
     31  var source = context.createBufferSource();
     32  source.buffer = buffer;
     33  source.loop = true;
     34  source.connect(gain);
     35  source.start();
     36 
     37  return context.startRendering().then(function(buffer) {
     38    assert_equals(buffer.getChannelData(0)[0], 1.0, "analyser1 output");
     39 
     40    var data = new Float32Array(1);
     41    analyser1.getFloatTimeDomainData(data);
     42    assert_equals(data[0], 1.0, "analyser1 time domain data");
     43    analyser2.getFloatTimeDomainData(data);
     44    assert_equals(data[0], 1.0, "analyser2 time domain data");
     45  });
     46 }, "Test effect of AnalyserNode on GainNode output");
     47  </script>
     48 </head>
     49 </body>
     50 </html>