Monday 14 July 2014

Fazed by Phase

In my discussion on square waves, when I mentioned the properties of its Fourier components, I glibly suggested “We’ll ignore phase”.  In truth, we need to look a little more closely at it.   I’ll start by defining phase.

Imagine in your mind’s eye a graph of a sine wave. If this were to represent a sound wave, the vertical axis would represent the air pressure oscillating up and down, and the horizontal axis would represent the passage of time. If you were to capture that sound wave with a microphone, the voltage waveform that the microphone would create would look just the same. Imagine now that you could actually “see” the sound waves, as though they were waves on the surface of a pond. Imagine yourself standing next to the microphone, observing the sound waves as they travel toward you and the mic. Imagine that you can make out the individual peaks and troughs. You can watch an individual peak approach and impinge on the microphone. At the instant it does so, you observe the output voltage of the microphone. You will see that the output voltage also goes through a peak. You watch as the peak passes by and is replaced by its trailing trough, and you observe the voltage from the microphone simultaneously decay from a peak to a trough. I hope this is all pretty obvious.

Now we are going to add a second microphone. Except that we are going to align this one a short distance behind the first one. Now, by the time the peak of the sound wave impinges on the second microphone, it has already passed the first one. The output voltage from the first microphone has already passed its peak and is on its way down to the trough. But the output voltage of the second microphone is only just reaching its peak. Over a period of time, both microphones capture exactly the same oscillating sine wave, but the output of the second is always delayed slightly compared to the output of the first. This is the Phase of the sine wave in action. The phase represents the time alignment. And, as you can work out for yourself, it is not the absolute phase which is important, but the relative differences between phases.

Interesting things happen when we add two nominally identical sine waves together. Let’s specify two sine waves which have the exact same magnitude and frequency, but differ only in phase. I won’t go into the mathematics of this, but what you get depends strongly on the phase difference. If both phases are identical the two sine waves add up, and the result is a sine wave of exactly twice the magnitude of the original. However, if the two sine waves are time aligned such that the peak of one coincides with the trough of the other, then the end result is that both sine waves cancel each other out and you end up with nothing. These two extreme conditions are often referred to as “in-phase” and “out-of-phase”. However, there are a whole spectrum of phase relationships between these two extremes. As the phase difference gradually varies from “in-phase” to “out-of-phase”, so the magnitude of the resultant signal gradually falls from twice that of the original, down to zero.

Lets now go back to the square-wave example of yesterday’s post. Yesterday’s example was concerned with the summing of individual sine waves (a fundamental and its odd harmonics), and how the more of these odd harmonics you added in, the closer the result approached to a square wave. We also saw that by limiting the number of harmonics, what we got was a close approximation to a square wave, but with some leading and trailing edge overshoot, and a bit of ripple. However, in all of that discussion we took no account of phase. Or, more specifically, we allowed for no phase difference between the different harmonics. What happens if we start to introduce phase differences?

The result is that we no longer get a nice clean square wave. As we mess with the phase relationships we get all sorts of odd-looking waveforms, some of them bearing precious little visual relationship to the original square wave. Yet all of these different waveforms comprise the exact same mixture of frequencies. The obvious question arises - do they sound at all different? In other words, can we hear phase relationships? This is a tricky question.

My own experiments have shown me that I have problems detecting any differences between test tones that I have created artificially, comprising identical assemblies of single frequency components added together with different - and sometime arbitrary - phases. But from a psychoacoustical perspective this is perhaps not surprising. Our brains are not wired to recognize test tones, and cannot therefore create a sonic reference from memory with which to compare them, so it is not surprising that I would find it very difficult to hear differences between them.

The conventional wisdom is that relative phase is inaudible, but this is hard to test with anything other than synthesized test tones. With real music there is no possibility to independently adjust the phase of individual frequency components (for reasons I won’t get into here) so the question of the audibility of relative phase is one which remains either unproven, or proven as to its inaudibility, depending on your perspective.