neil's webbly world

me@njohnson.co.uk
 Over to the engineers... To a hardware engineer, a waveform with only two levels looks very much like a digital signal, and straight away ideas begin to form about how to do analysis and synthesis in hardware, viz: Analysis involves integrating the products of the signal with a set of Walsh functions. Integration is really just a big summation, and with Walsh functions being +1 or -1 the multiplication becomes addition and subtraction. Synthesis is almost identical - sum the products of a set of Walsh functions and their coefficients. Again, the multiplication (by +1 or -1) can be turned into addition or subtraction. The Coefficient Multiplier Right, we know that to synthesize a waveform using Walsh functions we need some sort of adder/subtractor, to be controlled by a digital signal. And, just to add some interest to the sound we create, we also want to dynamically change the value of the coefficient as we play. All of this can be done with an analogue switch and an op-amp: With one of these for each coefficient, we then sum all of the outputs together to create the final waveform, ready for further processing by our beloved VCFs and VCAs. The Digital Revolution The advent of cheap digital technology now makes Walsh function synthesis even more exciting. Instead of doing all the maths in the analogue world it can all be done in the nice, clean, antiseptic digital world, where noise is a thing of the past. Actually doing it Most synthesizer builders know a bit about additive synthesis: creating a new waveshape from basic building blocks. Well, so far the only mainstream technique for this was to use Fourier, based on sinewaves. Nice in theory, but hell in practice. Now, lets look at the implementation of a Walsh function synthesizer. In particular I will only consider the generation of the audio waveform, and not further signal processing modules (filters, envelopes, amplifiers, etc). Also, the circuits presented in this discussion are conceptual circuits meant to inspire designers to take these ideas and create proper working circuits from them. I make no apology if they seem a bit crude; they are for illustration purposes only. Right, with that out of the way, let's begin. As I see it there are four main stages in creating waveforms with Walsh functions: generate clock signal from pitch data generate Walsh functions from clock signal multiply Walsh functions by coefficients sum all products to create resultant signal These stages will be described in a different order to the one above, and once you have read them through, you will understand why. Generate the Walsh functions The core of the Walsh function synthesizer is the Walsh function generator. We use the clock signal to generate all of the required Walsh functions using a mass of logic gates and counters. But first, a bit of theory. Since we cannot create a synthesizer which used all Walsh functions, we must limit ourselves to a workable subset. Obviously, the more Walsh functions you use the more accurately you can synthesize a waveform, but the more hardware and/or software you need - it's a tradeoff. Bear in mind the number of Walsh functions used must be a power of 2 (2, 4, 8, 16, 32, 64, etc) and you can quickly use lots of hardware for creating waveforms. You gain about 6dB SNR for each doubling of the number of Walsh functions you use. So, as an illustration we might consider an 8-term Walsh function synthesizer. The theory discussed below applies equally well to a 16-term, 32-term , 64-term, etc synthesizer, it just makes the diagrams a bit easier to read. The first new bit of information to absorb is the Rademacher function. Not as frightening as it sounds, this is actually a square wave, where each next member of the set has a frequency double that of its predecessor: The relationship between Rademacher functions and Walsh functions is: WAL(2n-1,t) = R(n,t) For example, R(4,t) is the same as WAL(15,t) Now, I bet the engineers amongst you see this not as mathematics, but the output waveforms of a counter. Yes indeed, a binary counter makes a great Rademacher function generator. The next step is to go from Rademacher functions to Walsh functions. We have seen from the above that some Walsh functions can be derived directly from Rademacher functions. The others require a bit of modulo-2 mathematics - well, okay, I really mean EXOR gates. Back to theory: for N = P (+) Q WAL(N,t) = R(P,t) (+) R(Q,t) where (+) signifies modulo-2 addition So, what does this mean in practice? In modulo-2 mathematics, addition is the same as subtraction, and cannot be negative. In effect we are using EXOR gates to do the maths. So, how do we go about it? Let's make some more of the Walsh functions and you will soon see. Start with WAL(2,t). We already have WAL(1,t) and WAL(3,t), and we know, I hope, that 3 - 1 = 2, so WAL(2,t) = WAL(1,t) (+) WAL(3,t). Likewise, to make WAL(4,t) we know that 7 - 3 = 4, so WAL(4,t) = WAL(7,t) (+) WAL(3,t). Putting all this together, we have something like: Clock Generation To the left of the above diagram is a binary counter. This generates the basic clock signals for the Walsh function generator, and is itself driven by a clock generator. The fundamental frequency of the final waveform is defined by the frequency of WAL(1,t). Since this is a fraction of the driving clock signal we need to generate a clock signal that is some multiple of the desired pitch. Using a synchronous counter, which ensures all its outputs change state at the same time, we will need a clock signal with a frequency eight times that of the fundamental, WAL(1,t). There are two main approaches to generating the clock signal: analogue and digital. Both approaches have their advantages and disadvantages, and I don't really want to venture into such a politically sensitive area as the analogue-digital debate. However, he says as diplomatically as possible, here are a couple of views of both approaches: With an analogue clock source, it is easily interfaced to other analogue synth components, as it could be driven by the familiar 1V/octave scale. But, for any reasonable number of Walsh functions, eg. 32, you would need an oscillator running at 32 times the fundamental. A digital clock source can be easily controlled by a microcontroller. And, it offers greater stability than an analogue oscillator. But, interfacing to analogue synths is much more difficult, as some micro would be involved. Also, any modulation scheme would be more complex to design, requiring some involved programming of said micro. Multiply Walsh coefficients OK, now we have our set of Walsh functions oscillating up and down. The next stage is to multiply these waveforms by their respective coefficients. A simple approach to this has already been shown above in the Coefficient Multiplier, using an op-amp and analogue switch. I'm sure there are many other ways of doing this. Summing the terms The final stage in this process is to sum together all the Walsh terms (the products of the Walsh functions ans their coefficients) together. The easiest way of doing this is with a multiple-input summing amplifier. Circuits abound for this sort of thing, so I won't embarass myself and draw such a circuit here. Putting it all together We have covered all the main sections needed to build a basic Walsh function waveform generator. The clock generator takes information from the keyboard and creates a clock signal which is some multiple of the required pitch. This feeds into the Walsh function generator which generates a large set of Walsh functions. These in turn are multiplied by their respective coefficients to create a set of Walsh terms, which are all summed together to make the final waveform. Once you have the synthesized waveform it is then ready to be further processed by all manner of signal processing functions: filters, amplifiers, modulators, whatever - the list is endless. The diagram below brings together some of the above points, as well as a couple of refinements for improved signal quality. The latch after the EXOR matrix resolves logic path timing differences (direct functions, like WAL(3) will settle before a processed function, like WAL(13) due to the delays introduced by the EXOR gates). The inverter before the latch makes it operate on the oppposite edge to the counter, allowing half a clock period for the gates to settle down. The Sample & Hold on the output allows the analogue coefficient multipliers to settle down from the abrupt changes due to the Walsh functions. Some people may choose to skip the latch and run the S/H in anti-phase - it is just a matter of personal choice, and actually building some hardware and seeing exactly how well it behaves.