tor-browser

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

mix-testing.js (689B)


      1 let toneLengthSeconds = 1;
      2 
      3 // Create a buffer with multiple channels.
      4 // The signal frequency in each channel is the multiple of that in the first
      5 // channel.
      6 function createToneBuffer(context, frequency, duration, numberOfChannels) {
      7  let sampleRate = context.sampleRate;
      8  let sampleFrameLength = duration * sampleRate;
      9 
     10  let audioBuffer =
     11      context.createBuffer(numberOfChannels, sampleFrameLength, sampleRate);
     12 
     13  let n = audioBuffer.length;
     14 
     15  for (let k = 0; k < numberOfChannels; ++k) {
     16    let data = audioBuffer.getChannelData(k);
     17 
     18    for (let i = 0; i < n; ++i)
     19      data[i] = Math.sin(frequency * (k + 1) * 2.0 * Math.PI * i / sampleRate);
     20  }
     21 
     22  return audioBuffer;
     23 }