1 Phase Shifting
Martin Guy edited this page 2025-01-01 20:05:58 +01:00

Phase Shifting (Phasing)

By Scott Lehman

Part of the series of articles Effects Explained

Recovered from archive.org

Introduction

The phase shifter (or phaser) achieves its distinctive sound by creating one or more notches in the frequency domain that eliminate sounds at the notch frequencies (the flanger also makes use of notches, and it is actually one specific type of phasing). The notches are created by simply filtering the signal, and mixing the filter output with the input signal. The filters can be designed so that we can independently control the location of each notch, the number of notches, and even control the width of the notches. This can lead to many interesting sonic possibilities as presented in Sound Set 1.

.au file (92K) .wav file (183K) .mp2 file (92K)

Sound Set 1: A picked chord sequence dry followed by the same sequence with phase shifting applied.

How it Works

The notches needed for phase shifting (or simply called phasing) are most often implemented using a special group of filters called allpass filters. As the name implies, the allpass filter passes all frequencies - that is it allows all frequencies to appear in the output with no attenuation or amplification. So if you were to put any sine wave into the allpass filter, you would see a sine wave at the output, with the same amplitude it was at the input. To complete the phase shifter, we just add the filter output to the input signal, as in Figure 1. The amount of the filtered signal that appears in the output is set by the depth (also called the 'mix' or 'level') control.

Diagram of the phase shifting effect Figure 1:

Well that's interesting, but if the filter passes all frequencies equally, how does it alter the sound, and where do the notches come from? Well there's one other characteristic of the filter we haven't mentioned yet, and that is the filter's phase response.

The phase response it kind of difficult to explain, so let's keep things relatively simple here. Let's say you're given a block box, and you don't know what circuit is inside of it. You can test it by putting a sine wave generator on the input and then look at the output and the input together on an oscilloscope. There are two important characteristics that can be observed. The first is the relative amplitudes of the two signals (which is referred to as the magnitude response). Again, for the allpass filter, these amplitudes are equal, so the magnitude response is one for all frequencies. The other important characteristic is the relative alignment of the two signals in time, i.e. do they both cross zero or reach the maximum values at the same time. The difference between the two signals is the phase lag, or the phase response. The black box is altering, or shifting, the phase of the input signal - hence the name 'phase shifting.'

The phase lag is usually measured in fractions of a wavelength rather than an amount of time. A single cycle of the wave is 360 degrees (regardless of the period or frequency of the sine wave), so 90 degrees is a quarter of a cycle, 180 degrees is half a cycle, and so on. Figure 2 shows some examples of a phase lag with a sine wave. The horizontal axis is time, so a delay moves things to the right.

Phase lags of a sine wave

Figure 2: A simple sine wave (a), and the same signal with a phase lag of (b) 90 degrees, (c) 180 degrees, (d) 270 degrees, and (e) 360 degrees (one cycle of the waveform). Note that when (a) and (c) are added together, the result is zero - complete cancellation.

All practical filters have a phase response that changes with frequency, and Figure 2 is a plot of the magnitude and phase response of one possible allpass filter. One interesting case is a linear phase response (i.e. the phase response is a straight line, angled downwards). In this case, doubling the frequency means doubling the phase lag. The wavelength of the doubled frequency is half that of the original. This basically keeps all the frequency components aligned in time - it delays the signal. So the pure delay (no feedback or mixing with the original signal) is one type of an allpass filter. (On some audio products, there is a specification 'Deviation from linear phase.' Linear phase is desirable in some applications so that all frequencies are kept together in time and the sound isn't colored by 'phase distortion.')

Magnitude and frequency response for a particular allpass filter

Figure 3: The magnitude and frequency response for a particular allpass filter (of second order). Only the phase varies, while all frequencies are passed with a gain of one.

Now we are ready to understand where the notches come from. To create the notches, we only need to mix the allpass filters output with the input. Why? At some frequencies, the phase lag introduced by the filters will be 180 degrees, which is equivalent to taking the negative of the input. When you mix this signal with the input, those frequencies that experience 180 degrees of phase lag will exactly cancel with those frequency components in the input, and that is the notch. Frequencies near the notch will also be attenuated somewhat. Essentially, a filter with a non-linear phase response, though it may be hard to believe, is delaying the signal, but not all frequencies are delayed by the same amount.

Going back to the linear phase case (the pure delay), the phase response hits values of -180 degrees minus multiples of 360 degrees (-180, -540, -900, -1260, etc.) at equally spaced frequencies. So when we mix a delayed copy of the signal with the original, there will be notches at equally spaced frequencies. This is exactly how the flanger operates, and thus, the flanger is merely one type of a phase shifter.

By using allpass filters that do not have a linear phase characteristic, we can distort the phase response to produce a notch at whatever frequency we choose. The number of notches is determined by how complex the filter is. But we can also exploit another property of allpass filters to increase the number of notches - a series combination of allpass filters is itself an allpass filter. So we can start with a simple filter, and then chain additional filters to create more notches, and the phase response for the chain of filters is simply the sum of each filter's phase response. The MXR Phase 90 pedal contains four stages to create its sound (but each stage doesn't necessarily produce a notch. A phase response of a first order allpass approaches 180 degrees at very high frequencies, so multiple stages are needed to create a notch.). Also, unlike the flanger, we can control the width of the notches if we want to. But this parameter is often determined in the design stage of a product and can't be adjusted by the user.

