Calculating Frequency from Sound Samples

  • Thread starter Traveller
  • Start date
  • Tags
    Frequency
In summary, the conversation discusses using a computer program to analyze sound waves. The individual is unsure of how to calculate the frequency from a set of samples and asks for help. The concept of Fourier transform is mentioned as a possible solution. The individual also mentions difficulties with extracting the correct frequency from the graph and seeks further advice.
  • #1
Traveller
4
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
  • #2
Look up the keyword Fourier transform
 
  • #3
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
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 ...
 
  • #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 ...
 
  • #6
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
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 ...
 

Related to Calculating Frequency from Sound Samples

What is frequency and how is it calculated?

Frequency is a measure of how often a particular event or occurrence happens. It is calculated by dividing the number of times the event occurs by the total number of opportunities for the event to occur. This can be represented as a fraction or a percentage.

How do you calculate frequency in a data set?

To calculate frequency in a data set, first organize the data in ascending or descending order. Then, count the number of times each value appears in the data set. Finally, divide the number of times each value appears by the total number of values in the data set to determine the frequency.

What is the difference between relative and cumulative frequency?

Relative frequency is the proportion of times a particular event occurs out of the total number of opportunities for the event to occur. It is often expressed as a decimal or percentage. Cumulative frequency, on the other hand, is the sum of all previous frequencies up to a certain point in the data set.

How is frequency used in statistics?

Frequency is a fundamental concept in statistics and is used to analyze and interpret data. It helps to identify patterns and trends in a data set, and can also be used to compare data sets and make predictions. It is a key component in calculating measures of central tendency and variability.

What are some common misconceptions about frequency?

One common misconception about frequency is that it is the same as probability. While frequency can be used to calculate probability, they are not interchangeable terms. Another misconception is that a higher frequency always indicates a higher likelihood of an event occurring. However, this is not always the case as there may be other factors at play. Frequency should always be considered in context with other relevant information and data.

Similar threads

  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
1K
  • Introductory Physics Homework Help
Replies
3
Views
1K
  • Introductory Physics Homework Help
Replies
8
Views
997
  • Introductory Physics Homework Help
Replies
7
Views
904
  • Introductory Physics Homework Help
Replies
2
Views
2K
  • Introductory Physics Homework Help
Replies
8
Views
1K
  • Introductory Physics Homework Help
Replies
19
Views
3K
Replies
9
Views
2K
  • Introductory Physics Homework Help
Replies
20
Views
2K
Back
Top