Maybe you are familiar with the effect of multiplying two sinusoids
on analog
synths. The original frequencies disappear, and
you get two new frequencies in return: the sum and difference
frequencies. Such multiplication can also be done with two input audio
signals, and is then known by the name of ring modulation.

Quadrature mixing is a fascinating extension of this process.
Basically, it works like this: of each input signal, a -pi/2 radian
phase
shifted version must be created. Together with the original signal, the
shifted version makes a complex signal, also called analytic signal.
When complex signals are multiplied, only the sum frequencies remain.
It is single-sideband modulation. Because complex signals have no
alias, there is no negative frequency product.

Complex signals can be considered streams of complex numbers, and
regular complex multiplication apply to them. Illustrations of complex
multiplication are on the page 'complex
plane, intro' for example.

Let me start with synthesizing a complex signal. This is
simply a cosine phase and a sine phase of identical frequency. Here it
is done as a Pure Data patch, but it can also be done with
Max/MSP or probably any modular (soft)synth. Notice that sin[x] = cos[x-pi/2], so the second phase is
shifted by -pi/2 respective to the first phase. When expressed in units
of time, the second phase is a quarter of a cycle ahead in the positive
direction of the x-axis. That is a delay, actually. The first phase is called real phase and the second phase is
the imaginary phase. In engineering terms, they are called in phase and
quadrature phase respectively. |

Here I packed the complex modulator in a subroutine
'complexsinusoid' and duplicated it. There is a complex signal (a+ib)
and another one (c+id). These signals are complex multiplied. The
product is a complex output signal with real phase and imaginary phase
again. Notice the frequencies of the complex sinusoids: 180 Hz and 50
Hz. When done with real-only signals, multiplication would result in a
sum frequency of 230 Hz plus a difference frequency of 130 Hz. You
would see an amplitude-modulated signal. In the complex case, there is
only the sum frequency of 230 Hz. |

Imagine you have complex-modulated a signal into another
frequency range, and you want to restore that signal later. Then it
must be demodulated. This goes with complex division instead of
multiplication. When the modulator was (cos[x]+i*sin[x]), there is no
scaling factor involved, and the complex division boils down to an
inverse rotation. Which in turn is a simple sign-flip of the imaginary
part in the modulator. (a+ib)/(cos[x]+i*sin[x]) = (a+ib)*(cos[x]-i*sin[x]) With complex multiplication it is not really defined which
input signal is the modulator and which is the modulated, because they
modulate each other. With demodulation it is different. The input
signal is divided by the demodulator. Therefore, the sign-flip must be
in the demodulator and not in the input signal. If (c-id) is the
demodulator (cos[x]-i*sin[x]), the demodulation goes: (a+ib)*(c-id) = (ac+bd) + i(bc-ad) A difference frequency is the result, still with the correct
phase shift to make a complex signal. In the patch here, the output has
frequency 180-50 = 130 Hz. |

For comparison, here is a multiplication of two real signals
with 180 and 50 Hz frequency. Sum and difference frequencies both
appear in the output: 130 and 230 Hz. From the waveshape you can see
that there is amplitude modulation. |

Quadrature mixing with synthesised signals is not the real challenge,
because the output frequencies could be created with easier methods.
With a real world signal as an input, quadrature mixing can do
something which can not be done otherwise: shift all frequencies to
another range, creating a single sideband. In order to do quadrature
mixing on a real world signal, that signal must first be made complex.

A set of two all-pass filter cascades can convert a real
signal into a complex signal over a large range of frequencies. In Pd,
you can find this process in an abstraction called hilbert~. For the
purpose of demonstration, I have copied the content of hilbert~ into my
main patch. The output phases of the filter set are both phase-shifted
with respect to the original signal. But it is done in such a way that
the phase distance from the first to the second output is always -pi/2.
Only for the lowest frequencies and for the highest octave this does
not work. In the patch, a sinusoid test input is used to visually check
if the phase distance and direction is correct. But it can be replaced
with any signal, even if that signal contains many different
frequencies simultaneously. There are more ways to produce a
complex signal. For details and illustrations, see the page 'Hilbert Transform'. |

