Not so hip to be square
There seems to be a fair bit of confusion about trying to reproduce square waves using bandwidth-limited systems (and face it, all audio systems are bandwidth-limited), so I decided to try to write up some basic things that hopefully will help clear some of the confusion.
As we know, a square wave is the sum of all odd harmonics, according to the formula
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/dc1ca9de7f258a89d3c579f55d29ed05.png.93746a73f3387dae706cd0249e50e77a.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28170" src="https://audiophilestyle.com/uploads/monthly_2013_06/dc1ca9de7f258a89d3c579f55d29ed05.png.93746a73f3387dae706cd0249e50e77a.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
By the way, that formula has nothing to do with Fourier analysis - it is just the sum of a bunch of sine waves, so the only operation we use is addition.
To perfectly reproduce the square wave, infinite bandwidth is required, so we will never get a perfect square wave.
Here is a square wave built up from harmonics 1-99 (So if the fundamental was at 1 KHz, this square wave would require a system capable of reproducing 100 KHz):
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square99.png.aa382256a46a72bcbe0b06cf578e9111.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28171" src="https://audiophilestyle.com/uploads/monthly_2013_06/square99.png.aa382256a46a72bcbe0b06cf578e9111.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
Not too shabby, right?
OK, what happens when we lower the bandwidth? Here is the same wave, but with an upper limit of 20 KHz, so only the harmonics 1-19 are included:
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square19.png.edc3a5207034ec28f7acf150284048b3.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28172" src="https://audiophilestyle.com/uploads/monthly_2013_06/square19.png.edc3a5207034ec28f7acf150284048b3.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
As we can see, we now have a ripple caused by the harmonics above the 19th missing from the supposedly infinite sum. Some people might think it is ringing caused by the DAC filter, but note that so far we haven't applied any filter. The ripple is totally natural consequence of the fact that the higher harmonics that would "smooth out" the square wave are missing (and note that the ripple frequency is at 21 times the fundamental, so above the 20 KHz human hearing range). This actually has nothing to do with digital - we could use a bank of analog sine wave generators feeding an analog mixer, and use a tape deck as our bandwidth-limited channel.
Here is the same approximate square wave again, but showing the missing harmonics - exactly the difference between the approximation and the ideal square wave:
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/squareripple.png.a6c99d84af93ea432deb799f26656557.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28173" src="https://audiophilestyle.com/uploads/monthly_2013_06/squareripple.png.a6c99d84af93ea432deb799f26656557.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
Now, does this have anything to do with how it sounds? No, not really. The "squareness" of the square wave is purely a visual thing - and our ears don't care about visual squareness. To illustrate this, let's shift the phase of the harmonics by 180 degrees (180 degrees of harmonic 3 corresponds to 60 degrees of the fundamental), a change that is pretty much inaudible to the ear:
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/squarephase.png.d87210d4a9656fdcc54d1de3ccc75592.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28174" src="https://audiophilestyle.com/uploads/monthly_2013_06/squarephase.png.d87210d4a9656fdcc54d1de3ccc75592.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
Pretty nasty-looking, huh? It is the same square wave, but with a bit of frequency-dependent phase shift (as generated by any filter or speaker).
It is pretty clear that the "squareness" of a square wave on a 'scope display has very little to do with how it actually sounds.
So, how does the original square wave look when we shift the frequency up to 10 KHz but keep the high frequency cut-off at 20 KHz, just as would happen with any system (not just digital) that has an upper frequency limit below 30 KHz?
Here is the result:
<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square10khz.png.b5395e0e8ae30d3db6cf16fd4e38c1d2.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28175" src="https://audiophilestyle.com/uploads/monthly_2013_06/square10khz.png.b5395e0e8ae30d3db6cf16fd4e38c1d2.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
So we have a sine wave. Not very surprising, considering we removed anything from 30 KHz and up - so all harmonics got removed, leaving only the fundamental?
The crucial question remains - how does it sound? Funny enough, just like the unlimited square wave, as our ears can't hear even the 3rd harmonic at 30 KHz anyway. To our ears, there is no difference between a 10 KHz sine wave, and a 10 KHz square wave.
So, considering how common square waves are in digital systems, it is a bit ironic that they are so useless in evaluating systems with a HF cutoff (both analog and digital).<p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/dc1ca9de7f258a89d3c579f55d29ed05.png.e1f5f3413817fed100908876ebefa5ea.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28420" src="https://audiophilestyle.com/uploads/monthly_2013_06/dc1ca9de7f258a89d3c579f55d29ed05.png.e1f5f3413817fed100908876ebefa5ea.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p><p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square99.png.9cc239cd98736db94d68e6721a03ba7a.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28421" src="https://audiophilestyle.com/uploads/monthly_2013_06/square99.png.9cc239cd98736db94d68e6721a03ba7a.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p><p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square19.png.6bb0ddd973a9c518a95a425c65deb4ae.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28422" src="https://audiophilestyle.com/uploads/monthly_2013_06/square19.png.6bb0ddd973a9c518a95a425c65deb4ae.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p><p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/squareripple.png.16f2f5b6bad1612d5029fdca269c6c41.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28423" src="https://audiophilestyle.com/uploads/monthly_2013_06/squareripple.png.16f2f5b6bad1612d5029fdca269c6c41.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p><p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/squarephase.png.d2f2d70fcb43123e3eca43ddf6431cb5.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28424" src="https://audiophilestyle.com/uploads/monthly_2013_06/squarephase.png.d2f2d70fcb43123e3eca43ddf6431cb5.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p><p><a href="https://audiophilestyle.com/uploads/monthly_2013_06/square10khz.png.62c572087a38941fa16007f03c97ebac.png" class="ipsAttachLink ipsAttachLink_image"><img data-fileid="28425" src="https://audiophilestyle.com/uploads/monthly_2013_06/square10khz.png.62c572087a38941fa16007f03c97ebac.png" class="ipsImage ipsImage_thumbnailed" alt=""></a></p>
10 Comments
Recommended Comments