I have used FFT algorithm to detect frequency of the sound(guitar pitch) and it works great when I play sinosoidal sound from the computer it will estimate it perfectly but it is not so perfect when i use guitar. How to better estimate the pitch frequency?
double[] spectrum = FourierTransform.Spectrum(ref sampleBuffer);//spectrum contains data from FFT
double frequency = indexOfMax(spectrum) * 16000 / 500; //sampling rate/FFT size
//indexOfMax just finds the index of the maximum element in the array
To generate sinosoidal waves i used: http://www.audiocheck.net/audiofrequencysignalgenerator_sinetone.php and fort this kind of waves just finding maximum from the spectrum array worked great, but I am looking for better way.