A program to convert aftertouch data from a KX5 into controller data for a DX21, Crikey!
Getting aftertouch from your DX21. Andy Honeybone backflips into the MIDI stream to make his pet synth do things even Yamaha never dreamed of.
TO CUT a long story short, my recently acquired Yamaha KX5 remote keyboard arrived after some pre-sale servicing with the interesting feature of generating breath controller MIDI codes instead of aftertouch. Investigation showed this to be due to swapped cable headers, but therein lay the germ of an idea for an article for this august journal.
Let me elaborate. I have a DX21 synthesiser which can be programmed to respond to key velocity data but doesn't have a touch sensitive keyboard. The KX5 gives me the hardware to generate the aforementioned data and also to send aftertouch commands. Alas, the DX21 does not respond to aftertouch and so in an attempt to emulate a DX7, a computer program was conceived to convert aftertouch data from the KX5 into controller data which the DX21 can act on. Additionally, the computer program to be described can also change the MIDI channel of incoming data to overcome the channel 1 or channel 2 transmitting limitation of the KX5. Although I cannot lay claim to have tested the code with every available keyboard/expander combination, it should work outside of the pairing described.
As of old, the code is a mixture of FORTH and its peculiar reverse polish assembler running on a BBC "B" micro fitted with a "Making Music" MIDI interface. The program is structured as a background task which is interrupt driven by the arrival of MIDI data. The computer may therefore be used to calculate royalties, advances and other financial aspects of being a rock star whilst mapping aftertouch to controller data.
The routine which does all the hard work is nmiservice which is triggered by a non-maskable interrupt. First off, this routine saves the accumulator and Y register on the stack so that they may be restored on completion of the code. The source of the interrupt is determined and should this not be the MIDI interface, the program jumps to complete the original service routine which this piece of code intercepts.
Having obtained a MIDI data byte, the first test is to find if it is a status byte. This is readily checked by monitoring the processor's negative flag which reflects the most significant bit of the data. In signed integer terms, a status byte is negative. If a status byte is found, the next test is to see if the byte is system real time. These status bytes are unique in that they do not change the running status which is a sort of memory feature designed to reduce the number of transmitted bytes and give software designers severe headaches.
Assuming that the status byte is not in the system real time class the program checks for aftertouch having previously masked the encoded channel information. If aftertouch is found the controller status byte is substituted and the designated MIDI channel is ORed. Additionally, a flag is raised to signal that controller is the current running status. If any of the remaining status conditions are found, they are simply turned around with the new channel code and the controller running status flag (touchflag) is lowered.
Meanwhile, for ordinary 7 bit MIDI data bytes, the program checks the state of touchflag and if it has been set high by the arrival of an aftertouch byte, a controller select byte is sent to prefix the data byte.
The MIDI byte transmit word (tx) expects the byte to be in the Y register and checks that the last byte has been sent before loading up the next.
The remainder of the definitions are concerned with housekeeping. The routine nmi-on resets the ACIA chip on the MIDI interface, sets the clock division factor and enables the interrupt on receiver buffer full facility. Loading a jump to nmiservice into the original interrupt service routine is the work of prepare. It is complimented by tidy-up which restores the code as it was before tinkering.
NUMIN is a modified version of the numeric input routine to be found in the Acomsoft FORTH manual. The code has been hacked to throw out negative and non-integer quantities. The definitions mm and header handle the double height title on the display while filter initialises the variables and displays brief instructions. The red function keys invoke two further programs, prompt and sel-chan which allow you to enter the controller and output MIDI channel of your choice. Remember that MIDI channel 1 is channel 0 to a computer. When typing in the listing, be careful to note the tick (') which comes before references to tx.
The KX5 is available very cheaply at many outlets and represents not only terrific posing potential but also a great deal of MIDI for your money. One of its features is a monument to the early confusion over the MIDI spec — although the manual doesn't quite put it that way. It would appear that Yamaha implemented aftertouch as controller 3 on early DX7s. To maintain compatibility, the KX5 will comply with this unique concept if turned on with the sustain button pressed. Incidentally, talking of holding keys down at power up, I recently came by the fact that if the Pitch Bend Mode switch of a DX100 is given this treatment, the direction of the modulation wheel is reversed to aid playing the thing when on a strap around the neck.
The idea of mapping the aftertouch to a controller has proved itself to be worthwhile but as yet the breath option has not been fully exploited. Certainly, the DX21 provides the same parameters for breath control as are to be found for the DX7's aftertouch, but to build the response into the voices requires more time spent huddled over the data entry slider than I currently have at my disposal. The modulation controller (1) is a highly useful setting and can send voices into bubbling discord with a modest lean on the keys. If you care to live dangerously, you can try mapping the volume controller (7) to the aftertouch to allow pressure sensitive volume — you do need a steady hand though. Late extra: Yamaha have designated controller 10 for audio panning on the FB-01. Try mapping the aftertouch to this controller for some peculiar effects.
Gear in this article:
Feature by Andy Honeybone
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!
Please note: Our yearly hosting fees are due every March, so monetary donations are especially appreciated to help meet this cost. Thank you for your support!