
August 25th, 2011, 07:06 AM
#1
Problems getting the frequency of a wave
Hi. I'm working on a program that captures a sound by a mic from a guitar, and then via Fourier, getting the main frequency, and using it to indentify the sound (A, B, C...). I do this getting the real part of the output of the FFT (Fourier Fast Transform), and then looking for the position of the array (x; the frequency) where the value is the max (y;the amplitude). The thing is, the value I get doesn't match with the frequency of the sound I'm playing on the guitar.
Am I missing something?
Thank you.

August 25th, 2011, 07:50 AM
#2
Re: Problems getting the frequency of a wave
Try using a readybuilt library such as FFTW. You'll then be able to ask questions on the FFTW mailing list (which you'lll find if you follow the above link). Fourier transformation is a specialized area so you'd probably get better advice on a specialized site.
"A problem well stated is a problem half solved.”  Charles F. Kettering

August 25th, 2011, 08:09 AM
#3
Re: Problems getting the frequency of a wave
Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions.
What's your Visual C++ question?

August 25th, 2011, 02:04 PM
#4
Re: Problems getting the frequency of a wave
Thank you for your quick answers.
John E, I'll try working with that library and maybe as you say they can guide me better there.
0xC0000005, that is exactly what I'm trying to do, an harmonic analysis, so I can unequivocally identify a sound by its harmonics. To do so, that was my main idea; finding the fundamental harmonic and work from there, comparing to a table that would contain every fundamental harmonic  frequency for each sound. I just don't know if I'm missing something in the way.
Anyway, I guess GCDEF is right and this question should be asked to someone in the area of maths and signal processing rather than in a Visual forum. I came here because is in Visual where I am developing my application, and I thought that maybe someone had play with signals on Visual as well and had some idea of where I'm coming and what I am doing wrong.

August 25th, 2011, 02:11 PM
#5
Re: Problems getting the frequency of a wave

August 26th, 2011, 03:14 PM
#6
Re: Problems getting the frequency of a wave
Originally Posted by LuisRT
The thing is, the value I get doesn't match with the frequency of the sound I'm playing on the guitar.
I agree that this post belongs in the Algorithm forum
That being said, when you post there, please confirm that you have applied suitable windowing to the sound samples, such as a Hamming window. Without windowing, the resulting FFT will have peaks much broader than you might expect.
Please also let us know the sample rate and the total sample time. Both of these will tell us the width of each frequency bin in the resulting FFT, as well as the ability to reject noise.
Please also let us know whether the mismatch (between the frequency of the guitar note and the frequency detected by your algorithm) is large or small. By "small" I mean within one or two frequency bins of the FFT. Please recall that the FFT results in bins of discrete frequencies, and not a continuous function of frequency, such that it's not possible to simply take the bin with the highest value and call that the answer. Instead, it's necessary to interpolate using adjacent bins, and even then you will never be able to obtain the exact answer, owing to the fact that FFT results in bins of discrete frequency.
For some information on interpolation, see the following site and the following paper. Both are directed to DSP processing, so there is an emphasis on computational efficiency, but the underlying algorithms are helpful:
http://www.ericjacobsen.org/fe2/fe2.htm
http://www.ericjacobsen.org/FTinterp.pdf
Finally, you might also have some luck posting over in the comp.dsp newsgroup, but unless you want to be eaten alive there, you had better be familiar with the above: http://groups.google.com/group/comp.dsp/
Mike
Last edited by MikeAThon; August 26th, 2011 at 03:16 PM.

August 30th, 2011, 10:31 AM
#7
Re: Problems getting the frequency of a wave
Thank you very much, you gave me some things to think on. I'm going to go over all details and see first if there is maybe some problems on the way I am sampling the signal, specially relating to the noise that is present already in the incoming signal and the ability of rejecting noisein the FFT. I am now going over a DSP Complete Analysis, and then I'll check the links you posted there, and once I have go over every possibility, if the algorithm is still not giving meaningful results, I will turn to the algorithm forum or to that other one you mentioned.
Thanks Mike for your detailed answer and once again thanks every one for the help

August 31st, 2011, 02:27 AM
#8
Re: Problems getting the frequency of a wave
the value I get doesn't match with the frequency of the sound I'm playing on the guitar.
The last thing to remember whatever forum you in. Please be precise in your statements as much as possible, as this is going to show your respect to the issue as well as to the people you want some help from.
"Doesn't match" specifically tells me not much. What is the mismatch? Few percents? Times? Does the mismatch deviate from time to time? Which way you measure the value you are to compare with? How precise the measurement is?
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.
Featured
