The Ins and Outs of Digital Design
An in-depth investigation into the problems of digital filter design and their possible effects, plus a simple circuit for an ultra-powerful low-pass filter.
As the next few months will be seeing a good deal of activity on the practical design front, in the shape of the E&MM Programmable Digital Sound Generator, David Ellis lays out a few ground rules in Digital Design by taking a look at some of the cogs and wheels of digital sound synthesis — time-multiplexing and filtering. And, to put things in a thoroughly practical perspective, he's also included the circuit for an ultra-sharp low-pass filter for improving the synthetic lot of the Mountain Computer MusicSystem digital hardware, known and loved (?) by all owners of alphaSyntauris and Soundchasers....
There's a touch of delicious irony in the fact that the mainstay of analogue synthesis, the low-pass filter, is a major bone of contention in the digital field. Everywhere you look, you read about the magical role of these objects for such neo-mystical operations as 'anti-aliasing', 'waveform smoothing', and the like. Whether it's a cheap and cheerful Casio for a few tens of green ones or a Fairlight at three orders of magnitude more, the ultimate proof of the pudding is down to what the inevitable low-pass filter on the output of one or more digital-to-analogue converters feels like passing on to the outside world. And one commercial product which particularly shows up this fact is the 16-channel MusicSystem hardware from Mountain Computer, the synthetic raison d'etre of both the alphaSyntauri and Soundchaser systems.
The way the hardware works is by employing 16 'digital oscillators' to part with waveforms over a wide range of frequencies and amplitudes as a result of relevant values received from the host micro (an Apple II, as it happens). Nothing startling in that. But the main claim to fame of this hardware lies with the fact that the programmability of these digital oscillators also extends to the timbre of waveforms being spewed out at nineteen-to-the-dozen. This is the result of some circuitry on the boards that periodically flips the switch so that the right waveform samples are yanked out of relevant locations in the host micro's memory and then sent directly to the digital oscillators - a very trendy technique called, not surprisingly, Direct Memory Access.
Now, if you've got some hardware in front of you that waves the magic wand of 16 digital oscillators, it shouldn't take much more than a modicum of intelligence to surmise that each of those digital oscillators probably has one DAC that's turning waveform samples into analogue sound, and a second DAC that's performing the amplitude control. Tried and tested techniques, after all... In fact, you'd be wrong. Those so-called digital oscillators don't quite exist in reality; they're actually much more philosophical in nature. The term the designers use to describe them is 'conceptual', meaning that they're almost there but not quite.
The truth of the matter is that there's actually just a single extremely hard-working DAC receiving waveform samples in turn for all 16 of the 'digital oscillators' - a new and highly mystical experience for digital synthesis called time-multiplexing. This is a bit like the equally new but highly unmystical time-sharing scheme for owning and using holiday villas. The idea is that, rather than each sample of the holiday-going population buying one villa and going there for the same two weeks out of the year, 26 families split the purchase and then agree to use the villa for two weeks in turn. The hassle with this is that you've got to get everyone around the table to agree to a particular part of the yearly cycle. And, in fact, that timing requirement is as much the problem of time-multiplexing lots of sound channels through a single DAC as it is for time-sharing lots of holidays in a single villa.
The really nice thing about time-multiplexing is that it's so much cheaper to have just one DAC split umpteen ways. But, once out of the DAC, the cobbled together channels then have to be de-multiplexed with sample & holds and switching in order to restore some semblance of individuality to the stereo outputs. The point is that the last thing you want is an outbreak of rampant wife/husband-swapping amongst out-of-sync time-sharers, and the equivalent problem of cross-talk with time-multiplexing has to be watched out for.
Anyhow, minor problems aside, time-multiplexing now seems to be the most popular method of getting multiple output channels in mid-cost equipment, and is equally applicable to keyboard instruments like the Synergy (which uses 32-way time-multiplexed hardware originally developed at Bell Telephone Labs.) and digital drum machines like the Drumulator and MXR Drum Computer (both of which use a single DAC that's fed samples in turn from all the different sound EPROMs). It's also the technique behind the operation of the Programmable Digital Sound Generator project that we'll be commencing next month.
Now, in the case of both MusicSystem and Synergy hardware, the rate at which any particular waveform is sampled for one channel is around 31.2kHz. This means that the highest theoretical frequency that can be sampled and reconstituted is half that figure, ie. 15.6kHz, the so-called Nyquist limit. But note that tag 'theoretical'. In practice, digital synthesis is rarely quite as wonderful as the theory.
A necessary evil of putting waveform samples through a DAC at a particular sample rate is that the samples and the sampling rate tend to enjoy interfering with each other - a fact of digital audio life called 'aliasing'. In fact, if you try to sample and convert a waveform with a particular set of harmonic components, you'll discover that these will then generate a whole mass (not to say mess) of beat frequencies with the fixed sample rate. So, taking the above 31.2kHz sample rate, a sinewave regurgitated at a frequency of 14.5kHz would lead to a beat frequency of 16.7kHz (31.2-14.5). As this extra component lies within the hearing range of most young ears, and a few olduns as well, nobody's going to be too delighted listening to the raw 14.5kHz sinewave complete with the added beat frequency complications.
So, by hook or by crook, something has got to be done about removing all those frequencies that come above the maximum synthesisable frequency, and that's where the low-pass filter comes into play. However, the higher the frequency you're synthesising, the nearer the beat frequencies will be to the actual frequency you're trying to synthesise, and in the end you're in danger of throwing away the baby with the bathwater. The sorry truth of the matter is that low-pass filters aren't usually capable of chopping out all you don't want without encroaching into the area you do want. In short, filters don't come sharp enough.
On this basis, the low-pass filters on the outputs of the MusicSystem are really pretty blunt, and tend to cut off high-frequencies with unduly wild abandon. For this reason, a major improvement to the performance of the system can be had by replacing them with some external filtering circuitry. In fact, when I was trying to work out the correlation between measured frequencies and written frequency bytes (by writing values to the relevant frequency registers on the boards and putting the output into a Digital Frequency Meter) it transpired that once I went above a 10kHz sinewave, there wasn't enough amplitude left in the signal even to trigger the DFM into making a reading! That's generous low-pass filtering for you...
So, for this reason, it seems entirely reasonable to search for an alternative to the low-pass filters used by the MusicSystem, and, of course, the outcome of this search might be valuable to anyone else contemplating the construction or use of digital synthesis hardware where optimisation of frequency response is an important consideration. Now, anyone who's read Hal Chamberlin's Musical Applications of Micro-processors will have come across a chapter that includes a whole chunk on the ins and outs of filtering, and they might even have attempted to work out all the component values for one of the ultra-sharp Chebyshev-type filters using seven or more stages. Not the easiest going of subjects, is it? Well, the circuit described below takes the easy way out by employing one of the new breed of switched-capacitor filter chips based on bucket-brigade technology, the R5609 from Reticon. The remarkable thing about this chip is that it achieves a filter slope of at least 100 dB/octave.
The de-multiplexed analogue signals (left and right) go from an MCI 4018 chip on the digital side of Board 1 of the MusicSystem to the four dual op-amps, configured as two low-pass filters, inside the ground plane on the same board. The point of the current exercise is to sidetrack these signals away from the evil grabbings of the resident filters, and take them to pastures new in the shape of the R5609 ultra-filters. A convenient place to extract the pre-filter analogue signals is from pin 5 of U2 and U4. At the same time, the positive and negative power rails and ground can be tapped off, and the whole lot cabled together for sending off to the external filter circuitry.
Aside from the operation of the R5609 chip itself, the filter circuit is totally uneventful. As the R5609 can handle an input of 12 volts peak-to-peak, a buffer stage (IC1a and IC2a) suitably conditions the signal emerging from the Music System. The 10K pot varies the rate of oscillation of the 4047 (IC3) so as to provide a variable clock for the R5609s. Since there's a 1:100 ratio between the cut-off frequency and clock rate, this pot determines the filter cut-off. Altering C1 above or below the recommended 22pF value varies the range over which the filter operates.
The prototype of the circuit was put together on a small piece of Veroboard, which is a fair way of going about it since there aren't too many components involved. However, watch out for that clock getting onto the signal lines! The R5609 spec sheet is fairly insistent that the positive and negative rails shouldn't go above 10 volts. In fact, the power rails going to the filter op-amps on the MusicSystem board are at + and - 8 volts (pins 8 and 4, respectively), which suits both the switched-capacitor filter chips and op-amps to a tee. Only one side of the filter is shown, so for two channels, a further couple of op-amps and a second R5609 will be required. Note, however, that both R5609s are clocked from the same 4047 clock.
One annoying drawback of adding a further clock to the system means that beat frequencies are also generated between the sample rate that's directing samples to the bucket-brigade stages of the R5609 and the sampling rate of the MusicSystem boards. The Reticon application note casually suggests that you can put a further low-pass filter on the output of the R5609 to get around this sort of problem... The manner in which these new beat frequencies are manifested is as a high-pitched whistle that varies in pitch as the clock-rate pot is twiddled. However, this is only really troublesome when the cut-off is set really low, and in practice, once you've adjusted the clock-rate so that the filters are just biting audibly into the extreme top frequencies, the problem vanishes. Another possible clocking arrangement would be to use the 7MHz 7M clock of the Apple, divide this down twice to 1.75MHz, and then use this to drive the R5609s. This would give a fixed cut-off frequency of 17.5kHz, which, though somewhat higher than the Nyquist limit, doesn't actually seem to lead to any noticeable increase in aliasings, clock whistles, or other disasters.
The R5609 is difficult to get hold of at the best of times, and it's also rather expensive (approx. £27 as a 1-off in 1983), so it's probably best to go direct to the horse's mouth, EG&G Reticon, (Contact Details). EG&G Reticon can also provide a data sheet on the R5609 which'll help to fill in the gaps about the operation of these interesting chips.
In fact, the filtering story is a good deal more complicated than merely a question of sharpness. For instance, there's evidence that very sharp filters might lead to unpleasant psychoacoustic phenomena. The argument goes something like this. The brain expects a continuum of frequencies over the audible (and possibly sub-and super-audible) spectrum. If some fool comes along and plants a whacking great filter slope reminiscent of a Sarajevo slalom run right in the middle of this, the brain's inclined to wonder what the Hell has happened and feels pretty miffed as a consequence.
So, if in the design stage it's a question of either using very sharp and expensive filters at a lower sampling-rate (around 32kHz, for instance), or less sharp filters at a higher sampling-rate (in excess of 50kHz, to play safe) the latter seems to be the best bet.
Another point to bear in mind is that a high sampling-rate means that high harmonics can be outputted with ease, whereas a low sampling-rate is always going to mean some sort of compromise when playing high notes with lots of high harmonics (though you've always got the option of just putting up with the aliasings).
To complicate matters further, filters have a habit of adding their own whims and fancies to whatever's being passed through them because of their inherent transient response. For instance, the Sony standard for Compact Disc samples sound data at the rate of 44.1 kHz and then passes the DAC output through a sharp low-pass filter. But because this is a fairly high sample-rate, the main requirement of the filter is to avoid burning out tweeters, leading bias oscillators astray, and generally rodgering the direction-finding capability of your friendly neighbourhood bat population. Even so, hi-fi pundits are complaining that the Sony Compact Disc low-pass filtering introduces phase distortion in the high register, a point that may add credence to the much-voiced opinion that the Compact Disc is tiring to listen to.
A classic demonstration aimed at convincing an audience of computer musicians that digital audio was positively injurious to one's health was perpetuated last year at a Stateside symposium. A group of people were made to stand on stage and listen to classical music on Compact Disc over headphones. It is reported that 'a significant number of the group developed involuntary repetitive motor activity after a short period of listening', and it was claimed this was entirely due to the insidious effect of digital audio on the brain. Hmmm. So where was the control group, then?
To be honest, though, I'm not entirely unswayed by this criticism of digital audio, and a case in point is an experience I had with the Synclavier. The Synclavier has the simplest of all low-pass filters on its output (just a capacitor to ground), so it's tempting to remove this and see what effect it has on the sound. In fact, performing that capacitotomy doesn't result in a vast difference to the perceived sound quality (hardly surprising since it uses a 50kHz sample-rate), but it didn't take long before I started to feel distinctly uncomfortable - something like having my head in an invisible vice.
Now, it's obviously going OTT to label digital sound as a potential bio-hazard, but there is just a chance that very high frequencies may have some sort of subliminal effect on the brain without actually being perceived as sound. And if that's ever shown to be the case, the humble low-pass filter is going to be a jolly useful chap to have on your side!
Feature by David Ellis
Previous article in this issue:
Next article in this issue:
mu:zines is the result of thousands of hours of effort, and will require many thousands more going forward to reach our goals of getting all this content online.
If you value this resource, you can support this project - it really helps!