Demonstration 1: Sampling, Aliasing, and Frequency Response, Part 1

Flash and JavaScript are required for this feature.

Download the video from iTunes U or the Internet Archive.

Topics covered: Sampling and aliasing with a sinusoidal signal, sinusoidal response of a digital filter, dependence of frequency response on sampling period, periodic nature of the frequency response of a digital filter.

Instructor: Prof. Alan V. Oppenheim

The following content is provided under a Creative Commons license. Your support will help MIT OpenCourseWare continue to offer high-quality educational resources for free. To make a donation or view additional materials from hundreds of MIT courses, visit MIT OpenCourseWare at ocw.mit.edu.

[MUSIC PLAYING]

ALAN OPPENHEIM: In This lecture, I would like to demonstrate the effects of sampling and aliasing, and also, some of the properties of discrete time linear systems. What we'll be using to demonstrate this is a programmable digital filter, which is contained in this box, programmable in the sense that many of the parameters of the filter-- for example, the filter coefficients, the coefficient and arithmetic word length, the sampling rate etc, are easily changed. In other words, programmable.

So this is the basic digital filter. And then, of course, we have some associated equipment to help us with the demonstration. Well, we'll be returning to this filter in a few minutes, when, together with my colleagues, Mike Portnoff and Dave Harris, I'll be demonstrating several of the ideas that we're about to talk about.

But first of all, let me explain what the basic setup is. The programmable digital filter consists, essentially of a system which is a sampler, a continuous time, or C to D converter, which converts an impulse train to a sequence, a digital filter to obtain a filtered output sequence, a "discrete time to time" converter to convert the sequence back to an impulse train, and finally a D-sampling or smoothing low-pass filter.

So at this point, we have a continuous time input. At this point, we have a continuous time impulse train, at this point, a sequence, then a sequence here, an impulse train, and back to a smooth, continuous time function. For the first part of the demonstration, what I would like to focus on is just simply the effects of sampling and aliasing. And so for the first part, I'll just simply choose this digital filter to be an identity system. In other words, the impulse response of this system is just simply an impulse.

In that case, this overall system collapses to a somewhat simpler system, as I have on this next viewgraph where we convert from a continuous time input to a sequence and then back to the continuous time input. And, in fact, we could really collapse the A to D or C to D converter and D to A converter together since we're simply converting from an impulse train to a sequence and then back to the same impulse train. To see what the effect of this system is in both the time domain and frequency domain, we can look at the associated time waveforms and spectra.

On the left-hand side, we have the associated time wave forms and sequences. On the right-hand side, the associated Fourier transforms. So we can think of an input continuous time function, which is of some general form, with a band-limited spectrum-- band-limited from minus omega c to plus omega c. When we sample this to obtain the impulse train with a sampling period of capital T the associated spectrum is then a periodic replication of this band-limited spectrum. So we have the Fourier transform of x of a of t. Then the same thing reproduce that multiples of 2 pi over capital T

When we then convert this to a sequence, that implies a frequency normalization, a normalization of the frequency axis, so that this periodicity gets converted to a periodicity with a period of 2 pi in the digital frequency variable small omega. Otherwise, the general shape of the Fourier transform stays the same. We then go back through the system, converting. Back to an impulse train and then finally, by low-pass filtering, we extract just the one replication of the original Fourier transform. And what we would recover is x of a of j omega. We would recover this exactly provided that the bandwidth is small enough compared with the sampling frequency.

If, on the other hand, omega sub c is too large in relation to the sampling frequency, then what we end up with is an interaction between these two pieces of the Fourier transform. And that interaction is what's referred to as aliasing.

The effect aliasing is most easily understood in terms of a simple example, namely a sinusoidal input. So let's consider, specifically, what happens with the spectra in the case of a sinusoidal input. Here, we have an input cosine omega 0t, an assumed sampling rate of 2 pi over capital T. This then is the Fourier transform of this sinusoid or cosine. After sampling, that is just simply periodically repeated with a period equal to the sampling frequency.

