Home -> Magazines -> Issues -> Articles in this issue -> View
Technically Speaking | |
Article from Making Music, December 1987 | |
Part the second of Andy Honeybone's build your own MIDI pads epic. This month he completes the software, and abandons you to your own percussive urges. Less hitting, more programming, plenty clever stuff.
Nostrils inflamed from last month's soldering marathon you will, no doubt, be itching to jar your blistered fingers against the computer keys to complete the Making Music MIDI Drum Pad trigger — and why not?
First then the "big picture' — although FORTH enforces "bottom up' programming, let's do the software description 'top down'. The ultimate definition is named 'scan pad' and that is exactly what it does. The requirement is to detect if either pad has been hit or if the user has pressed the 'stop/edit' function key. This polling forms the main program loop. Simultaneously, incoming MIDI Real-time messages are intercepted and merged with the pad output so that a drum machine may be sychronised to a sequencer and the pads used to add 'live' fills (remember the drum machine only has one MIDI in).
Key press detection is time consuming and so the number of active keys during trigger conversion has to be minimised. As a result, editing is carried out with the pads 'dead'. So as you don't make an idiot of yourself, the 'state' of the trigger (ON or OFF) is maintained in a variable of the same name and is prominently displayed. Changing the state of 'state' is performed by the highly useful and equally non-standard FORTH word 'TOGGLE' which when given a bit pattern as an argument will happily swap the nominated ones for zeros and visa versa.
The definition 'help' displays which function keys do what, and gives the current settings for the selected pad. System Real-time MIDI messages are picked up and passed on by an assembler coded interrupt routine. Because all such messages are single bytes and may appear anywhere in a MIDI data stream, merging them with the trigger output is a trivial affair (unlike true MIDI merging). The interrupt vector is set up by the definitions 'prepar' and 'nmi.on' which also serve to condition the user port bit bit directions and turn off the Beeb's maskable interrupt response.
Continuing the description of 'scan, pad', the next line of code combines the MIDI channel number with the note on status — the transmit channel being a global value for all pads. The loop proper is then begun and a 'vote' is taken to see which pad, if any, has been hit the hardest. When two pads share a common stand, the cross-talk may be such that a signal of perhaps two-thirds the value of the struck pad may be generated from the other. Cross triggering is thus rife and made even worse when the pads are triggering toms which are the same sample replayed at different rates — the results are seldom those intended. The fierce but effective solution was found to be to trigger from only the loudest pad during any one scan. If you have good separation between your pads you might consider reconstructing the code too allow simultaneous hits to be detected.
When a hit has been sensed by the interface comparator, the analogue to digital conversion is triggered and the resulting value is dumped on the stack. The note value sent after the note on status is affected by the position of the alternate note foot switch. The definition 'alt' takes the pad number (0 or 1) and adjusts the offset into the 'value' array to allow the selection of either the first two standard values or the following two alternates.
The only way to adjust the individual levels of the Roland TR505 drum machine when controlled from MIDI is to apply velocity scaling. Provision for this feat is made in 'scaler' which hacks the A/D value fresh from the converter down by a selected percentage. Because the pad output is roughly linear and the 505 is even more roughly logarithmic in velocity response (and coursely stepped at that), some jiggery pokery is required between the two. The word 'hit' contains code to square the incoming pad velocity signal and rescale the value to remain within MIDI proportions. This transfer function is open to experimentation so feel free.
Having slaved to achieve a reasonable 'feel' from the pad, it became obvious that my untrained drumming abilities were insufficient to prevent the quieter end of my attempts at subtlety from sounding like the musical equivalent of a dog's hind leg, ie uneven. The minimum velocity setting is therefore to assist those whose stick control is less than perfect. If you prefer, it is possible to raise the threshold of the interface to suppress wimpy hits, but this makes dynamic control more difficult.
The three byte note on sequence having been sent, the next stage is to clear the interface peak hold capacitors by strobing the reset lines. The significance of '10' and the argument to 'clear-peak' is that it is the sum of 8+2 which are the binary values of the user port lines used to reset the interface. The strobe has to be held for long enough for the hit to have died away or else retriggering (or autoflam) will occur. When confirmation of reset has been received, the note off sequence is sent. The user may opt for a transgression of MIDI law and prevent the transmission of this data so that suitably wayward samplers are supported. The TR505 doesn't recognise note offs anyway but beware sequencers such as the QX7 which will gum up after 16 notes if no note off commands are received.
Scanning and voting complete, the program then looks at function key 0 (key number — 114 in case you were wondering) to see if editing is required. If so, the text 'Hit pad to edit' in flashing Teletext regales the user and the program loops until the pad whose characteristics require editing is struck. The interrupts are restored and the function keys then select edit parameters which are entered in response to suitable prompts.
The rest, as they say, is detail. You've seen some of it before and if you've read this far through the piece then you either know what your doing or you're an insomniac. Which just leaves me to say. 'happy hacking' or, alternatively, 'sweet dreams'.



Feedback 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!
New issues that have been donated or scanned for us this month.
All donations and support are gratefully appreciated - thank you.
Do you have any of these magazine issues?
If so, and you can donate, lend or scan them to help complete our archive, please get in touch via the Contribute page - thanks!