# Homework Help: Calculating Frequency

1. Sep 8, 2006

### Traveller

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 ... ;-)

Miles to go before I sleep

2. Sep 8, 2006

### nbo10

Look up the keyword fourier transform

3. Sep 8, 2006

### Staff: Mentor

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

4. Sep 9, 2006

### Traveller

Thanks

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 ...

5. Sep 10, 2006

### Traveller

I typed wrong ... let me correct it ...

***

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 ...

6. Sep 10, 2006

### Staff: Mentor

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?

7. Sep 11, 2006

Yes ...