What does the FFT data in the Web Audio API correspond to?

后端 未结 2 1348
予麋鹿
予麋鹿 2020-12-23 10:22

I\'ve used the FFT data from the Analyser node using the getByteFrequencyData method in the Web Audio API to create a spectrum visualizer as shown below:

<
2条回答
  •  情书的邮戳
    2020-12-23 10:42

    yes,getByteFrequencyData results in a normalized array of values between 0 and 255. (it copies the data to the array it gets passed-in).

    the frequency bands are split equally, so each element N of your array corresponds to:

    N * samplerate/fftSize
    

    so, the first bin is 0.
    and, assuming a samplerate of 44100 and a .fftSize of 512 the second would be: 86.13 Hz, and so on...

    you will find these two questions and answers useful, on dsp and on SO:

    Note that the length of your sampledata is half the .fftSize, effectively limiting the frequency-range to half the samplerate.

提交回复
热议问题