To illustrate the never ending confusion around phase shifts
and their direction, I did a similar patch with Max/MSP's hilbert~
object. As you can
see, the second output phase is not time shifted forward, but backward
relative to the first output. That means a positive phase shift. A
cosine from the first output goes with a negative sine from the second
output. This is not an analytic signal! It has a negative rotation. It
is easy to do something about that. A sign-flip of the second phase
makes positive frequencies. It may be the case that the filters inside
the object are accidentally swapped. The object source code is not
open, so there is no way to check the filters. But if we would swap the
outputs, the phase relation would be correct. That is another
workaround. Since both output signals were phase shifted in a
non-phaselinear way to get the pi/2 phase interval, the phaselinearity
of the signal is lost anyway, and probably it does not matter so much
which workaround you choose. |

Initially, I had made a similar mistake in the modulator, when doing
this page with Max/MSP examples. My mistake neatly compensated the
inverse rotation of Max/MSP's hilbert~ object, and there were sum- and
difference frequencies where I expected them. After
discovering what went wrong, I had to redo all illustrations, and took
that opportunity to use Pd instead. My advice is: check the rotational
direction of a
phase shifter before you do a lengthy webpage (or distribute a software
package).

Here is a Pd patch that shifts the frequencies of an input
signal. The oscilloscopes show the input signal and the real phase of
the modulated complex output. I have chosen a simple input signal: an empty beer bottle
blown. These are always around here.
It's fundamental frequency is around 210 Hz, and I set the modulator at
210 Hz
as well. The output shows the sum frequency, which will be some 420 Hz. If the modulated signal is a final product, a musical signal
which we are going to hear as is, and which does not need demodulation
later, the imaginary phase of the product can be discarded. |

Here are some audio fragments for Quicktime, demonstrating the
effect of single sideband modulation:

This is the original beer bottle sound: |

This is the beer bottle through the modulator: |

Into the modulator I have also played a kaval (Turkish flute)
soundbite. The modulator frequency was at 440 Hz. |

The next experiment is with difference frequencies. I set the
modulator frequency to 105 Hz. That
results in an output with 210-105=105 Hz. It is in the picture below.

Since I am not going to use the imaginary product, I erased
the connections for it's computation, and replaced it by the
computation of (a*c+b*d), the real phase for the difference
frequencies. Another empty beer bottle was blown, while the modulator /
demodulator frequency was set at 105 Hz, half the input
fundamental of 210 Hz. The output is single-sided again, and shifted to
a lower frequency. |

Here the sound of the low beer bottle: |

Here is the sound of difference frequencies from the kaval.
The modulator is at 500 Hz. |

Quadrature mixing or single side band modulation
has been a popular technique in radio transmission, reducing the
required bandwidth and energy. As we have seen, it shifts frequencies
by a fixed amount, that of the modulator frequency. This means that
harmonic relations are not preserved. That is a pity: we can not use
the technique for pitch shifting. For pitch shifting, each frequency
should be shifted by a ratio. For example, to double the pitch would
mean a 50 Hz frequency shift for a 50 Hz input component, and a 180 Hz
shift for a 180 Hz component. This can only be done when all
frequencies are sufficiently isolated, like in Fourier analysis.

While frequency shifting is not appropriate for conventional
harmonic music, it is an appreciated technique in electronic music and
soundscapes. The process is very simple, and can hardly be spoiled by a
poor implementation. Although it works with an analytic signal, the
content is actually not analysed. Nothing can go wrong there, whatever
weird sound is sent in. The modulator frequency can be controlled
dynamically to bend notes. Single-sidedness avoids the all too
stereotypical effect of ring modulation. It is up to the composer or
performer to exploit these benefits.