For starters, we must realize that any signal can be represented by an infinite sum of single tones of the right amplitude and phase. This is a fundamental principle upon which all signal processing is based. Problems arise, like in many areas of life, when reality hits the theory... In this case, it's impossible for a real system to have infinite frequency response, sampled or not, and of course getting all those tones' amplitudes and phases just right when we add them up is a real problem. Sampling means we only have a limited bandwidth to work with, so the number of frequencies we can sum is fixed by the fundamental signal frequency and the sampling frequency.

A square wave is comprised of an infinite sum of only odd harmonics of the signal. That is, a 1 kHz square wave includes 1 kHz, 3 kHz, 5 kHz, and so on out to infinity. No even harmonics! The amplitude of the odd harmonics decreases as the ratio 2/(n*pi) where n is the harmonic number and pi = 3.14159... (that old circle number). So, the third harmonic is only 1/3 the amplitude of the fundamental, the fifth is 1/5, etc. It doesn't take a whole lot of harmonics before we can't really see much difference between an ideal square wave and one with only a few components. Digital systems routinely work with limited bandwidth to reduce noise. Noise just keeps getting larger as you increase the system bandwidth, so it makes sense to use as little bandwidth as required to capture the signal and thus maximize the SNR.

For this example, I went back to a 1 kHz signal, and started added harmonics as required to build a square wave. The top plot is the 1 kHz sine wave, a nice single tone. I added a bit of 3rd harmonic, and you can see the top is already starting to flatten. Added in the 5th, and it actually starts to look like a square wave! As I add the 7th and 9th harmonic terms, it looks like the flat top ripple is a little worse, but the edges are starting to shape up now. By the time I add in the first 11 terms we have a pretty decent square wave. The bottom curve is the first 101 terms (fundamental plus 100 harmonics) and is about as close to a perfect square wave as made sense to me to plot.

This next plot shows the single (fundamental) 1 kHz tone and sums to the 3rd, 5th, and 101st harmonic. You can see that even with only 5 terms the edges are nearly as fast as using 101, at least to the eye (and usually to the ear as well).

What does this mean? Well, there aren't many square waves in music, but there are a lot of harmonics. If we

*were*to reproduce a square wave, and decide we need at least 5 terms, then the highest square wave we can produce on a CD is about 20 kHz/5 = 4 kHz.

Hope this is useful! - Don