p5.js-sound icon indicating copy to clipboard operation
p5.js-sound copied to clipboard

Set frequency range for FFT Analyze?

Open paulcanning opened this issue 4 years ago • 2 comments

I'm using analyze to create a circular spectrum graphic, but the issue I have is that the "end" of the circle typically stays put, as the frequency range is simply never hit.

Is there a way to "dial in" a frequency range, or put a max frequency for the analysis?

Screenshot 2021-03-15 at 18 02 00

You can see in my image, the peaks are the low frequencies, which get a lot of usage. Even if I play a high frequency tone, to get any peaks at the end, it's such a high frequency, its like a mosquito buzzing around.

paulcanning avatar Mar 15 '21 18:03 paulcanning

@paulcanning

new p5.FFT([smoothing], [bins])

this see the constructor . provide value of [bins] to get the desired output

Ajaya1000 avatar Apr 19 '21 04:04 Ajaya1000

@Ajaya1000

I think the bins argument which control the fft length can't help you adjust the frequency range. The frequency range of you fft result is determined by the sample rate of you time domain data(e.g. for mp3 file it's 44.1khz). By changing the fft length you are actually changing the frequency domain resolution(checkout this post).

@paulcanning

I believe what you should do here is add some additional logic into you UI code. You can add logic to identify the frequency band you are interested in plotting by checking the magnitude of spectrum.

yxiao1996 avatar May 10 '21 23:05 yxiao1996