This session is an introduction to sampling theory. It reviews the important ideas that pertain to sampling but leaves the detailed mathematics for your further study.
The material in this presentation and notes is based on Chapter 15 of Benoit Boulet, Fundamentals of Signals and Systems from the Recommended Reading List and you'll find the mathematical treatments there. There is much more detail in Chapter 9 of Steven T. Karris, Signals and Systems: with Matlab Computation and Simulink Modelling, 5th Edition from the Required Reading List.
We will be using an adaptation of a pair of demo scripts to illustrate alialising. These scripts were published by Prof. Charles A. Bouman, School of Electrical and Computer Engineering, Purdue University as part of the course materials for ECE438: Digital Signal Processing.
I need a volunteer to provide a sound sample ....
open sampling_demo
What will the bit-rate be for playback?
What is going on here?
Sampling can be modelled as the multiplication of a continuous-time signal by a sequence of periodic impulses as illustrated here.
This is a form of modulation
$T_s$ is the period of the periodic sampling function.
Multiplication in time domain is convolution in the frequency domain
$\omega_s$ is the frequency of the periodic sampling function = $2\pi/T_s$.
The Sampled signal:
$${x_s}(t) = \sum\limits_{k = - \infty }^{ + \infty } {x(k{T_s})\delta (t - k{T_s})} $$
Frequency convolution: $${X_s}(\omega ) = \frac{1}{{{T_s}}}\int_{ - \infty }^{ + \infty } {X(\upsilon )} \sum\limits_{k = - \infty }^{ + \infty } {\delta (t - \upsilon - k{\omega _s})} \,d\upsilon $$
Sampling property:
$${X_s}(\omega ) = \frac{1}{{{T_s}}}\int_{ - \infty }^{ + \infty } {\sum\limits_{k = - \infty }^{ + \infty } {X(\omega - k{\omega _s})} } \delta (t - \upsilon - k{\omega _s})\,d\upsilon $$
Sifting property:
$${X_s}(\omega ) = \frac{1}{{{T_s}}}\sum\limits_{n = - \infty }^{ + \infty } {X(\omega - k{\omega _s})}$$
Gives a sufficient condition to recover a continuous time signal from its samples $x(nT_s)$, $n$ is an integer.
Sampling Theoreom
Let $x(t)$ be a band-limited signal with $X(\omega) = 0$ for $|\omega|>\omega_M$.
Then $x(t)$ is uniquely determined by its samples $x(nT_s)$, $\infty <n < +\infty$ if
$$\omega_s > 2\omega_M,$$
where $\omega_s = 2\pi/T_s$ is the sampling frequency.
This is of course theoretical only!
Basic set up
clear all
w0 = 1; % fundamental frequency rad/s
t0=2*pi/w0; % period s
tmax = 1.5*t0; % plotable range
We will use a system with an underdamped second-order response.
The transfer function is: $$H(s) = \frac{\omega_0^2}{s^2 + 2\zeta\omega_0 s + \omega_0^2}$$
syms s t
zeta = 0.3;
H = w0^2/(s^2 + 2*zeta*w0*s + w0^2)
H = 1/(s^2 + (3*s)/5 + 1)
h = ilaplace(H)
h = (10*91^(1/2)*exp(-(3*t)/10)*sin((91^(1/2)*t)/10))/91
t = linspace(0,tmax,100);
xc = eval(h); % eval evaluates a symbolic expression as a Matlab command.
tc = t;
plot(tc,xc)
title('Fig 1: Continuous Time Signal x(t)')
ylabel('x(t)')
xlabel('Time t [s]')
ws = 4*w0; % twice minimum!
Ts = (2*pi)/ws;
t = 0:Ts:tmax;
xs = eval(h);
td = t;
stem(td,xs)
hold on
plot(tc,xc,'r:')
hold off
title('Fig 2: Sampled Signal x_s(t)')
ylabel('x_s(t)')
xlabel('Time t [s]')
Problem
In the frequency domain, the ideal way to reconstruct the signal would be to construct a chain of impulses $x_s(t)$ and then to filter this signal with an ideal lowpass filter.
In the time domain, this is equivalent to interpolating the samples using time-shifted sinc functions with zeros at $nT_s$ for $\omega_c = \omega_s$.
Signal reconstructed with sinc function
stem(td,xs)
hold on
x = zeros(length(td),length(tc));
for k=1:length(td)
xk = xs(k);
sincx = xk*sin(pi*(tc - td(k))/Ts)./(pi*(tc - td(k))/Ts);
x(k,:) = sincx;
end
plot(tc,x,'-.')
hold off
title('Fig 5: Signal x(t) reconstructed with sinc functions')
ylabel('x(t)')
xlabel('Time t [s]')
Obtained by summing all the sinc functions
plot(tc,sum(x),tc,xc,'r:')
title('Fig 6: Reconstruction with sinc functions')
ylabel('x(t)')
stairs(td,xs)
hold on
plot(tc,xc,'r:')
title('Fig 3: Signal x(t) reconstructed with zero-order-hold')
ylabel('x(t)')
xlabel('Time t [s]')
plot(td,xs,'bo-',tc,xc,'r:')
title('Fig 4: Signal x(t) reconstructed with first-order-hold')
ylabel('x(t)')
xlabel('Time t [s]')
Aliasing Occurs when the sampling frequency is too low to ovoid overlapping between the spectra.
When aliasing occours, we have violated the sampling theorem: that is $\omega_s < 2\omega_m$.
When aliasing occurs, the original signal cannot be recovered by lowpass filtering.
We use the recording made at the start and run it through a script that effectively aliases the original signal be reducing the sampling frequency to less than half the original sampling frequency.
Here's the script: aliaseg1.mlx that I'll be using. (Also available as an m-file aliaseg1.m)
open aliaseg1
Assume signal $x(t)=\cos(\omega_0 t)$ is sampled at a rate of $\omega_s = 1.5\omega_0$, violating the sampling theorem.
open aliasing
We can see the effect on the plot below:
Image generated by aliasing.mlx (Also available as aliasing.m).
Most real signals are not band-limited so we have to artificially make them bandlimited using an anti-aliasing filter.
An anti-aliasing filter is a low-pass filter whose cutoff frequency is lower than half the sampling frequency.
This can produce some distortion at high-frequencies but this is often better than the distortion that would occur at low frequencies if aliasing was allowed to happen.
For more on this topic see Pages 551—552 of Boulet.
This example uses anti-aliasing to downsample the audio. You should hear that the sound is less distorted as we sample below the sampling frequency of 8 kHz.
Script: aliaseg2.mlx (Also available as an m-file aliaseg2.m)
open aliaseg2
Human beings can hear sounds with frequencies up to around 20 kHz so when recording music in the modern sound studio (or phone or PC for that matter) the audio signal is antialiased with a 22 kHz filter. The signal is then sampled at 44.1 kHz before being stored for later processing and/or playback.
In modern signal processing and digital communications many of the operations that were once done in continuous time are now done entirely in discrete time.
For example, we can implement sampling and modulation in discrete time.
We can also upsample (interpolate between samples) or downsample (reduce the number of samples in a discrete-time signal)
These topics are left to you for further study.
Next session
bit rate = [number of samples per second] x [number of bits per sample] x [number of channels]
bit rate = $8192 \times 8 \times 1$ bits/second [baud]
bit rate = $65,536$ bits/second