Digital Signal Processing (Part 1)
PART 1: Digital Signal Processing is rapidly becoming more familiar to musicians and home recordists as digital effects become ever more commonplace. Nevertheless, the technology and principles behind it remain a mystery to most. In this new series Jim Grant offers a straightforward explanation of how DSPs work.
A few years ago as a student engineer, I struggled with the maths of sampling theory. The topic was part of a much broader course called 'Signals And Systems', and at the time I thought that I was at last moving towards the focus of electronics: surely this was the kind of esoteric knowledge that only engineers knew. How wrong can you be? In less than eight years I find that musicians and hobbyists talk to each other about aliasing and quantisation distortion just as if it were hi-fi or car mechanics.
The passing of these subjects into common usage is, of course, due to the proliferation of digital samplers and the coverage of sampling theory in the technical music press. But as technology and techniques forever march onwards, still more obscure topics become familiar ones to musicians, and one of the next to pass into the public domain will probably be that of Digital Signal Processing - a rapidly expanding field of recording technology at present, and the subject of this short series of articles. In this and subsequent parts we will explore the technology and techniques involved, and how they can be applied to produce various familiar effects. This is not as complicated as it may sound, because Digital Signal Processing is basically very simple - all that is involved is the conversion of audio signals into data, some heavy number crunching, and the conversion of the resulting data back into audio.
Whilst it is true that Digital Signal Processing has been around for some time, its application to performance oriented music has been fairly recent. This has been primarily due to the difficulty and expense involved in making small high speed computers that can handle the very demanding number crunching requirements of real-time signal processing. A DSP must continuously sample the input audio signal and thereby convert it into a stream of data, process and modify that data, and convert the modified data back into audio signals (via a digital-to-analogue convertor, or DAC), which become the audio output of the unit. The word 'modify' can cover any number of operations, some of which will be covered later in this series, but what is most relevant at this point is the time element: the DSP must be capable of performing all the calculations on each sample (ie. single data word) before the next one arrives in order for effects to be heard in real time.
To illustrate this let us choose a simple example. Figure 1 shows a triangle wave which is sampled by a Digital Signal Processor (DSP) and each sample is multiplied by -1. The overall effect, as you can see from Figure 2, is to change the phase of the output with respect to the input by 180 degrees. Now suppose that the sampling rate is 40kHz, ie. a sample is generated every 25 microseconds. It is easy to see that the multiplication by -1 must itself take less time than 25 microseconds or the net throughput of 40,000 modified (processed) samples a second cannot be maintained. Consequently, the sample rate of DSPs is often reduced in order to allow the processor more time between samples to perform its calculations - as with a sampler this reduces the audio bandwidth of the final output, and this is the reason for many digital effects units having a frequency response that only reaches up to about 12kHz.
Other nasty side-effects caused by a DSP's data processing demands (which we will subsequently ignore and leave for the designer to worry about) include calculation errors caused by using a limited number of binary bits in the arithmetic. These errors usually manifest themselves as noise and, all other things being equal, the system might as well be using fewer bits in the sampling process. Fortunately, the underlying techniques of signal processing can be described in terms of how things work in theory, and not how to make things work in practice.
To understand how Digital Signal Processing works in more detail, let us consider a typical DSP system. Figure 3 shows such a system in the form of a block diagram. The audio chain can clearly be seen progressing from left to right through the block marked 'DSP chip'. Our system is equipped with stereo sampling and stereo inputs/outputs, although only one ADC (analogue-to-digital convertor) and one DAC (digital-to-analogue convertor) are used. To achieve this little trick, electronic switches route the audio and sampled signals at the correct times to make it appear as if two ADCs and two DACs are being used. In fact, a typical system might use the power of electronics to enable a single DAC to perform the work of two ADCs and two DACs.
Also shown in the diagram is a microprocessor system which controls the operation of the DSP chip. In every product there are certain low level functions like keypad and switch scanning, display driving and the handling of MIDI data. These must take place continuously, often at the same time as signal processing, and so are handled by a microprocessor to avoid overburdening the DSP chip. Communication between the two systems is via the Input/Output block, which is dedicated to providing this control path: it is never used as a path for processing audio samples. Microprocessors are generally medium to slow speed devices and cannot handle the operations necessary to perform interesting functions whilst maintaining a high audio bandwidth.
The most basic signal processing operations are those of simple arithmetic: addition, subtraction, multiplication and division. If only one channel of the DSP system were to be used, say the left one, and an audio signal digitised and its sample values multiplied by a factor of 2 before being passed to the DAC, the result would be simply a gain increase of 6dB -ie. a doubling of signal levels, though not of perceived loudness (the reason for this discrepancy is related to the physics of sound, and is therefore not strictly relevant to this article). A multiplication by a factor of 4 would give a 12dB gain increase, and so on. Likewise, the division of each audio sample value by 2 would attenuate the output signal level by 6dB. Figure 4 shows this gain and attenuation process with examples of unprocessed and processed triangle waves. In general, the overall gain of the samples can be summarised with a simple dB formula:
Gain = 20 LOG (sample value x multiplication factor)
Don't forget that if the multiplication factor is less than one (ie. a fraction), then we get attenuation instead of gain. A common mistake is to assume that multiplying the signal by a negative number gives attenuation - but as you can see from Figures 1 and 2, this results in amplitude inversion. The confusion lies with the difference between a system that, say, has a gain of 20dB (a multiplication factor of 10), and another with a gain of -20dB (a division of 10). Negative dB gains are, in fact, attenuations.
Next, let's bring the right channel into play as well, so that we are digitising two separate channels of audio information and dealing with two streams of audio samples. The addition of these two streams, sample for sample, would result in the familiar process of audio mixing. To spice things up a bit we could multiply the input samples before they were added together, to adjust their levels, and then to finish the whole thing off, multiply the resultant output samples to produce a mixer with variable gain/attenuation.
Figure 5 shows the signal flow through the various arithmetic stages of this process. Usually the arithmetic operations will be DSP instructions and the actual multiplying values at the various stages in the process would most likely come from the microprocessor system, and could be selected by the keypad.
Turning a powerful and expensive DSP system into a two-channel mixer with gain (something that could have been achieved with a single integrated circuit chip and three resistors!) seems like a bad waste of good technology, so what is the point? Mixing is a trivial application for this technology, but it serves to illustrate the basics of Digital Signal Processing. Also, the operations of multiplication, division and addition are present at many stages of more complex signal processing, digital or otherwise. In case you are wondering what has happened to the subtraction operation, this is equivalent to multiplying the values for one of the audio channels by -1 and then adding the values for the two channels together. Figure 4, input [A] shows the process. Since the ear is fairly insensitive to phase relationships, most of the time the overall effect will be the same as straight addition.
Next month we will look at how a DSP can be used to generate interesting harmonic structures using distortion techniques and ring modulation, and how delay-based effects such as echo, flange and harmonising can be produced.
Feature by Jim Grant
Previous article in this issue:
Next article in this issue: