Filters and Phase Shifting

 

This page attempts to show the relevance of phase shifts in audio and filters. Most understanding will be gained by listening to the audio files which greatly enhance the meaning of the text.

 

Waveforms and Phase Shifts

 

To understand the relevance of phase shifting in audio it is necessary first to know what a phase shift is. A sine wave contains only one frequency which is the fundamental pitch that you hear. A sine wave starts and ends at a zero crossing and a single complete sine wave goes from zero to 360 degrees. A sine wave with a 90 degree phase shift is called a cosine wave and starts and finishes at a peak or maximum amplitude. When many cycles of a sine or cosine wave are played consecutively they both sound the same.

 

Click on the audio files below to hear a sine and cosine wave at 440 Hz

(all audio files on this page are 16 bit 44.1Khz wav or aif files)

 

2 seconds sine wave                                         2 seconds cosine wave

 

*images can be opened on a separate page to enlarge

 

A Single cycle of a sine wave

A single cycle of a cosine wave

Sine Wave

Cosine Wave

So when listening to a single waveform in isolation the phase shift has no audible effect. It just means the waveform starts from a different point.

Composite Waveforms

A composite waveform is a waveform made up from several component frequencies. A good example of this is a sawtooth waveform which contains all the harmonics (odd and even) of the fundamental frequency but at amplitudes that decrease with frequency. So a sawtooth with a fundamental pitch of 440 Hz will have a second harmonic at 880 Hz at -6db relative to the fundamental, a third harmonic at 1320 Hz at -12 dB relative to the fundamental and so on. This next sound file makes this clearer. It is a 440 Hz sawtooth being built up by adding more harmonics (2nd to 7th harmonics).

Building a sawtooth waveform

The complete spectrum of the final sawtoothed waveform is shown below. Here the fundamental is at 440Hz, the harmonics reduce gradually as the frequency increases.

A Sawtooth Waveform containing 6 harmonics

Sawtooth Spectrum

Delays and Filters

The above information shows how sounds are created from component frequencies and introduces the concept of phase in a waveform. Here's a bit more about phase shifting and filtering. You may have heard the idea that a comb filter is simply a delay line. That is by delaying a signal and then adding the delayed version back with the original signal we get a filtering effect. A block diagram for this is shown below.

A Simple Low Pass / Comb Filter using a delay line

A Simple Delay Line Filter

The original sound is passed through a delay which is then added back in with the original. This is what occurs in a typical delay effect but here the delay times are much shorter (in the region of mili and micro seconds (ms and μs)). The length of the delay line in this case is fixed (a variable length delay line will allow us to tailor the filter characteristic). If different frequency waveforms are delayed by the same length of time then the phase shift will be dependent on frequency. For an example lets say the length of the delay line is 20 ms. The diagrams below shows what happens when we delay and add different frequency sine waves.

Note the time scale at the bottom of these diagrams, the delay is always the same at 20 ms.

100 Hz Sine Waves 150 Hz Sine Waves 250 Hz Sine Waves

100 Hz

150 Hz

250 Hz

Result of Adding the Waveforms together

Result of Adding the Waveforms together

Result of Adding the Waveforms together

The Result

The Result

The Result

 The top image in each column shows the original and delayed waveforms (2nd wave delayed by 20 ms). The bottom image shows the result of adding the top 2 waveforms together.

When two 100 Hz sine waves are added there is actually a gain increase which causes the waveform to clip. At 150 Hz there is still a gain increase but by a lesser amount than at 100 Hz. As the frequency increases the attenuation factor increases and the resulting waveform becomes smaller. There comes a point (or frequency) when the phase shift is exactly 180 degrees because the length of the delay line is exactly the length of one half cycle of the waveform. At 2 ms delay this occurs at exactly 500Hz. When the two waveforms in the third column of the table above are added together we get a complete cancellation or no sound. The positive values are equal to the negative values and when added together create zero. So we can see here that we get a frequency dependent filtering effect or a low pass filter. Higher frequencies are attenuated more than lower frequencies and we get our characteristic low pass filter curve that you are probably familiar with on digital equalisers.

Low Pass Filter Curve (not scaled to above examples)

Low Pass Filter

What actually happens in this type of filter is that when the frequency continues to increase above the cancellation frequency the amplitude begins to increase again. This creates a comb filter characteristic.

What Phase Shifting Sounds Like on Composite Waveforms and Music

So we can create a digital filter from a delay line (analogue filters actually work in a similar way) and there is a trade off between creating a filter, creating a phase shift and introducing a delay into the signal path. In the sawtooth example above the harmonics were added each starting with zero phase shift. i.e. all the harmonics started at a zero crossing. It is however possible to add harmonics with different phase shifts. The sawtooth will still contain the same harmonic components at the same amplitude but their phases will be different. This is what usually happens in music and sound engineering. We add a number of different component sounds together and the phasing is generally left to chance (although we might get the 180 degree phase shifting option on our mixing desk and we can move the microphones around a bit).

The next sound file demonstrates the effect of phasing when adding sounds together. Although each sound contains the same frequencies at the same amplitude their relative phases have been changed. What you will hear is a sawtooth wave first with no phase shift, secondly with an increasing phase shift per harmonic (the phase shift gets greater the higher the frequency) and finally with a random phase shift for each component. This occurs for 5 different notes (the notes are at frequencies 1 KHz, 500 Hz, 250 Hz, 125 Hz and 62 Hz).

Sawtooth with phase shifts

The diagrams below show the time domain waveform for each of the sounds.

Sawtooth Zero Phase Shift Sawtooth Increasing Phase Shifts Sawtooth Random Phase Shifts

Saw Zero Phase

Saw Increasing Phase

Saw Random Phase

Conclusion

The sawtoothed waveforms above look considerably different but the change in audible effect is quite minimal. So it can be said that the amplitude of the component sounds or frequencies has a greater effect than the phase of the components. (Remember this example is for a complete waveform with all its components passing through a single filter. If we added several sound sources together through a mixer the result of phase shifting can have a more drastic effect and remove complete chunks of the audio spectrum). Subtlety in mixing and music however can turn a great mix into an excellent one. This subtlety in filters is inherent in the equalisers used in digital and analogue mixing and is probably why even though the same characteristic can be dialled up on 2 different equalisers the one that sounds best is obvious (and easily chosen by the ear).

Copyright

Dave Payling 2005. No part of this web page may be reproduced without permission from the author. Feel free to link to this page.

d.payling at staffs.ac.uk