Calculating Frequency from Sound Samples

  • Thread starter Thread starter Traveller
  • Start date Start date
  • Tags Tags
    Frequency
AI Thread Summary
The discussion focuses on calculating frequency from sound samples using a computer program. The user is utilizing Fast Fourier Transform (FFT) to analyze sound waves but is encountering discrepancies between the expected and calculated frequencies. Suggestions include verifying the accuracy of the time-domain representation of the signal and the window function used in the FFT process. Additionally, it's recommended to check the number of cycles in the data and adjust the dataset to improve accuracy. The user is encouraged to test these aspects to resolve the frequency extraction issue.
Traveller
Messages
4
Reaction score
0
Hi everybody ...

I have to write a computer program about analysizing the sound wave ... and I don't know much about it ...
Now I'm taking the signals from the sound card and save them in an array ...
So I got a set of samples ... using those samples I can make a picture and it will show a kind of wave depending on the input ...
Now my problem lies here ... If I want to calculate the frequency from that set of samples ... is it possible ...?
If there is any formula ... will you do a favor for me by letting me know ...?
f=(1/T) or f=(c/lambda) or f=(v/lambda) ... I only know those 3 and I don't know how to use them for a set of samples ...
Maybe my question is not showing a meaning ... because I don't know physics very well ... but I have to write the program and so I need someone to help me ... ;-)

Thanks in advance ...
Miles to go before I sleep
 
Physics news on Phys.org
Look up the keyword Fourier transform
 
For a continuous sine wave, you get two zero crossings per period. The frequency, as you wrote, is the inverse of this period: f = 1/T. You know your sample rate per point, so the number of samples that it takes to get two zero crossings tells you the period T.

If you have a mix of signals, then as nbo10 says, you will need to do some analysis like a Fourier transform on the signals. You will first need to apply a "window" function to your data, since the Fourier transform applies to inifinite-time functions, and you have a finite-time sample with square edges. The windowing function softens the edges, basically. Also, you will probably use a form of the FT called the Fast Fourier Transform (FFT). You could start at wikipedia:

http://en.wikipedia.org/wiki/Fast_fourier_transform
 
Thanks

Thank you both for your reply ...

Yes I used FFT for drawing a graph in Frequency Domain ...
Although I did it ... I didn't understand it very well ;-) ...
But I surely got that graph ...
Then I find out the highest y of that graph and take the corresponding x as the average frequency ... but it is exactly shows the frequency that I input from the signal generator ... I mean when I input with frequency 10 ... it shows 11 ... then 20 ... it shows 22 ... then 150 ... it shows 142 ...
So I don't want to extract from the graph ...
I don't know what to do now ...
While calculating fft series ... can I extract the frequency from that series ...?

With all my thanks and regards ...
Miles to go before I sleep ...
 
I typed wrong ... let me correct it ...

***

Thank you both for your reply ...

Yes I used FFT for drawing a graph in Frequency Domain ...
Although I did it ... I didn't understand it very well ;-) ...
But I surely got that graph ...
Then I find out the highest y of that graph and take the corresponding x as the average frequency ... but it is not exactly showing the frequency that I input from the signal generator ... I mean when I input with frequency 10 ... it shows 11 ... then 20 ... it shows 22 ... then 150 ... it shows 142 ...
So I don't want to extract the frequency from the graph ...
I don't know what to do now ...
While calculating fft series ... can I extract the frequency from that series ...?

With all my thanks and regards ...
Miles to go before I sleep ...
 
When you put in a sine wave and graph the time function, do you see the correct period in the v(t) data? Check that first to determine whether the error is in the digitization step, or the FFT step. What window function are you using? How many cycles of the sine wave are in the data? If you artificially cut the data set so that the waveform starts very close to zero and also ends very close to zero, do you get a better answer?
 
Yes ...
Your advice is very good ...
I should test them separately ...
Let me come back later ...

With thanks & regards ...
Miles to go before I sleep ...
 
Back
Top