I am using the JavaScript Web Audio API to create a frequency viewer.
Apparently the getByteFrequencyData
distributes the gain of frequencies from 0 to 255 in an array, but the frequencies are apparently from 20Hz to 20kHz and I would like to know if I can regulate the frequency range that is stored. For example, instead of 20Hz to 20kHz, I would like 20Hz to 800Hz.
Edit:
Apparently, fftSize causes the frequency range to decrease, but increasing it a lot, leaves the analysis with a lot of delay.
No, you can't really configure the range. The frequency range is always 0 to context.sampleRate / 2
. Changing fftSize
just changes the number of bins that cover the range.
If you want just the range 20-800 Hz, just take the set of bins that cover this region. You will throw away a lot of data, but there's not much that can be done.
I really think AnalyserNode
is really meant for visualization, not analysis, despite the name.