Using Fft In Android
I am having trouble understanding how I should pass PCM data from the mic to this FFT class I am using made by Piotr Wendykier (it's the DoubleFFT_1D class in JTransforms). I think
Solution 1:
If you are looking for the pitch of a musical note, you will find that pitch is often different from the spectral frequency peak produced by an FFT, especially for lower notes.
To find the frequency peak from a complex FFT, you need to calculate the vector magnitude of both the real and imaginary results.
mag(i) = sqrt(real[i]*real[i] + imag[i]*imag[i]);
Solution 2:
Since you're using real audio data as the input you should use realForward
function:
fft.realForward(audioDataDoubles);
Then you can compute the energy on a frequency by computing the magnitude of real and imaginary parts:
magn[i] = audioDataDoubles[2*i]*audioDataDoubles[2*i] + audioDataDoubles[2*i+1]*audioDataDoubles[2*i+1]
Post a Comment for "Using Fft In Android"