0

I understand that fftSize and getByteTimeDomainData are linked since the length of fftSize is the same as the length of the array of getByteTimeDomainData.

const audioContext = new AudioContext();
const audioSourceNode = audioContext.createMediaElementSource(audio);
const analyserNode = audioContext.createAnalyser();

analyserNode.fftSize = 256;

const bufferTimeDomainLength = analyserNode.fftSize;
console.log(bufferTimeDomainLength)
const dataTimeDomainArray = new Uint8Array(bufferTimeDomainLength);

audioSourceNode.connect(analyserNode);
analyserNode.connect(audioContext.destination);
setTimeout(loop, 1000);

function loop() {
  analyserNode.getByteTimeDomainData(dataTimeDomainArray);
  for (let i = 0; i < bufferTimeDomainLength; i++) {
    let v = dataTimeDomainArray[i];
    console.log(v + " - " + i);
  }
}

My big question is that it represents v. Is it the amplitude of that sample or is it the bin number? I've actually read the Mozilla Developers documentation but I still don't understand anything.

sebas.varela
  • 1,535
  • 2
  • 10
  • 12

0 Answers0