FFT Problem (Returns random results)

后端 未结 4 1184
盖世英雄少女心
盖世英雄少女心 2021-01-24 02:37

I\'ve got this code, but it keeps returning random frequencies from 0 to about 1050. Please can you help me understand why this is happening.

My data length is 1024, sam

4条回答
  •  盖世英雄少女心
    2021-01-24 03:03

    Assuming oSignal is filled with complex numbers in such a way, that real and imaginary parts alternate, it might help to change

    for(int y=0;y< 8191;y++)
    

    to

    for(int y=0;y< 8191;y+=2)
    

    Edit: I didn't even notice that you're passing only 1024 samples. You must pass as many time-domain samples as there will be frequency-domain samples, in your case 4096.

    Edit: One more thing: you're obviously trying to find the base frequency of something. Unless that something is a computer generated tone or a human whistle (both of which are very pure tones), you might be disappointed by the result. The simple method you posted barely works for flute.

    Edit: For voice and guitar you're out of luck. I wrote a program some time ago that displays the frequency domain, try it out, you'll see the problem. There are also sources available, if you're interested.

    Final edit: You might want to read the Wikipedia article on pitch detection. Concentrate on time-domain approaches.

提交回复
热议问题