tor-browser

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

detune-overflow.html (1318B)


      1 <!doctype html>
      2 <html>
      3  <head>
      4    <title>Test Osc.detune Overflow</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>
      7    <script src="/webaudio/resources/audit.js"></script>
      8    <script src="/webaudio/resources/audit-util.js"></script>
      9  </head>
     10 
     11  <body>
     12    <script>
     13      const sampleRate = 44100;
     14      const renderLengthFrames = RENDER_QUANTUM_FRAMES;
     15 
     16      let audit = Audit.createTaskRunner();
     17 
     18      audit.define('detune overflow', async (task, should) => {
     19        let context =
     20            new OfflineAudioContext(1, renderLengthFrames, sampleRate);
     21 
     22        // This value of frequency and detune results in a computed frequency of
     23        // 440*2^(153600/1200) = 1.497e41.  The frequency needs to be clamped to
     24        // Nyquist.  But a sine wave at Nyquist frequency is all zeroes.  Verify
     25        // the output is 0.
     26        let osc = new OscillatorNode(context, {frequency: 440, detune: 153600});
     27 
     28        osc.connect(context.destination);
     29 
     30        let buffer = await context.startRendering();
     31        let output = buffer.getChannelData(0);
     32        should(output, 'Osc freq and detune outside nominal range')
     33            .beConstantValueOf(0);
     34 
     35        task.done();
     36      });
     37 
     38      audit.run();
     39    </script>
     40  </body>
     41 </html>