And we see that if omega 0, the input frequency is low enough, then the original spectrum, or Fourier transform, falls within the passband of the low-pass filter. This dashed line corresponds to the frequency response, an ideal frequency response, associated with the D-sampling low-pass filter. And, of course, if the spectral fall, as I've shown in here, then there is no aliasing. In other words, what we recover at the output of the low-pass filter is just simply the original Fourier transform, or equivalently, the original signal.

Now, let's consider, on the other hand, the effect of increasing omega 0, the input frequency, and we can think in particular of what the effect is on each one of these impulses in the Fourier transform. As omega 0 increases, this impulse moves to the right, this impulse moves to the left. And likewise, in the periodic replications, this impulse moves down in frequency. This impulse moves up in frequency, etc.

Now, if omega sub s minus omega 0 is greater than omega 0, then these two impulses haven't crossed. However, if omega sub s minus omega 0 is less than omega 0, then the situation that we have is what I've illustrated here, where now, the impulses that lie in the passband of the filter are at the frequency omega sub s minus omega 0 rather than at the frequency omega 0. So as we think of increasing the input frequency, what happens for a while, is that the output frequency will correspondingly increase.

But after we've increased omega 0 past this point, then the output of the low-pass filter will decrease in frequency because it's taken on the alias of a new frequency or a new sinusoid. And so the output, in, that case is cosine omega sub s minus omega 0. And there's a little t over here.

There is-- I want to demonstrate this effect. There is another effect that we'll observe in the process of demonstrating this, because of the fact that in any real-world situation, in fact, this low-pass filter is not going to be an ideal low-pass filter, as I've shown here but in fact, is going to have some transition with associated with it. And so as omega 0 and omega sub s minus omega 0 get very close in frequency, in essence, both of them are having some influence on the output because of the fact that there isn't infinite attenuation of one of the impulses an exact replication of the other. So what we'll see in that case, as we get an input frequency which is close to half the sampling frequency, will see, in addition to the effective aliasing that we want to demonstrate, we'll see an effect which, essentially, is a beating phenomenon.

So let's move over to the digital filter and demonstrate these effects, where I remind you now that this filter, the digital filter aspect of it, is just simply an identity system so that it corresponds to sampling, and then simply sampling and low-pass filtering. What we have as an input, if we look at the oscilloscope, is on the upper trace, the input sinusoid, on the lower trace, the output sinusoid. And as we see it right now, the input sinusoid has chosen to be low enough frequency so that, in fact, there is no aliasing.

Well, let's now increase the input frequency. And what we'll observe is that the output frequency increases likewise. The output frequency is still equal to the input frequency.

We're now getting into the vicinity of half the sampling frequency so that what we're beginning to see now in the output is not just a sinusoidal output. But in fact, what we see are the two components. In other words, we see the beating effect due to the fact that the low-pass filter is not an ideal low-pass filter.

Now what we want to observe as we sweep past half the sampling frequency is the aliasing effect-- in other words, the fact that the output sinusoid will decrease in frequency. Let's first sweep back down to DC. So the output sinusoid follows the input sinusoid. And then we'll sweep automatically from 0 up to the sampling frequency. And let's see that.

So on the bottom trace is the output sinusoid. The top trace is the input sinusoid. Were now in the vicinity of half the sampling frequency. We're now past half the sampling frequency. And you see that the output is decreasing in frequency while the input was increasing.

Let's finally look at that again. But this time, let's also listen to the output sinusoid. And what you'll hear, in addition to observing this on the bottom trace of the scope, is the fact that the output frequency first increases, and then decreases, even though the input frequency is continuing to increase. So let's do that again. But now, in this case, let's listen to the output.

[SOUND WAVES RISE AND LOWER]

OK, now what we would now like to consider is the effect of actually carrying out some digital filtering in-between the sampling and D-sampling. And so let me return to the basic system again where we had previously removed this digital filter. And now, what we want to consider is the effect of the overall system, when we, in fact, insert an interesting, or a more interesting, digital filter in the middle.

The digital filter that we're going to insert is a low-pass filter. And the impulse response of the low-pass filter, or the unit sample response of the low-pass filter, is, as I've shown up here. And it's a symmetric unit sample response. And consequently, it corresponds to a linear phase filter.

