Last weekend I was in Paris to meet a friend and we decided to visit the Musée des Arts et Métiers, which was hosting a very nice exposition on Claude Shannon “Le magicien des codes”.
It is impressive to see how much Shannon contributed to the world of communication, it seems that almost everything we do to communicate today, from writing a message on Facebook to calling a friend on Skype on the other end of the world or paying the bill with our bank card is the result of what he discovered years ago. Shannon is considered to be the father of information theory and a good amount of his work is included in his book “A Mathematical Theory of Communication”.
Here‘s a documentary on his life and impact from University of California Television. Among other things he influenced the field of boolean algebra, contributed to the concept of digitization and compression, that allow us today to stream videos, worked on speech encryption together with Alan Turing. He also in some way anticipated the ideas behind machine learning by building Theseus, an electrically controlled mouse that can find his way home by trial and error, as explained by Shannon himself in this video:
Well, of course Shannon has also been helped by a fascinating and inspiring working environment: the Bell Labs. The Bell Labs contributed with Shannon to the development of Information Theory, and also to the invention of the transistor, the laser, Unix, C, C++…just think that eight Nobel Prizes have been won by people working there.
Together with Shannon there was another well known researcher working at Bell Labs: his name was Harry Nyquist.
Nyquist is without doubt well known to the DSP community for the development of the Shannon-Nyquist theorem, that explains aliasing and defines the Nyquist frequency. He had to be quite revered alredy in the Bell Labs though, as testified by point 8 of this picture..
THE DAILY LIFE AT BELL LABS IS:
– The 20 to 30% of work time has to be devoted to a free project, chosen by the employee.
– Smart dress code is required.
– There are not personal profits: all the patents are sold for 1$ to Bell Labs.
– The leaders have a role of advisors: they cannot interfere in the work of their subordinates.
– It is forbidden to flirt with the secretaries!
– It is allowed to collaborated without referring to one’s superior.
– Everyone has to give a scientific explanation to anyone who demands it.
– Whoever produces the highest number of patents has the right to have lunch with Harry Nyquist, one of the stars of our Lab!
– The employees are loyal to Bell Labs: one stays there for all his or her career.
– Works schedules are often substantial.
While dreaming of a lunch with Harry Nyquist let’s then dive into the world of aliasing.
In order to record and digitize an analog signal we need to sample it. Sampling means that we check the value of that signal, we store it, and than we check it again after a certain period of time. We do not have any information regarding what happens between samples. If our sampling frequency, or sample rate, is not high enough in comparison to the highest frequency contained in our analog signal, we may experience aliasing.
“Aliasing” comes from the Latin word “alias”, meaning
ALIASING EXAMPLE WITH MATLAB
Let’s simulate a continuous signal sc composed of a simple sinusoid at a frequency f of 1000 Hz (I say “simulate” because of course nothing will ever be continuous in Matlab..).
% Number of points
NP = 50000;
% Signal length (s) -increase tmax if you want to hear a longer signal (but
% you will have a more dense graph.)
tmin = 0;
tmax = 0.01;
% Time axis
tc = linspace(tmin, tmax, NP);
% Frequency of the signal (Hz)
f = 1000;
sc = sin(2*pi*f*tc);
And let’s plot it:
Now, if we sample it at 44100 Hz, which is the most common sample rate for audio, we can clearly see that we have enough points to represent the signal.
% Sample rate (Hz)
Fs1 = 44100;
% Sampling period
Ts1 = 1/Fs1;
% Time line
t1 = tmin:Ts1:tmax;
s1 = sin(2*pi*f*t1);
In Matlab you can also play the signal to listen to the frequency:
% Playing the resulting frequency
You can listen to it here:
Let’s now sample at a lower sample rate, for example 1500 Hz.
% Sample rate (Hz)
Fs2 = 1500;
% Sampling period
Ts2 = 1/Fs2;
% Time line
t2 = tmin:Ts2:tmax;
s2 = sin(2*pi*f*t2);
We can notice that there are not enough points to represent the signal:
There are many signals that could be represented by sinusoids passing through these orange points! It could be a signal at 500 Hz, 1500 Hz, 2000 H, 2500 Hz and so on. In this case the 1000 Hz original signal will be aliased and we will hear a 500 Hz signal, because 500 Hz lower than the Nyquist frequency (1500 Hz / 2 = 750 Hz):
If you listen to the signal with soundsc you will hear indeed a 500 Hz frequency.
You can also listen to it here:
You can download or have a look at the Matlab .m file on aliasing that I created here.
Just to give you now a more musical example, I took the most famous bit of Der Hölle Rache and created an aliased version of it. As you probably know, the highest note in this aria is an F6, which corresponds to a frequency of 1396.91 Hz. By sampling at a frequency of 2756 Hz, which is lower than the Nyquist rate, the F6 will be aliased. We’ll hear a frequency of 1359 Hz instead, which sounds already a bit like an E6, a nightmare for singers trying to sing this aria!
Here you can listen to the original 44100 Hz sampling rate version:
And here you can enjoy (or probably not) the aliased version:
*DISCLAIMER: this may be really hurting to hear if you love this piece*
Conclusion: choose carefully your sampling rate when recording!
You can download here the Matlab script used to obtain an aliased Der Hölle Rache.
(Edda Moser (s), Queen of the Night)