1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Calculating Frequency

  1. Sep 8, 2006 #1
    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
     
  2. jcsd
  3. Sep 8, 2006 #2
    Look up the keyword fourier transform
     
  4. Sep 8, 2006 #3

    berkeman

    User Avatar

    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
     
  5. Sep 9, 2006 #4
    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 ...
     
  6. Sep 10, 2006 #5
    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 ...
     
  7. Sep 10, 2006 #6

    berkeman

    User Avatar

    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?
     
  8. Sep 11, 2006 #7
    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 ...
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Calculating Frequency
  1. Calculating Frequency. (Replies: 4)

Loading...