The associated frequency response I show down here, where this is now the filter passband. This is the filter stop band. And, of course, there is some ripple. There is an infinite attenuation in the stopband.

And I remind you of the fact that, of course, the digital filter frequency response must, by necessity, be periodic with a period of 2 pi. The cutoff frequency associated with the particular filter that we want to demonstrate is pi over 5, or one tenth of 2 pi. And the factor one tenth is a factor that I'll want to refer to again shortly.

Now, the overall system, of course, is a continuous time system. In other words, we have a continuous time input. We have a continuous time output. And the question then is, what is the equivalent continuous time system in relation to the digital filter frequency response that we have illustrated here? In other words, what is the equivalent frequency response of the corresponding continuous time system?

We can answer that by simply referring to the basic definition of frequency response for the continuous time case and frequency response for the discrete time case. In the continuous time case, for a linear time invariant filter, the frequency response is defined as the gain change applied to a complex exponential. So if we consider a complex exponential as the input, then the output of the system is a complex exponential at the same complex frequency, but with an amplitude, which is equal to the frequency response of the system at that frequency.

Likewise, for a discrete time system, we can consider a complex exponential input at a frequency small omega. And the output is a complex exponential at the same complex frequency, with an amplitude change, which is the frequency response of the digital filter, or discrete time filter, again evaluated at that frequency. Well, simply from these definitions, we can trace our way through the system and see fairly easily what the equivalent analog, or continuous time filter frequency, response is.

Let's consider the overall system. And let's choose an input, which is a complex exponential. And we'll choose the complex exponential carefully to avoid aliasing.

We then sample this complex exponential and convert that to a sequence. And the sequence values are there for e to the j omega and capital T. Well, this is just the discrete time complex exponential with a frequency of capital omega times capital T. So the output of the digital filter is a complex exponential with the same complex frequency, capital omega times capital T, with an amplitude, which is the frequency response of this filter evaluated at the frequency of the input-- In other words, evaluated at capital omega times capital T.

Then we convert that back to an impulse train, and finally, low-pass filter. And the output of the low-pass filter then has the same amplitude, but now multiplying a continuous time complex exponential at the original input frequency. So simply from the definition comparing this to the input from the definition of the continuous time frequency response, the continuous time frequency response is equal to this term. In other words, it's the frequency response of the digital filter, but with a rescaling of the frequency axis-- in other words, with the digital frequency variable small omega replaced by capital omega times capital T.

The consequence of that for the particular digital filter that we're talking about-- or, in fact, for any digital filter-- is that the continuous time filter frequency response has the same shape as the digital filter frequency response, but has a rescaled frequency axis-- rescaled according to this scaling. And in essence, what the rescaling corresponds to-- and I think you can verify this on your own-- is to reconvert or rescale the frequency 2 pi in small omega to the sampling frequency in large omega. And the upshot of all of this, is that this cutoff frequency, which in a digital filter is a pi over 5, is now rescaled to pi over 5 capital T.

And what we would observe is that as capital T, the sampling period changes, then the bandwidth, or the cutoff frequency, of the continuous time filter changes also. So let me remind you of the fact that the digital filter had a cutoff frequency which was 1/10 of 2 pi. 2 pi gets rescaled to the sampling frequency in the continuous time domain. And the filter cutoff frequency will then get rescaled to one tenth of the filter sampling frequency.

Let's illustrate some of these effects with the digital filter. What we have, as I said was, is a low pass filter impulse response and frequency response. First let's look at the impulse response of the filter of the overall system-- in other words, after the D-sampling low-pass filter. What we see here is the impulse response of the overall system. And we observe, for one thing, that it's a symmetrical impulse response-- in other words, corresponds to a linear phase filter.

We can also look at the impulse response before the D-sampling low-pass filter. Lets take out that the D-sampling low-pass filter slowly. And what we observe is basically the output of the digital-to-analog converter, which, of course, is a staircase or boxcar function, not an impulse train.

In the real world, the output of a [? D-day ?] converter generally is a boxcar type of function. We can put the D sampling filter back in now. And notice that the effect of the D-sampling filter is basically to smooth out the rough edges in the boxcar output from the [? D-day ?] converter.

