Fundamentals of Data Representation: Nyquist-theorem

From Wikibooks, open books for an open world
Jump to: navigation, search

UNIT 1 - ⇑ Fundamentals of Data Representation ⇑

← Sound compression Nyquist-theorem Sound synthesis →


We have seen the various ways that you can reduce the size of files, we have also seen that humans have a limit to the frequencies that they can perceive, so what sampling rate would be needed to only store the samples that humans can perceive. The full range of human hearing is between 20 Hz and 20 kHz.

Extension: Human hearing limit

People are able to hear different frequencies, up to what level can you hear?

For x = 0 To 25
	Console.WriteLine("Can you hear: " & x * 1000 & "Hz?")
	Console.Beep(x * 1000, 500)
Next

You lose your hearing with age, so the older you are the less likely you are to be able to hear the full spectrum.

So why not just use 20kHz as our sampling rate record 20k cycles per second and be done with it? There is a small problem:

Cycle - A complete oscillation (up and down) in a sound wave


Period - The time that a wave takes to oscillate one cycle.


Frequency - The number of waves passing a point per second


we are going to try and sample this sound that shows 3 cycles
taking one sample per cycle leads to a straight line! We're going to need more samples
taking 1.5 samples per cycle leads to a skewed representation

What we need to properly represent a sound wave is to sample it at least two times per cycle:

2 samples per cycle gives us a close representation of the sound

Therefore the minimum sampling rate that satisfies the sampling for the human ear is 40 kHz (2*20kHz). The 44.1 kHz sampling rate used for Compact Disc was chosen for this and other technical reasons.

Nyquist's theorem - the sample rate should be at a frequency which is at least twice the value of the highest frequency in the sampled signal


Shannon's version of the theorem states:[1]

If a function x(t) contains no frequencies higher than B Hz, it is completely determined by giving its ordinates at a series of points spaced 1/(2B) seconds apart.

We can relate Frequency and period together using this equation. This equation will be very useful for working out the sample rate of a given wave.

  \text{frequency (f)} = \frac{1}{\text{Period (T)}}

What happens when you have a graph of time against displacement?
We know that Nyquist's Theorem is that the sample rate should be double than the highest frequency. So to calculate the sample rate,

  1. Work out the period by looking at the time taken for one complete oscillation.
  2. Work out the frequency
  3. Work out the sample rate with this:
  \text{sample rate} = 2 \times \text{freqency(f)}
  • TIP - sometimes the period is hard to determine in one go as it may not cross an easily readable point on the axis.
    • To Compensate, you can go to where it does cross the axis at a readable point, then divide by how many oscillations have occurred from 0 to the time
Exercise: Nyquist-theorem
Describe Nyquist's-theorem

Answer :

You should set the sample rate at a frequency which is at least twice the value of the highest frequency in the sampled signal
For a sound sample of maximum frequency 16kHz what should the sample rate be?

Answer :

32kHz
How many cycles per second in the following sample?

For the sample what should the sample rate be according to nyquist's-theorem?

CPT-sound-nyquist-thereom-question.svg

Answer :

the sample has a frequency of 4 cycles per second. using Nyquist's theorem you would have to sample this at at least 8Hz

References[edit]

  1. C. E. Shannon, "Communication in the presence of noise", Proc. Institute of Radio Engineers, vol. 37, no. 1, pp. 10–21, Jan. 1949. Reprint as classic paper in: Proc. IEEE, vol. 86, no. 2, (Feb. 1998)