My app. is displaying the peak frequency of input sound in RPM .. i have array of doubles contains the samples in time domain.
audioRecord.read(buffer, 0, 1024);
Then i did FFT on it .
transformer.ft(toTransform);
using this class Here
then i got the max magnitude of complex values which are the results of FFT
// block size = 1024
double magnitude[] = new double[blockSize / 2];
for (int i = 0; i < magnitude.length; i++) {
double R = toTransform[2 * i] * toTransform[2 * i];
double I = toTransform[2 * i + 1] * toTransform[2 * i * 1];
magnitude[i] = Math.sqrt(I + R);
}
int maxIndex = 0;
double max = magnitude[0];
for(int i = 1; i < magnitude.length; i++) {
if (magnitude[i] > max) {
max = magnitude[i];
maxIndex = i;
}
}
Now i got the index of the max magnitude ... 1 - How can i get the Peak Frequency in details pls ? 2 - Is there any ready function called ComputeFrequency() or getFrequency() ? Thanks in advance :)