All right, now what we'd like to demonstrate is the actual frequency response of the overall continuous time filter. And we can do that by sweeping the system with a sinusoidal input. And what we expect to see, of course, is as the sinusoidal input frequency gets past the effective cutoff frequency, then the output sinusoid is greatly attenuated. Let's now sweep the filter frequency response. And there is the filter cutoff frequency.

We can demonstrate the filter characteristics in several other ways. One way is to choose, as a display, instead of the output as a function of time, we can display the output sinusoid as a function of frequency. And so we'll observe that on the left-hand scope, while on the right-hand scope, we'll have the same trace that we just saw, namely two traces the upper trace as the input sinusoid, the lower trace as the output sinusoid. And in addition to observing the frequency response, let's also listen to the output sinusoid and observe the attenuation in the output as we go from the filter passband to the filter stopband. Again, a 20-kilohertz sampling rate and a sweep range from 0 to 10 kilohertz.

[SOUND WAVES RISE]

Now, of course we're in the filter stopband. Now, if we increase the sweep range from 10 kilohertz to 20 kilohertz so that the sweep range is equal to the sampling frequency, in essence, that corresponds to sweeping out the digital filter from 0 to 2 pi. And in that case, we'll begin to see some of the periodicity in the digital filter frequency response. So let's do that now with a 20-kilohertz sampling rate and a sweep range of 0 to 20 kilohertz.

[SOUND WAVES RISE AND FALL]

Now we come near 2 pi, we get back into the passband, and finally, back to a 0- to 10-kilohertz sweep so they were again, sweeping only from 0 to pi with regard to the digital filter.

[SOUND WAVES RISE]

OK, now, what we would like to demonstrate is the effect of changing the sampling frequency. And we know that the sampling-- that the effective filter cutoff frequency is tied to the sampling frequency, and for this particular filter, corresponds to a tenth of the sampling frequency. Consequently, if we double the sampling frequency, we should double the effective filter passband width or double the filter cutoff frequency. And so let's do that now. Again, a 0 to 10 kilohertz sweep range, but a 40-kilohertz sampling frequency.

[SOUND WAVES RISE]

And we should observe that the filter cutoff frequency has now doubled out to 4 kilohertz. Now let's begin to decrease the filter sampling frequency. So from 40, let's change the sampling frequency to 20 kilohertz. And we should see the cutoff frequency cut in half.

[SOUND WAVES RISE]

Now we can go even further. We can cut the sampling frequency down to 10 kilohertz. And remember that the sweep range is 0 to 10 kilohertz. So now we'll be sweeping from 0 to 2 pi.

[SOUND WAVES RISE]

So as we get close to 2 pi, we'll see the passband again.

[SOUND WAVES FALL]

And now, let's cut down the sampling frequency even further to 5 kilohertz.

[SOUND WAVES RISE]

Here we are at 2 pi.

[SOUND WAVES RISE]

And then at 4 pi.

[SOUND WAVES FALL]

Now finally, let's demonstrate this effect of changing the effective filter cutoff frequency by changing the sampling rate by carrying out some low-pass filtering on some live audio. And we'll demonstrate this by listening to the audio, and also, observing the audio on on a single trace, namely, the time waveform. And we'll begin it with a sampling frequency of 40 kilohertz, change that then to 20 kilohertz, 10 kilohertz, 5, and then 2 and 1/2, corresponding to a filter cutoff frequency then of 4 kilohertz, then 2 kilohertz, then 1 kilohertz, then 500, , 250 etc.

So let's begin 40 kilohertz. And then we'll work our way down.

[MUSIC PLAYING]

Now, let's reduce that to a 20-kilohertz frequency or a 2-kilohertz filter.

[MUSIC PLAYING]

And 10 kilohertz sampling frequency.

[MUSIC PLAYING]

And finally, a 5-kilohertz sampling frequency corresponding to make 500-cycle equivalent analog filter.

[MUSIC PLAYING]

All right, now let's finally conclude by returning to a little higher quality ragtime by changing the sampling rates back to 40 kilohertz.

[MUSIC PLAYING]