How to extract frequency information from samples from PortAudio using FFTW in C

前端 未结 1 1193
梦毁少年i
梦毁少年i 2020-12-04 23:08

I want to make a program that would record audio data using PortAudio (I have this part done) and then display the frequency information of that recorded audio (for now, I\'

相关标签:
1条回答
  • 2020-12-04 23:38

    To convert your audio samples to a power spectrum:

    • if your audio data is integer data then convert it to floating point
    • pick an FFT size (e.g. N=1024)
    • apply a window function to N samples of your data (e.g. Hanning)
    • use a real-to-complex FFT of size N to generate frequency domain data
    • calculate the magnitude of your complex frequency domain data (magnitude = sqrt(re^2 + im^2))
    • optionally convert magnitude to a log scale (dB) (magnitude_dB = 20*log10(magnitude))
    0 讨论(0)
提交回复
热议问题