One remaining point to cover is how the notches sweep over time. For the chorus and flanging effect, we use a simple LFO to control the delay time. But with the phaser, it's generally preferred to have the notch frequencies change exponentially. For example, when the notches are moving up, you might double the notch frequency at each step, taking larger and larger steps, and then once you've reached the high point of the sweep, you halve the notch frequency at each step to return to the low point. This approach makes it harder to several LFO waveforms that are easy to understand. You won't have control over how the notches sweep in most commercial products, just how quickly the notches sweep back and forth and the range they sweep over. Of course, there is not really a right or wrong way to do things, and for the circuit hacker or programmer, there are plenty of possibilities to explore. In this spirit, Sound Set 2 offers two clips of phasing on a distorted guitar with an exponential and linear sweep.

.au file (66K) .wav file (132K) .mp2 file (66K)

Sound Set 2: Two segments of phase shifting applied to a distorted guitar. In the first, the notches sweep exponentially along the frequency axis, while in the second clip, the notch sweep is linear. Listen to the notches at the beginning (their low point) - in the first clip, the notches move more slowly at first compared to the second clip.

Common Parameters

Depth (Mix/Level)

The depth parameter controls the amount of the filter output that is added to the sound. It's called the depth control because as it increases, the depth of the notches increases as well. When the depth is set to 1 (or 100%), then the notches reach all the way to zero. (In many cases, people use 'depth' to describe how wide a range the notches sweep across, which is referred to as the 'sweep depth' in this article.) In some multi-effects processors, the depth or level control may only be controllable in the mixer section.

Sweep Depth (Range)

This parameter is used to control how far the notches sweep up and down in frequency. In some cases, you may be able to select actual frequency values, and in other cases, the base frequency may be set to some value and you can only control how far from that frequency the sweep will go. Sound Set 3 demonstrates the sweep depth on the phaser.

.au file (83K) .wav file (166K) .mp2 file (83K)

Sound Set 3: The distorted guitar sound again, first processed by a phaser with an octave sweep depth, followed by a version with a two octave sweep depth. The rate is the same in both cases.

Feedback/Regeneration

The phase shifting effects can be made more intense by using feedback - adding part of the filter output to the input, as in Figure 4, and in Sound Set 4. Some units may also allow you to have negative feedback gains, which is equivalent to subtracting the output from the input. When working with several stages of allpass filters, you can conceivably use feedback on each individual stage as well as the entire structure.

Diagram of a phase shifter that incorporates feedback. Figure 4: The phase shifter with an added feedback path. The feedback gain can be negative as well as positive.

.au file (50K) .wav file (100K) .mp2 file (50K)

Sound Set 4: A strummed guitar using a phaser with mild feedback, followed by a version with a higher feedback setting.

Speed/Rate

This parameter simply controls how quickly the notches sweep up and down over the frequency range. The rate sets how many times the notches sweep up and back down per second only. The speed at which the actual notches are moving is determined by this rate control, the sweep depth, and the sweep pattern.

Implementation

Analog

There are a number of analog implementations as would be expected. Figure 5 shows one possible circuit. For creating the dynamic sweeping effects, the variable resistor can be replaced with some voltage controlled device.

![A simple allpass filter}(images/phase-shifting-f5.gif)

Figure 5: A possible circuit for a phase shifter.

Digital

Creating an allpass filter in a digital system is very simple. Figure 6 shows the flow diagram for an allpass filter, where the feedforward and feedback loop gains are negatives of each other. The filter pictured is only a first order allpass. More complex versions with multiple delay blocks can be constructed.

Diagram of a digital allpass filter

Figure 6: The flow diagram for the digital allpass filter.

Digital allpass filters are also useful in some sound synthesis techniques. Going back to the idea that the allpass filter delays a signal, for most frequencies, the delay will be some fraction of a sample period. When trying to physically model a musical instrument, you can use this fractional delay to create a resonant structure with a period that isn't a multiple of the sampling period. This technique is an alternative to interpolation. The primary problem is that since not all frequencies are delayed by the same amount, the harmonics can go out of tune during synthesis.

Other Notes

Stereo Phase Shifter

A stereo phaser could be constructed along the lines of a stereo flanger/chorus unit by using two filters with notches falling at different frequencies. It's also possible to create more complex sounds by selectively mixing the outputs of the two filters as well which can create additional notches that can exist on a single output. This general structure is depicted in Figure 7. If the feed-across gains are set to zero and each output fed to a speaker, you will have a 'spatial phaser' where the notches exist only in the air and can be heard by simply moving about the room. Sound Set 5 gives a sampling of some stereo phase shifting effects.

!ADiagram of a stereo phaser](images/phase-shifter-f7.gif]

Figure 7: A generalized diagram of a stereo phaser.

.au file (178K) .wav file (355K) .mp2 file (178K)

Sound Set 5 (Stereo): Three different stereo phaser configurations applied to the distorted guitar sound from above.

References

  • Cronin, Dennis "Examining Audio DSP Programs," Dr. Dobb's Journal, July 1994.

  • Smith, Julius O. "An Allpass Approach to Digital Phasing and Flanging," Proceedings of the 1982 International Computer Music Conference.

  • The Technique of Electronic Music Wells, Thomas and Eric S. Vogel., Austin: Sterling Swift Publishing Company, 1974. (ISBN 0028728300)

© Scott Lehman and licensed to Harmony Central, LLC. All rights reserved. Harmony Central encourages linking from other sites to Harmony Central content.