Sampling Rate samples what?

Audio software developers forum.

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Sampling Rate samples what?

Permanent link to this post Posted by merlin_1102 » Fri Nov 28, 2008 9:08 pm

Hey

Sorry if this is a dumb questions, but I became really confused by how Audacity handles the sample rate. I was 100% sure I knew what the sample rate does, but now I am not so certain. To keep it simple, say I generate a tone for a duration of 1 second. I then change the sample rate from 44100 to 22050Hz and my tone doubles from 1 second to 2 seconds. I cannot figure out why it would do this? Is this desired behavior?

Is the sample rate simply how many points it takes in a given second. This was my original understanding. E.g. 44100 is how many points along lets say a sine wave would be taken in a given second of the sine waves life? So in theory, if I had a sine wave with a frequency of '44100' , then it would be sampled 44100 times exactly.

If I were to generate a sine wave at 200Hz then it would be sampled a total of (44100*220.5) times (math below).
1/200Hz = period 0.005
1/44100 = 0.000022676
(0.005/0.000022676) = 220.5
And using the same math, a sampling rate of 22050 for a sine wave of 200Hz would be (22050*110.25) times. So sampled half as much.

I guess I am confused as to why my audio sample grew (given that the above math is correct. Is the sampling rate sampling the period of the sine wave some how or am I missing something. Does it simply say at a frequency of 44100 that I have so many points, and when I go to 22050 I still have as many points so lets extend the duration to use all those points with the 22050Hz sample. It would have to resample each point I am guessing as the points from the 44100 sampling are not the same points that would be sampled in a 22050 sampling (e.g. they would each sample at different parts of the sine wave (actually the 22050 should sample the same points as the 44100, just fewer over the same period of time)). So if it had to resample anyways, I am not sure why it just did not resample only as many points were needed for the 1 second duration. I am very concerned my understanding is now flawed though as a result of the time growth. That was very unexpected (I am also very new to audio programming).

Also, since I am asking questions, what would happen if I were to generate a sine wave of 88000 and only want a single sample at 44100. So the duration of this would actually be smaller then the duration of the number of samples I would get in 44100 (1.1364E-5 vs 2.2676E-5 seconds). Is this possible for an audio format to handle (I know that its not a very likely scenario that anyone would need this or even be able to hear it. I am just curious if this would break things as I would really be playing something with nearly half as many samples as needed to be at 44100Hz).

Thanks
merlin_1102
 
Posts: 1
Joined: Fri Nov 28, 2008 8:34 pm

Re: Sampling Rate samples what?

Permanent link to this post Posted by steve » Sat Nov 29, 2008 5:21 am

merlin_1102 wrote:Is the sample rate simply how many points it takes in a given second.
Yes
merlin_1102 wrote:E.g. 44100 is how many points along lets say a sine wave would be taken in a given second of the sine waves life? So in theory, if I had a sine wave with a frequency of '44100' , then it would be sampled 44100 times exactly.

Hmm, no. I think you are making it too complicated.

If you have 1 second (duration) of sound (any sound) and it has been recorded with a sampling rate of 44100Hz, then there will be 44100 samples. The "44100Hz" means the frequency at which samples are taken - in other words, it is the number of samples per second.

2 seconds at 22050Hz is 2x22050 samples = 44100 samples
1 second at 48000Hz (48kHz) is 48000 samples

(Sample Rate) = (Number of samples) per second
(Number of samples) = (Sample Rate) x time

merlin_1102 wrote:If I were to generate a sine wave at 200Hz then it would be sampled a total of (44100*220.5) times (math below).
1/200Hz = period 0.005
1/44100 = 0.000022676
(0.005/0.000022676) = 220.5

Yes, but that seems a complicated way of saying that the number of samples in a 1/200 second period will be:
44100 x (1/200)
(sample rate) x time

merlin_1102 wrote:I guess I am confused as to why my audio sample grew

It didn't exactly "grow" - it got "stretched".

At 44100Hz, there is one new sample every 1/44100th of a second
but at 22050Hz there is a new sample every 1/22050th of a second.

The samples have been spaced out over twice the length of time.

merlin_1102 wrote:what would happen if I were to generate a sine wave of 88000 and only want a single sample at 44100.
You can't generate a tone of 88000 Hz if you are using a sample rate of 44100Hz.
The highest theoretical frequency that you can have, is less than half of the sampling frequency. If you think about it, to represent a waveform you need to have at least 2 samples per period (which would give a very rough indication of the signal), so at a sample rate of 44100Hz, the highest possible frequency that can be represented is less than 22050Hz. This is known as the Nyquist frequency: http://en.wikipedia.org/wiki/Nyquist_frequency
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 35551
Joined: Sat Dec 01, 2007 11:43 am

Re: Sampling Rate samples what?

Permanent link to this post Posted by PPetrov » Sun Dec 28, 2008 5:22 am

Subjects:
Sampling Sine and cosine waves
Sampling simplest band limited signals
Nyquist–Shannon sampling theorem is not correct?


Dear Sir/Madam,

Could you please be so kind to see the papers below?
They are discussing the sampling of the Sine/Cosine waves
and the Sampling simplest band limited signals. May be will help.


http://www.ieindia.org/pdf/88/88ET104.pdf

http://www.ieindia.org/pdf/89/89CP109.pdf

http://www.pueron.org/pueron/nauchnakri tika/Th_Re.pdf

Also I believe the following rule could be applied:

"If everything else is neglected you could divide the sampling rate Fd at factor of four (4) in order to find the guaranteed bandwidth (-3dB) from your ADC in the worst case sampling of a sine wave without direct current component (DC= 0)."

I hope that this is useful to clarify the subject.

The feedback is welcomed.

Best and kind regards

Petre Petrov

ppetre@caramail.com
PPetrov
 
Posts: 1
Joined: Sun Dec 28, 2008 4:04 am


Return to General Audio Programming



Who is online

Users browsing this forum: No registered users and 2 guests