Lab Notes: Computer Music Without the Computer
or: What to do 'til your processor arrives.
I realize that a lot of you will respond to the introduction of the 8780 Equally Tempered D/A with a frustrated, "But, I don't HAVE a computer."
Here's a little surprise. You don't really need a computer to do some very interesting and useful things with the 8780. You are going to need some additional hardware, as we'll see in a moment, but it's not only inexpensive, it's also equipment that you'll need for processor interfacing later on anyway. You're not building something that will be scrapped when your computer arrives, just getting a head start. Getting READY:_, so to speak.
Let's shift our mental gears for a minute, and instead of thinking of the 8780 as a computer peripheral, we'll consider it in terms of being a digital sample and hold.
Our analog S/H circuits are acceptable, but they will always drift because they store information by charging a capacitor. Even if we were able to miraculously devise a capacitor with no leakage, we still have to measure the charge on the capacitor; and whatever circuit we use to do that will itself eventually drain away all the charge (I think that a Mr. Heisenberg had something to say about this, but I'm not certain). With a digital S/H, we don't have that problem, because we're storing the information as a pattern of 1's and 0's.
To use our new digital S/H we need some way to provide it with the 1's and 0's it needs to decide what voltage to produce. We need some way to "encode" our AGO keyboards.
There are lots of ways to do this, including the simple expedient shown in figure 1.
This is frequently referred to as a "brute force" encoder. When a switch closes, any diode connected to the switch line forward biases, causing a 1 to appear on the data line connected to it. The diodes are there in the first place to prevent "sneak" current paths back through the matrix. This is an acceptable encoder as long as you assume that only one key is going to be down at a time. But, when two keys are pressed simultaneously, the diodes act like OR gates and the data that comes out may or may not (most probably not) represent those keys. If, for example, we were to press the first two keys down at the same time, data lines D0 and D1 would both go high. Exactly the same situation that we had defined in figure 1 as being an indication that key 3 was down: BUMMER
A more popular approach (because it works better) is to "scan" the keyboard a switch at a time to see if any are closed. There are LSI chips that do this with a single integrated circuit package; but, while saving design time is a great temptation, we're not going to use them. They're too expensive, and worse yet, not versatile enough to do all the things that I have in mind.
So that you can follow the design that I prefer, let me turn you on to a new part:
This is called a "4051 8 channel analog multiplexer/demultiplexer". Or, just 4051. Inside the package are 8 bilateral CMOS switches. While one side of each of these switches is tied to one of the pins Y0 - Y7, the other side of all the switches are commoned and connect to pin Z. In mechanical terms, it looks like this:
One of the neater things about the 4051 is that each of those switches is individually "addressable" from the pins marked A0 - A2. If I put the binary number 000 into the address pins, switch S0 will "close". 001 causes switch to be activated, and so on to 111 which addresses S7.
You will also notice a pin labeled E. This is an enable pin that sort of says "GO" to the rest of the circuitry in the package. As long as this pin is held at a high voltage, all of the switches will be "off', but when the E pin is grounded, the switch specified by the address currently on the A pins will close.
What a terrific part. We really need to spend some time soon looking at all of the potential applications for this device. Not today, though. Today we have too many other things to do.
You're already familiar with the 4024 CMOS seven stage divider, we've used it before in other applications. Now we're going to use it again in a circuit that looks like figure 4.
This is our keyboard encoder. As far as parts go, there's not a lot to it. But it does a lot, watch.
Gates G1 and G2 along with R1 and C1 form an astable clock that feeds the seven bit counter IC1. Notice that I can start and stop the clock by raising or lowering, respectively, the line labeled SCAN. If I'm not using this line, I can simply leave it disconnected and the pull up resistor R2 will keep the clock running.
Notice that the three LSB's from the counter (DO - D2) are connected to the address pins of IC2 while the next three MSB's connect to the address pins on IC3 (we are going to temporarily forget about the seventh bit). Assuming that the counter starts counting at 000000, both IC2 and IC3's Z pins are connected to their Y0 pins. If these two Y0 lines are isolated from one another another nothing happens; but, if they are shorted together (by a switch at the point at which they cross in the matrix, for instance) then a current flows from the Z pin of IC3 to the Z pin of IC2 through R4 which is tied to the ground. The resulting voltage rise across R4 appears on the line labeled STROBE as a logical 1, which we can interpret as an indicator that a key is down.
When the clock cycles and the counter advances to 000001, it has no effect on IC3, but IC2's Z pin is now connected to it's Y1 pin. If those points in the matrix are isolated - nothing; if they're connected, we get a 1 on the strobe line. As you can see, each clock cycle advances the counter, which will have the effect of looking at each cross point in the matrix, one at a time. A STROBE results if the cross points are connected.
At any instant in time, the six bit number appearing on the data line is the number of the key being examined - in binary, and the status of the STROBE line will tell us whether that key is up or down.
It will also be handy at times to have a line that goes low when a down key is found, so G3 is used as an inverter to provide the complement of STROBE - STROBE. (I'm tempted to say son-of-strobe, but actually NOT strobe.)
One subtle point about the 4051's that we overlooked above: the line from the clock also connects to the E pin of IC3. The effect of this is to allow a STROBE to occur only during negative half-cycles of the clock (immediately after the counter changes state) like this:
which assumes that key 000010 is down. This, as well as the lag network R6 and C3, is done for timing considerations.
Also, getting back to the counter again for a moment, we have a reset available; and while I can't think of a use for it right now, one may come up later. I bring it out on a line with a pull down resistor, R3, and label the line RESET. Raising this line to a 1 will reset the counter. Also, that seventh bit that we conveniently forgot, we can now bring out on a line labeled START. In computer application this line will serve as an indication that a scan is just starting or ending.
So, that's our all-purpose, super-gee-whiz keyboard encoder. In all of the drawings, I've shown it operating from a 5 volt supply because in computer applications we're going to be tapping power from the processor; but we're using CMOS logic here and the big reason is that it likes all different kinds of supply voltages - anywhere from 3 to 15 volts. If we retro-fit this stuff into a 4782 Road Keyboard (which as you might expect, I highly recommend) we can easily use the +9v. part of the supply that's already there to power both the encoder and the D/A.
The encoder can handle up to 64 switches (the number of cross-points in the matrix) and it will obviously work with a 5 octave keyboard. We really want to concentrate on a 37 note unit, though, since this is our standard.
No matter whose keyboards we are going to use, we are probably going to have to make some changes in the switch busses first. I'll show you on one of ours. If yours is different, I'm sure you can figure out something.
PAIA keyboards (and most others, too)- have two busses: one of which boils down to a single switch that is closed as long as any key is down. With analog S/H's, this is a signal to the circuitry to do its stuff. We don't need this anymore.
The second buss is really 37 switches, with one side of each switch tied to a common connection. We could represent it like this:
The switch contacts that are not commoned would ordinarily go to the voltage divider board in an analog system.
We need to break these switches down into groups of 8 (giving us 4 such groups with a group of 5 keys left over) by cutting small sections (about 1/8 inch or so) out of the buss rod that runs the length of the keyboard. When you do this, don't forget that you have the keyboard upside down. Be sure that the first cut is between the first G and G# on the keyboard. I ran into structural problems after cutting the buss rod; one section of it was supported at only a single point. An easy fix for this problem was to slip short sections of clear tubing (spagetti) over the adjacent ends of the cuts, providing both insulation of the buss section and mechanical rigidity. When you're finished, what you have could be represented by figure 7.
Now we buss together the individual key switches from each group by connecting together all of the first keys in each group, all the second keys in each group, etc. Notice that again to prevent sneak current paths which could generate "phantom" keys if multiple switches were closed, we've added a diode in series with each key. When we're done, we have what's shown in figure 8.
If we now redraw what we've got and superimpose it on the matrix, we have what's shown in figure 9.
You probably noticed that the first key does not begin at note 000000, but rather picks up from row 2 of the matrix; equivalent to making it key number 010000 from the encoder's standpoint, and transposing the keyboard 16 semi-tones up-scale from the D/A's point of view.
IT DOESN'T MATTER WHERE THE FIRST KEY STARTS.
Between the pitch knobs on our oscillators and the one on the D/A, we will be able to "put" the oscillator in any pitch range we want anyway.
There are a couple of good reasons for starting with key number 010000; First, I have a few computer things in mind for keys 000000 through 000111, and I want to hold them in reserve. Also, one of the things that our computer is eventually going to do for us is take care of transpositions into a new key signature, which will simply be a matter of adding to, or subtracting from, the note data the number of semi-tones by which we want to transpose. If my first key is 000000, I'm going to have a hard time transposing it down scale.
Now that I have the keyboard connected to the encoder, I'm ready to start doing things. Like replacing my old analog S/H with this shiny new digital model. There are lots of ways that I can do this. One is shown in figure 10.
Assuming that no keys are down, the encoder's STROBE line is at a 0 and STROBE is at a 1, making the RDY on the D/A high. The 8780's input latches are in a holding state and the activity on the data lines D0-D6 is invisible to the converter. This is fortunate, since the data lines are "counting" as the encoder continually looks at the keyboard.
Now, we push down a key. For the purpose of illustration let's say that it's the first key, number 010000. When the data lines next reach the state 010000, the encoder finds that that key is down, and because of that, the STROBE line goes low which both stops the encoder's clock and takes the D/A's RDY line to a 0 putting the D/A's latches in a pass state. The new note data (010000) is strobed into the converter and a control voltage representing that key appears at the control voltage output of the D/A. The STROBE line from the encoder also connects to the D6 input of the D/A, which appears at the D/A output panel as the first trigger flag (F1), so we have a trigger showing that a key is down. And this trigger is used the same way we would a trigger from the analog system.
As long as the key is down, the system is going to sit in this configuration. But, when I release the key, new things happen. Almost simultaneously STROBE goes low and removes the trigger flag D0 (which indicates that the key is now up) and STROBE goes high. The encoder's clock starts again (looking for the next key down) and the RDY line on the D/A is forced high putting the latches in a holding condition - and what they're holding is data on the last key that was down.
This is behaving exactly like the old analog system that we had, except, as I already mentioned, it doesn't drift. AND it gets rid of that annoying "in between" note that we had with the old keyboard if two notes were pressed at the same time (since the clock stops, the encoder can "see" only one down key at a time). AND, it doesn't have 37 adjustments to time it; now there are none.
Let me show you something that this keyboard can do that our others can't.
Suppose that we remove the wire connection between the encoder's STROBE output and SCAN input. You will remember that this was the thing that caused the clock to stop when a key was found down. If we replace the wire with a capacitor, say about .22 mfd. or so, we have generated a little time delay in this loop. The clock will stop when a key is found down, but only temporarily - until the capacitor discharges - then it is going to go looking for the next key down. If, in the process of searching, the encoder finds another key down, it will strobe it into the latches, hold for the time delay, and then go searching again. With this arrangement, if two keys are held down, the output of the D/A will alternate between the two, and what we will hear is a trilling between these two notes. If three keys are held down, each note will be heard in turn and while this is not polytonic by any stretch of the imagination, it can certainly sound that way.
Can you imagine what the effect of pushing down a large number of keys will be? I call it the "orgasmatronic glide" but everyone here thinks that's a terrible name.
Anyway, the arpeggiation gimmick is slick and if you wish it can be left in place and bypassed with a switch when not used as shown in figure 11.
Here's another one.
You may have noticed that there is a switch in the encoder that I hadn't mentioned; the switch labeled (innocuously) RND. This switch activates the STROBE line briefly whether or not any keys are down, and that produces an interesting effect.
Every time that I press this button, whatever number happens to be on the data buss at that instant will be strobed into the D/A. Since the encoder clock is working very fast, there is no way to know in advance what the number on the data lines will be. As you've probably guessed, RND stands for RANDOM, and that is the effect of this button. It causes a random note to be strobed into the D/A. If I apply a low speed square wave clock to the point in the circuit marked A the encoder will throw out random notes at the tempo of the slow clock. We can make a suitable clock as shown in figure 12. There is an extra package of gates on the encoder board just for things like this.
Out of space and out of time, again. And so much left to do. It will have to wait for next time.
Speaking of next time - here are some things that we're going to do: We're going to look at a memory add-on for the encoder, D/A combination that will allow you to do some terrific digital sequencer things. We're also going to look at an expansion system that will convert what we've done so far into a polytonic (phonic) keyboard. Also we'll have a story on a touch keyboard - the easy way, and will look at ways that this kind of thing can be tied into our encoder, D/A set-up.
And, I think, our computer will be ready. We've put a lot of time into configuring it for maximum usefulness either as a stand-alone micro-processor trainer or for use with the music stuff. I believe that the time has been well spent. When you see all of the things that this system will do for you it's going to: BLOW YOU AWAY. No kidding.
Feature by John Simonton
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!