Finite-Bandwidth Square Wave in Samples

After introducing the finite-bandwidth square wave in a previous article, I’ll show in this one how such a square wave looks in a digital system, so in sampled form. The figure below shows one period of a square wave of 1 kHz, sampled at 44.1 kHz, a widely used standard sampling rate for audio.

Square wave with harmonics 1, 3, 5, …, 19Square wave with harmonics 1, 3, 5, …, 19

If these “dancing dots” are reproduced by a bandwidth-limited system (using a digital-to-analog converter or DAC), they will produce exactly the waveforms from the illustration in the mentioned article.

Reproducing the Analog Signal

How can you compute the analog signal that will result from the given samples if these are reproduced by a bandwidth-limited system? The theoretical answer is given by the Whittaker–Shannon interpolation formula,

\[x(t) = \sum_{n=-\infty}^{\infty} x[n] \cdot {\rm sinc}\left(\frac{t - nT}{T}\right).\]

Here, \(x[n]\) is the digital signal, \(T\) is the sampling period, and \(x(t)\) is a continuous function that represents the analog signal. For each time point \(t\), the infinite sum computes the value of the signal at that time point by combining the complete digital signal with the sinc function. As is typical in signal processing, the normalized sinc function is used here, defined as

\[{\rm sinc}(t)=\frac{\sin \pi t}{\pi t}.\]

The Whittaker–Shannon interpolation formula is more of a theoretical construct, since it has infinite delay. This is because the complete signal is combined with the sinc function, which does not go to zero very quickly. However, I’ll use it anyway, as an approximation. To create this approximation, I’ve computed the analog waveform on five periods of the sampled square wave, and assumed the (sampled) signal to be zero otherwise. The image below shows the top part of the middle period.

Part of interpolated square wavePart of interpolated square wave

The blue dots are the digital signal, the blue line is the interpolated signal, and the red line is the theoretical bandwidth-limited signal, which is mostly hidden behind the blue one. The small deviations between the blue and the red line are there because only five periods of the sampled square wave were used, while the theoretical (red) signal assumes an infinite length square wave. In practice, a windowed version of the interpolation formula has to be used, but that is for a future article.

Submitted by Tom Roelandts on 15 October 2013

Add new comment