1
I’m using Analysernode to analyze the intensity of each frequency of a sound, so I can make a viewer. The problem is that the analyser.getByteFrequencyData()
returns the intensity of frequencies from 20Hz to 20KHz compressed in an array of 255 positions, and would like to filter these frequencies between, for example 30Hz and 600Hz, for this I thought to modify the API itself or make a new function using the analyser.getByteFrequencyData()
as a base and filter those frequencies. Or I needed a solution that got the same array by analyzing a smaller frequency range that might be outside the API.
I would like to know if I have access to the code of this API or at least know the internal functioning of it to be able to replicate or modify.
Edit:
In the API documentation we have the following:
The Frequency data is composed of integers on a Scale from 0 to 255. Each item in the array represents the decibel value for a specific Frequency. The Frequencies are spread linearly from 0 to 1/2 of the sample rate. For example, for 48000 sample rate, the last item of the array will represent the decibel value for 24000 Hz.
As the documentation shows, the frequencies are distributed from 0Hz to half the sample rate value, so I could simply decrease the sample rate to decrease the range of analysis, but the problem is that the analysis gets too slow.
I found the question OK and voted to reopen it, but I recommend you [Edit] and add a description of what you need to do, as it may not really be necessary a change at this level.
– Woss
I voted to reopen tbm, in theory do not have q filter anything, just cut your array into the corresponding spectral components ...
– ederwander
edit the question and enter your code ...
– ederwander
don’t even need to do it just vc cut the array into the correct components @Linuxmen
– ederwander
Imagine you have 255 bars on the screen, and you want them to represent 0Hz to 255Hz but you have an array of 255 positions that analyzes the frequencies from 20Hz to 20KHz. It’s not that simple.
– LinuxMen
of course it’s simple, each bar represents a spectral resolution based on the FFT size of your code and samplerate, so you know the frequency corresponding to each position of the array, an arr of 255 positions can be calculated to know the frequency, so I asked your code to ask, if you can put your code we need to know if this size of 255 is using Nyquist, here 1 answer d how to calculate the frequency of each position of the array here
– ederwander
The FFT’s work well with power of 2, I do not know if the implementation that JS uses works well with FFT sizes outside of this standard, but if you want 255 points between 30 and 600 hertz vc could make a FFT of exact size
21400
respecting the theorem of Nyquist vc would have21400/2= 10700
valid points, but now you can cut the array in position13
where it is equivalent to a frequency of 30hzround(1/(48000/30/(10700*2)))
and in position268
where freq equals 600hz,round(1/(48000/600/(10700*2)))
That would give you a 255 representation =268-13=255
bars to represent your freqs– ederwander
since your question has not been reopened can try to give you a north in the comments even kkk, summing td depends on the order of resolution you want and how many bars you need and if this size of the FFT will work in real time or the time it takes to calculate the spectrum, 21400 points is no small thing not heim it may be that you have to test if you have been working with real-time representation, these parameters give you an order of resolution in
2.24
hertz, to make a Spectrum Analyser is more than good rsrs ...– ederwander