IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Relation between audio sample rate and audio frequency?, Please help me understand the bearing of these two!
Gew
post Mar 19 2011, 22:20
Post #1





Group: Members
Posts: 22
Joined: 6-November 09
Member No.: 74690



Hi guys!

Since I know that lots of experienced people hang around here, I thought it'd be a good place to put this question. Now, i understand the basics of audio sampling frequency. In short; the number of times an analog waveform is "measured" (sampled) to it's digital PCM form. Now, what I don't seem to get into my [quite small] brain is what "specifies" that (or how) the low-pitched / high-pitched signals are sampled. Aawergh, that didn't make any sense, did it? I try to come up with a example, then maybe someone understands my way of thinking.

Telephone is 8KHz, i.e. it measures audio 8000 times per second, or 8 times per millisecond. Now, by theorem, these 8 samples/ms would consist of the lowest audio frequencies, i.e. 0-8000Hz (or 0-4Khz, if taking Nyquist law into consideration). But _what_ is it that specifies that these 8 samples/ms wouldn't consist of [for example] 8 higher audio frequencies? I _suppose_ that the answer to this could be something like "It's nature's law that it starts 'sampling' from point zero, and 'climbs' up the audio frequencies", and if someone would/could just confirm this, I suppose I could sleep. But right now, I'm dazed and confused, thinking a lot on this. Been reading the following work, but too dumb(?) to know which paragraph(s) in which of the articles that explains the answer to this. A quotation would be dandy, if anyone here know exactly.

http://en.wikipedia.org/wiki/Sampling_(signal_processing)
http://en.wikipedia.org/wiki/Sampling_rate
http://en.wikipedia.org/wiki/Audio_frequency
http://en.wikipedia.org/wiki/Nyquist–Shann...ampling_theorem
http://en.wikipedia.org/wiki/Nyquist_frequency

Thanks _a lot_ for any help I could get on this one.
As "easy-educational" as possible is preferably.

Regards~
G.
Go to the top of the page
+Quote Post
saratoga
post Mar 19 2011, 22:34
Post #2





Group: Members
Posts: 5169
Joined: 2-September 02
Member No.: 3264



QUOTE (Gew @ Mar 19 2011, 16:20) *
Telephone is 8KHz, i.e. it measures audio 8000 times per second, or 8 times per millisecond. Now, by theorem, these 8 samples/ms would consist of the lowest audio frequencies,


To be clear, low frequencies are those that change slowly. Anything changing substantially on the scale of 1 millisecond is a higher frequency.

QUOTE (Gew @ Mar 19 2011, 16:20) *
But _what_ is it that specifies that these 8 samples/ms wouldn't consist of [for example] 8 higher audio frequencies?


This question doesn't really make sense as phrased. I think maybe you're assuming that individual samples map to individual frequencies? If so, thats not how it works. Imagine a 1 Hz sin wave sampled at 8000 samples per second. Each cycle of the 1Hz tone will span all 8000 samples (since its period is 1 second). Thus every sample contributes to every frequency.
Go to the top of the page
+Quote Post
Gew
post Mar 19 2011, 23:29
Post #3





Group: Members
Posts: 22
Joined: 6-November 09
Member No.: 74690



QUOTE (saratoga @ Mar 19 2011, 22:34) *
QUOTE (Gew @ Mar 19 2011, 16:20) *
Telephone is 8KHz, i.e. it measures audio 8000 times per second, or 8 times per millisecond. Now, by theorem, these 8 samples/ms would consist of the lowest audio frequencies,


To be clear, low frequencies are those that change slowly. Anything changing substantially on the scale of 1 millisecond is a higher frequency.

QUOTE (Gew @ Mar 19 2011, 16:20) *
But _what_ is it that specifies that these 8 samples/ms wouldn't consist of [for example] 8 higher audio frequencies?


This question doesn't really make sense as phrased. I think maybe you're assuming that individual samples map to individual frequencies? If so, thats not how it works. Imagine a 1 Hz sin wave sampled at 8000 samples per second. Each cycle of the 1Hz tone will span all 8000 samples (since its period is 1 second). Thus every sample contributes to every frequency.


