So, after nearly a year of studying and soldering I’ve finally got a project that is worth writing some of my own code for (hallucinogen’s 808 clone). I plan on using a modifided MBSeq to trigger the 808 through DOUT pins, saving me the need to build an AOUT which doesn’t have enough pins for all the sounds anyway. Accent will be achieved by sending some voltage level (derived with a simple voltage divider) to all the instruments and using a switch that is also triggered by a DOUT pin (this DOUT module is handy!). So, in order for this design to work each instrument needs 3 things: a short 5v pulse to trigger it, a switch to turn the accent on/off via another 5v signal and a voltage level for the accent. Now, as it is the SEQ has just about everything I need, so I really do need to do much work. All I really need to do is set DOUT pins along with the midi events that are being triggered. This has two advantages: it’s simple and it allows the sequecer to behave just like a normal MBSeq to external equipment (so I can write basslines right along with the drums ;D).
Now, after tracing through the source code a bit I’ve identified midi_event.inc as the file where most of my changes will need to be. When a midi note is triggered in a drum track I need to first read it’s value to determine which instrument it is and then set the appropriate DOUT pin(s). Here is the code fragment that most interests me:
MIDI_EVNT_Send
call MIOS_MIDI_BeginStream
;; branch depending on MIDI status
SET_BSR MIDI_EVNT0
swapf MIDI_EVNT0, W, BANKED
andlw 0x07
JUMPTABLE_2BYTES_UNSECURE ; 8 entries
rgoto MIDI_EVNT_Send_8x ; Note Off
rgoto MIDI_EVNT_Send_9x ; Note On
rgoto MIDI_EVNT_Send_Ax ; Aftertouch
rgoto MIDI_EVNT_Send_Bx ; Controller
rgoto MIDI_EVNT_Send_Cx ; Program Change
rgoto MIDI_EVNT_Send_Dx ; Channel Pressure
rgoto MIDI_EVNT_Send_Ex ; Pitch Bend
rgoto MIDI_EVNT_Send_Fx ; AOUT
;; sending three bytes:
MIDI_EVNT_Send_8x ; Note Off
MIDI_EVNT_Send_9x ; Note On
Now, aside from the fact that I don’t yet understand how the JUMPTABLE implements a switch statement there is something quite suspicious about this code.. see it yet? The functions for sending note on and off messages are empty! Surely this cannot be correct so I must not be looking in the right place, no?
Moving on from there for a miniute there is one more dilemma, to trigger the sounds I only need a very short gate signal, meaning that the note off event should be sent almost immediatly after the note on. Possibly this is easy to do by simply setting the gate length for the drum tracks to a very small value, but I suspect that even the smallest gate length is still a good bit longer than 1ms. Furthermore this would make it difficult to layer drum sounds from external equipment, so idealy there will be special handling of notes sent to DOUT pins in order to keep the gate length very short. Possibly I could simply add some simple differetiators in hardware to accomplish this as well, but additonal hardware just seems uneccessary at this point