[net.audio] The stuff square waves are made of ....

gregr@tekig1.UUCP (Greg Rogers) (06/24/84)

I'm afraid I contributed to some confusion over the frequency components
of a 20 Khz square wave.  When I referred to a 40 Khz frequency component
I was thinking of a non-perfect "square wave" as might be generated by a 
real world pulse generator, not an artifically created "perfect square wave"
as encoded on a CD test disk.  To set the record straight, rectangular waves,
or periodic pulses, contain a frequency component at 1,2,3,4,...n times the
fundamental frequency (inverse of the repetition rate) in general.  However, 
due to a [sin (x)]/x frequency spectra envelope, the magnitude of the frequency
component is zero at nN times the fundamental frequency, where 1/N is the duty
factor.  Since a perfect square wave has a duty factor of 1/2, (exactly the same
amount of time at its high level and its low level), then its frequency
components at 2f,4f,6f,...2nf are zero.  Thus a perfect 20 Khz square wave has 
no 40 Khz, 80 Khz, etc. components.  However, a real world "square wave" with a
duty factor slightly different than 1/2 will have these components (magnitude
varies with sin x/x function) and this should be taken into account when 
using "square waves" for other types of audio evaluations.  Failure to do this
may lead to some very faulty performance conclusions.  Again sorry if I 
contributed to anyone's confusion.

					Greg Rogers
					Tektronix

fish@ihu1g.UUCP (Bob Fishell) (06/25/84)

I hope this will be the LAST WORD on this argument...

The Fourier series for a square wave is given by,
                                                                        
           ___o_o__                                                       
           \    |                                                       
            \                                                           
   f(x)=     >    (1 / (2 * i - 1)) sin ( (2 * i - 1) * x )       
            /                                                           
           /____|                                                       
            i = 1                                                       
                                                                        
Thus the first component encountered after the fundamental is (sin(3*x))/3,
or a frequency 3 times that of the fundamental.
-- 

                               Bob Fishell
                               ihnp4!ihu1g!fish

gregr@tekig1.UUCP (Greg Rogers) (07/03/84)

Bob I don't know who you are now arguing with or why you posted a reply
to my explaination about rectangular waveforms.  As I agreed a square wave
has only odd harmonics of the fundamental.  However the point I made was
that often when dealing with so-called squarewaves produced by real
generators the duty factor is not exactly 1/2.  In that case the even
harmonics are ALSO present and if this is not taken into account then
errors will be made when using these signals to test audio gear.  A 
true square wave is a special case of a periodic gate function (or 
rectangular wave) and in fact can only be approximated to some arbitrary
degree by real world generators.  The Fourier coefficients for periodic
pulses of width a, occuring at period T = 2*pi/w is

               c  =  a/T * [sin (nwa/2)] / [nwa/2]
                n

where n = 1 is the fundamental, n = 2 the second harmonic, and so forth,
which has been normalized for a unit amplitude.  Obviously for a square
wave where a = T/2, 

               c  =  a/T * [sin (n * pi/2)] / [n * pi/2]
                n

which has nonzero values only when n is odd, hence has only odd harmonics.

However if the rectangular wave is not perfectly "square" (i.e. a <> T/2)
then the equation reduces to

               c  =  a/T * [sin (n * pi * a/T)] / [n * pi * a/T]
                n

at which point harmonics are only missing at n = T/a, 2T/a, 3T/a ....
If T/a is not an integer then no harmonics are missing at all since n
is of course always an integer.  Hence you can see if the "square wave"
is only slightly non-perfect then T/a will not be exactly 2 but rather
a non-integer close to 2, and all harmonics, even and odd will be present.

Well I hope THIS is the LAST word on the subject, surely you don't disagree
with any of this Bob.
				Greg Rogers
				Tektronix