Perhaps this is good news. TBH, I must say that when you wrote "Imagine a sin wave" I was lost. I Google'd and landed on Sine_wave@Wikipedia. I noticed all the "above basic math" formulas so I quickly figured that this would not make any sense to me. However(!), your first quotation with answer "To be clear, low frequencies are those that change slowly. Anything changing substantially on the scale of 1 millisecond is a higher frequency." was very interesting. This _could_ be the easy answer to my question.

"To be clear, low frequencies are those that change slowly."

Now, after reading this I get a whole new aspect on things.
I now imagine a possible "easy answer" like this:

A tone of 8Khz "changes" 8 times each millisecond, therefor a sample rate of _at least_ 8Khz (well, technically 16Khz, since invoking Nyquist thing, but please let's put this aside for now, just to lay the basics straight) is needed to "be speedy enough" to catch all the waveform changes of this 8Khz tone.

Is this correct?
The more I think about it, it sounds really "easy" and logical.
Go to the top of the page
+Quote Post
motion_blur
post Mar 20 2011, 01:54
Post #4





Group: Members
Posts: 13
Joined: 8-March 11
Member No.: 88816



If your sampling rate is to low, you do not get the right frequency. that's called aliasing.

http://www.cabiatl.com/Resources/part/nyquist.png
http://en.wikipedia.org/wiki/Aliasing#Samp...oidal_functions

To define a sine wave you need at least two sampling points, one at the maximum and one at the minimum of the wave.
Go to the top of the page
+Quote Post
Gew
post Mar 20 2011, 01:56
Post #5





Group: Members
Posts: 22
Joined: 6-November 09
Member No.: 74690



I'm still getting confused.



This figure comes from the Wikipedian article on PCM.
Now, what I don't understand is how audio actually disappear when pulling down sample frequency.

Like this for example, I downloaded sample file "10kHz_44100Hz_16bit_05sec.wav" just for tests.
I did the following:

CODE
ffmpeg -i 10kHz_44100Hz_16bit_05sec.wav -ar 19090 -y test1.wav
ffmpeg -i 10kHz_44100Hz_16bit_05sec.wav -ar 20010 -y test2.wav


When pulling SR below 20KHz (eg. 19090Hz), the output is barely audible, whereas it's much like the original when playing test2.wav, only sampling Hz faster. This makes sense in regards of Nyquist theorem, (tone is 10KHz meaning SR must be >20KHz). But still, this is a good example on my real "topic of issue" here. It feels logical that sampling a bit lower would only introduce aliasing by "quantizing" very much approx-isch, but not -- like it really does here -- cut the entire audio at given frequency.

I've also studied the following sine waveform:



This is that 1Hz you were talking about. Bad example maybe, since 1Hz is the lowest addressable frequency in terms of sps. But heck, say you have a sharp "ess" tone of ~9Khz, and record using eg. 8000 Hz SR. The entire ess sound would fall off, right? Why is this? Any easy explanation? My logic tells me there should only me dithering/quantization aliasing or whatever, but not the entire sound fall off. This is what makes me a bit confused, I guess. Would be much delighted if you or anyone else had an easy explanation to why all this is the way it is!

Cheers!
Go to the top of the page
+Quote Post
AndyH-ha
post Mar 20 2011, 06:32
Post #6





Group: Members
Posts: 2224
Joined: 31-August 05
Member No.: 24222



The sample rate must be at least twice the highest frequency you wish to capture (or create). However, that just sets the upper limit on frequency, it says nothing about what frequencies are actually in the data.

The data is a collection of samples. Each sample is an amplitude measurement. Looking at that hypothetical sine wave, it is the distance (+ or -) between the center line (zero) and the height of the sine wave trace at the instant the sample was taken. The sample is an amplitude number. It contains no frequency information, only the amplitude value (which can be expressed in various units, such as volts or fractional parts of zero to (+/-) maximum).

The frequency comes from how much the sample values changes from sample to sample. A low frequency changes only a little from one sample to the next, a higher frequency changes by a greater amount. The total amount of change might be the same for different frequencies, but the time it takes (which is equivalent to the number of samples it takes) to make the change will be different.
Go to the top of the page
+Quote Post
gimgim
post Mar 20 2011, 07:01
Post #7





Group: Members
Posts: 33
Joined: 2-February 11
Member No.: 87871



> Now, what I don't understand is how audio actually disappear when pulling down sample frequency.

It doesn't. Let me clarify...

The Nyquist theorem says that in order to reconstruct a bandlimited signal of maximum frequency f, you have to sample at at least 2*f.
(I am oversimplifying a bit here, but this should be OK). I think you have this clear from what you said.

What happens when your signal is NOT bandlimited at f, is that frequencies above f will appear in the reconstructed signal as frequencies in (0-f).
This is what aliasing is.

Now, when with a (decent) program (such as ffmpeg) subsamples a signal, in order to avoid aliasing, it will always apply a low pass filtering first.
I believe this is why your signal disappears.

Go to the top of the page
+Quote Post
Soap
post Mar 20 2011, 10:49
Post #8





Group: Members
Posts: 1019
Joined: 19-November 06
Member No.: 37767



QUOTE (motion_blur @ Mar 19 2011, 19:54) *
To define a sine wave you need at least two sampling points, one at the maximum and one at the minimum of the wave.


This is incorrect in that you do not need to "hit" the max and min of the wave if you have filtered out frequencies above the nyquest limit. The "points" can fall anywhere.


--------------------
Creature of habit.
Go to the top of the page
+Quote Post
[JAZ]
post Mar 20 2011, 15:14
Post #9





Group: Members
Posts: 1798
Joined: 24-June 02
From: Catalunya(Spain)
Member No.: 2383



I believe your question is answered by now, but I would like to clarify some points for later reference.

QUOTE (Gew @ Mar 19 2011, 22:20) *
Telephone is 8KHz, i.e. it measures audio 8000 times per second, or 8 times per millisecond. Now, by theorem, these 8 samples/ms would consist of the lowest audio frequencies, i.e. 0-8000Hz


Telephone has a bandwidth of 4Khz (0..4000). This signal needs to be sampled (at least) at 8Khz.

You cannot separate sampling from the Nyquist law. Like motion_blur said, you need two samples for a period (If you look at the image you showed of a sampled sine wave, would you be able to draw it with only one point? You need at least two, one at the upper side, and one at the lower side).
This is why you need always at least to double the amount of samples.
(More about this on the next point)

QUOTE (Gew @ Mar 19 2011, 22:20) *
But _what_ is it that specifies that these 8 samples/ms wouldn't consist of [for example] 8 higher audio frequencies?


You should understand the correlation between the amplitude domain and the frequency domain. A frequency F equals the inverse of its period f=1/T . 1Khz = 1/1000seconds.
The period is the time elapsed to complete an entire cycle. (In the case of a sine wave, the time needed so that the whole sine wave is drawn).
Now, if we don't forget the Nyquist theorem, this means we need to sample twice as fast (In this case, sampling at 2Khz which is the same as saying a sampling period of 1/2000seconds).
If this is the point that confuses you, think of this in this way: The sampling period defines the time elapsed between each sample point that is captured or played. The audio period defines the elapsed time between a complete cycle, for which we said we need at least two samples.

If you wanted a 2Khz audio frequency inside a 2Khz sampled signal, you would only be able to sample half of its cycle, which translates in causing aliasing.
(Actually, this case is quite an extreme. The aliasing it would cause is a DC offset. More about this at the end)

QUOTE (Gew @ Mar 19 2011, 23:29) *
A tone of 8Khz "changes" 8 times each millisecond, therefor a sample rate of _at least_ 8Khz (well, technically 16Khz, since invoking Nyquist thing, but please let's put this aside for now, just to lay the basics straight) is needed to "be speedy enough" to catch all the waveform changes of this 8Khz tone.


With the information I said above, a 8Khz tone means a cycle period of 1/8000seconds, which requires at least a sample period of 1/16000 which is a sampling frequency of 16Khz.


QUOTE (Gew @ Mar 20 2011, 01:56) *
Now, what I don't understand is how audio actually disappear when pulling down sample frequency.


When resampling down, a resampler should do the same than an ADC. Concretely, a good resampler, when downsampling, first applies a lowpass filter at half the destination sample rate (half the sample rate, because of Nyquist). This is what removes the frequencies in order to avoid aliasing.


QUOTE (Gew @ Mar 20 2011, 01:56) *
This is that 1Hz you were talking about. Bad example maybe, since 1Hz is the lowest addressable frequency in terms of sps.


1Hz is not the smallest frequency representable. The smallest frequency repesentable is in fact 0Hz. A 0Hz signal is also called DC offset
For example a 0.5Hz signal means a cycle period of 1/0.5seconds = 2seconds. So you need two seconds of samples to represent it (Sampled at, at least 1Hz smile.gif).





Now, just an addenum about aliasing and its relation with sampling:


Aliasing is an undesired effect caused by sampling a signal where its highest (cycle) frequency is higher than half the sampling frequency and no lowpass filter is applied to prevent it.
This effect can be visually explained as "mirroring at half the sampling frequency". (The frequency bounces)

Sampling at 10Hz, we can get a max cycle frequency of 5Hz.

If we sample a tone of 6Hz, the sampled signal will contain an aliased signal at 4Hz.
If we sample a tone of 7Hz, the sampled signal will contain an aliased signal at 3Hz.
if we sample a tone of 10Hz (the same as the sampling frequency), the sampled signal will contain an aliased signal at 0Hz (DC offset).
If we sample a tone at 11Hz (yet, even higher), the sampled signal will contain an aliased signal at 1Hz. (Yes, 0Hz also bounces).

Now, the description in terms of periods:

Since the cycle period is smaller than the allowed one, the samples captured out of it don't contain the complete cycle. But it is still sampled if not filtered out. These incomplete samples still represent a signal, but the positions at which they occur make it appear as a different frequency.

Example:
(Using triangle signal for easier number representation)

Triangle at 16x audio frequency:
[0,0.25,0.5,0.75,1,0.75,0.5,0.25,0,-0.25,-0.50,-0.75,-1,-0.75,-0.5,-0.25]

Triangle at 4x audio frequency (Take each fourth sample of 16x):
[0,1,0,-1][0,1,0,-1][0,1,0,-1]

Triangle at 1.5x audio frequency (Take each twelveth sample of 16x):
[0,-1][0,1][0,-1]


As you can see, this is the same (except with inverse phase) than the signal sampled at 4x.
Go to the top of the page
+Quote Post
Notat
post Mar 20 2011, 17:46
Post #10





Group: Members
Posts: 581
Joined: 17-August 09
Member No.: 72373



QUOTE (Gew @ Mar 19 2011, 15:20) *
Been reading the following work, but too dumb(?) to know which paragraph(s) in which of the articles that explains the answer to this. A quotation would be dandy, if anyone here know exactly.

http://en.wikipedia.org/wiki/Sampling_(signal_processing)
http://en.wikipedia.org/wiki/Sampling_rate
http://en.wikipedia.org/wiki/Audio_frequency
http://en.wikipedia.org/wiki/Nyquist–Shann...ampling_theorem
http://en.wikipedia.org/wiki/Nyquist_frequency

It might be a bit difficult to digest but your question is addressed in the Undersampling article. This is linked from the Undersampling section of the first article you listed.

You are not dumb. Many of the technical articles on Wikipedia jump straight into the math without first providing essential context. Please don't anyone feel shy about improving any of these articles.
Go to the top of the page
+Quote Post
DonP
post Mar 20 2011, 23:07
Post #11





Group: Members (Donating)
Posts: 1477
Joined: 11-February 03
From: Vermont
Member No.: 4955



QUOTE (AndyH-ha @ Mar 20 2011, 00:32) *
The sample rate must be at least twice the highest frequency you wish to capture (or create).


Nope. The sample rate must be greater than twice the highest frequency you want to capture, not "at least."
At least according to Nyquist theorom. That may seem like a trivial difference, but it is critical.


Go to the top of the page
+Quote Post
AndyH-ha
post Mar 21 2011, 03:40
Post #12





Group: Members
Posts: 2224
Joined: 31-August 05
Member No.: 24222



It might be "critical" in some signal processing applications but is irrelevant in music or voice audio.
Go to the top of the page
+Quote Post
Canar
post Mar 21 2011, 04:52
Post #13





Group: Super Moderator
Posts: 3373
Joined: 26-July 02
From: To:
Member No.: 2796



QUOTE (Notat @ Mar 20 2011, 09:46) *
You are not dumb. Many of the technical articles on Wikipedia jump straight into the math without first providing essential context. Please don't anyone feel shy about improving any of these articles.
I want to second this. There is also Hydrogenaudio's wiki. There I can guarantee any primer you decide to try help others with will not disappear or be reverted. smile.gif

You are not "dumb" for wanting more knowledge and trying to fill in subjects that you don't know. You're smart for choosing to do so!


--------------------
You cannot ABX the rustling of jimmies.
No mouse? No problem.
Go to the top of the page
+Quote Post
DonP
post Mar 21 2011, 11:55
Post #14





Group: Members (Donating)
Posts: 1477
Joined: 11-February 03
From: Vermont
Member No.: 4955



QUOTE (AndyH-ha @ Mar 20 2011, 21:40) *
It might be "critical" in some signal processing applications but is irrelevant in music or voice audio.


Aren't A/D and D/A conversions always signal processing applications? laugh.gif

If your sampling frequency is exactly twice the frequency of a sine wave you want to represent, you will always sample it at the same phase angle and won't have any informaiton about the wave's amplitude. And of course the phase angles could be 0 and 180 degrees so then the samples would always be zero.

This post has been edited by DonP: Mar 21 2011, 11:56
Go to the top of the page
+Quote Post
AndyH-ha
post Mar 21 2011, 21:10
Post #15





Group: Members
Posts: 2224
Joined: 31-August 05
Member No.: 24222



You’re talking about a function approaching a limit, where smaller and smaller parts of a Hz make a larger and larger difference. This is quite meaningless for any audio use.

If one were trying to analyze some frequency that happens to be very near the Nyquist limit, it would be foolish to choose a sample rate that puts that frequency there. In any real circumstances, hardware or software, the filters would essentially eliminate that frequency. As the frequency approaches the Nyquist limit, its level is reduced markedly.

If you choose not to filter, aliasing would create a host of extra frequency components not part of the actual signal. Maybe you could think up some very specialized application where approaching that limit very closely could be relevant but I doubt it would be anything that ever enters the lives of very many people.
Go to the top of the page
+Quote Post
Glenn Gundlach
post Mar 21 2011, 21:25
Post #16





Group: Members
Posts: 372
Joined: 19-April 08
From: LA
Member No.: 52914



QUOTE (DonP @ Mar 21 2011, 02:55) *
Aren't A/D and D/A conversions always signal processing applications? laugh.gif

If your sampling frequency is exactly twice the frequency of a sine wave you want to represent, you will always sample it at the same phase angle and won't have any informaiton about the wave's amplitude. And of course the phase angles could be 0 and 180 degrees so then the samples would always be zero.


You're coming up with a contrived nonsense condition which would never happen in the real world unless it was well, contrived.

There is no relation between the audio frequencies an the sample rate. It's asynchronous (unless it's another contrived setup). Audio sampling is similar in concept to shooting movies. Play the movie faster or slower and the motion speeds up or slows down. The same happens in the audio sampling world. I did this in a 'contrived' setup long ago with an old PC sending audio to a DAC. When I disabled the handshake between the units and let the PC send data as fast as it could, it speeded up like playing a 33 rpm LP at 78. FWIW it was 1987, the PC was a 10 MHz '286 sending 8 bit audio at an 11 KHz sample rate. Running Borland Pascal it could get the data up to 30KHz running flat out but it proved the point in no uncertain terms.

Nyquist only comes into play when you're approaching 1/2 sample rate. 1 kHz sinewaves in a 44KHz sample world will have no issues at all. Aliasing sounds awful because the artifacts have absolutely no musical relation unlike harmonic distortion which does.

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 28th December 2014 - 03:52