CORRELATION AND CONTRIBUTION
COMPOUND WAVEFORMS AND THEIR CONSTITUENTS

Recall from the section on timbre that a square wave is created by summing together a sequence of odd harmonics. Figure 1 shows the generation of a square wave by summing together three harmonically related phasors. The large blue phasor corresponds to the first harmonic, the smaller green phasor to the third harmonic, and the purple phasor to the fifth harmonic.


Figure 1.  Creating a Square Wave Using Three Phasors

The square wave in Figure 1 can be thought of as a compound waveform since it’s composed of three sinusoidal components. In fact, any waveform can be thought of as an aggregation of one or more sine waves. In this section we’ll utilize the dot product to construct a “detector” which is capable of measuring the presence or absence of a given sine wave within a compound waveform.

The “detector” is actually quite simple. It works by computing the dot product of the compound waveform with a pure sinusoid. If the resulting dot product is non-zero (the two signals are correlated), we know that the sinusoid is present in the compound waveform. The magnitude of the dot product tells us how much of that sinusoid is present. We can derive the “formula” or “recipe” for the compound waveform by running it through the detector over and over again while adjusting the frequency of the sine wave. Whenever the dot product is non-zero, we know that that frequency is present in the “recipe”. A basic schematic for this detector is shown in Figure 2. Use the Frequency slider to adjust the target frequency of the detector.


Figure 2.  Calculating the Dot Product of a Square Wave and Sines of Varying Frequency.
A Component Sine Wave "Detector"






As you play with the frequency control, you’ll notice that the detector will register the presence of sinusoidal components at 2, 6, and 10 hertz (the 1st, 3rd, and 5th harmonics of 2 hertz). In addition, the magnitude of the dot product at these frequencies corresponds perfectly with the relative sizes of the phasors in Figure 1. It seems like our detector is working! Using this construction we’re able to specify the frequency and radius of the three phasors which generate our square wave using only the time-domain representation of our square wave. In actuality, we’ve just performed a very simple Fourier Transform.

Unfortunately, our detector is flawed. you’ll notice that the detector will completely miss frequency components if the square wave is phase shifted 90 degrees in relation to the sinusoid. Our detector should be robust enough to handle inputs with arbitrary phase shifts. We’ll address this problem in the next section, and fix our detector through the clever use of sine and cosine.