Convert AudioKit FFT to dB?

First post, thanks to the large community!

I am using AudioKit and trying to add frequency weighting filters to the microphone input, so I'm trying to figure out the values ​​that come out of AudioKit AKFFTTap.

I'm currently trying to just print the FFT buffer converted to dB values

 for i in 0..<self.bufferSize { let db = 20 * log10((self.fft?.fftData[Int(i)])!) print(db) } 

I expected the values ​​to be in the range of -128 to 0, but I get strange values ​​of almost -200 dB, and when I blow on the microphone to set the reading, it reaches about -60. Am I right about this? I assumed that the values ​​output from the EZAudioFFT mechanism would be equal to the amplitude and that normal dB math conversion would work. Does anyone have any ideas?

Thanks in advance for discussing this issue!

+5
source share
2 answers

The values ​​in the array correspond to the bin values ​​in the FFT. The presence of one hopper having a value close to 1 means that a large amount of energy is in a narrow frequency band, for example. very strong sinusoid (signal with a single frequency).

Normal sounds, for example, caused by the fact that you blow on a microphone, spread their energy throughout the spectrum, that is, in many cells instead of one. For this reason, as a rule, the values ​​become lower as the FFT size increases.

The value of -40 dB on one hopper is quite loud. If you try to reproduce the tone, you should see a clear peak in one of the bunkers.

+3
source

You need to add all the values ​​from self.fft?.fftData (think about changing negative values ​​to positive ones before adding) and then change it to decibels

+2
source

Source: https://habr.com/ru/post/1273067/


All Articles