How can I get DFT/FFT output frequencies in Hertz?

前端 未结 1 1160
旧巷少年郎
旧巷少年郎 2021-01-31 23:48

I want to develop musical notes detector as my degree project and I want to do it from scratch. I have written code for \".wav\" file which extracts all info from that audio mus

相关标签:
1条回答
  • 2021-02-01 00:14

    You need to find the peak magnitude then work out the corresponding frequency:

    • calculate the magnitude of each DFT output bin: magnitude = sqrt(re*re+im*im)
    • find the bin with the largest magnitude, call its index i_max.
    • calculate the equivalent frequency of this bin: freq = i_max * Fs / N, here Fs = sample rate (Hz) and N = no of points in FFT.

    See this answer for a more detailed explanation of how bin indices and frequency are related.

    0 讨论(0)
提交回复
热议问题