Building a Square Wave

DonH50

Member Sponsor & WBF Technical Expert
Jun 23, 2010
3,695
77
225
Monument, CO
#21
If I can ask - is what you are trying to convey with your last statement that with digital and specifically CDs are limited to be able to capture adequate harmonics only <=4KHz?

BTW, my sinuses are killing me being in TX with seasonal cedar allergies. :)
Wow, from about ten years ago...

This is the statement in question: "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."

A square can be broken down into a series of sine waves of the proper amplitude and at odd harmonics. The more you include, the faster the edge, and the more like a square wave it looks. There are different "rules of thumb" for how many harmonics you need to capture or reproduce a square'ish signal and I arbitrarily picked five since that is what a lot of DSO's (digital sampling oscilloscopes, test equipment showing signals versus time) use. Three is another popular choice (that is, provide at least 3x the bandwidth for an x-frequency square wave).

An ADC will have an input antialias filter and DAC an output anti-image filter that reduces signals above fs/2; note these days higher-speed ADCs and DACs are much more common than ten years ago. A 20 kHz square wave passed through a 44.1 kS/s system will look like a sine wave after those filters. Before the filters, it can still look like a square wave, with rise time set by either the input source (to the ADC) or output rise time of the DAC. A 4 kHz square wave will only have the fifth harmonic present after filtering, since 5 x 4 kHz = 20 kHz, and for CDs there is a sharp filter at 22 kHz or so.

Part of this is driven by sampling theory, which says that the signal frequency content that can be correctly captured or reproduced is strictly less than 1/2 the sampling frequency. Beyond that, and you get aliasing, where the signal "folds" around the sampling frequency and generates new low-frequency signals not present in the original. There are several sampling and DAC articles here on WBF (mine are linked in my signature, and there are others as well) that show the process. You can capture 20 kHz signals and CDs can reproduce them, but sine waves only and not waveforms like square or triangle waves that have higher-frequency content that give them their "look". That is what I was trying to convey in that old post.

Interestingly enough I am dealing with this problem at work, where the DSO I have does not have enough bandwidth to properly capture the (square-wave like) signal from a source, and the ripples in the captured signal are messing up my amplitude calibration since the pulses are not "flat". Switching from a 33 GHz DSO to one with 70 GHz bandwidth helps (this is not audio, unless you can hear much higher than normal humans).

---

We still have snow on the ground, piled a couple of feet high here and there from clearing the walk and drive last week, but indoor allergies are just as bad. And of course we have a real Christmas tree in the house...

HTH - Don
 

sbo6

Well-Known Member
May 19, 2014
928
76
85
Round Rock, TX
#22
Thanks for the detailed explanation, Don. BTW - I saw the post before mine from November 2019 and didn't realize your original post was 10 years ago. Glad you are still part of WBF! :)
 
Likes: Gregadd

DonH50

Member Sponsor & WBF Technical Expert
Jun 23, 2010
3,695
77
225
Monument, CO
#23
Thanks for the detailed explanation, Don. BTW - I saw the post before mine from November 2019 and didn't realize your original post was 10 years ago. Glad you are still part of WBF! :)
NP. I didn't even noticed the preceding post until you mentioned it! Yup, still around, trying to stay low-key and out of trouble (not my strong suit).
 
Likes: sbo6

About us

  • What’s Best Forum is THE forum for high-end audio, product reviews, advice and sharing experiences on the best of everything else. A place where audiophiles and audio companies discuss existing and new audio products, music servers, music streamers and computer audio, digital to audio converters, turntables, phono stages, cartridges, reel to reel, speakers, headphones, tube amplifiers and solid state amplification. Founded in 2010 What's Best Forum invites intelligent and courteous people of all interests and backgrounds to describe and discuss the best of everything. From beginners to life-long hobbyists to industry professionals we enjoy learning about new things and meeting new people and participating in spirited debates.

Quick Navigation

User Menu

Steve Williams
Site Founder | Site Owner | Administrator
Ron Resnick
Site Co-Owner | Administrator
Julian (The Fixer)
Website Build | Marketing Managersing