|
Some words about the software
In the mainloop the status of the dip-switches are stored in a register.
I also reserved a register for 8 flags of the current filteringstatus.
Another register is used to save the current midistatus, just one bit is used to save 'running status'.
The processing of incoming midibytes is of course handles in an interruptroutine. At the end of the routine are two jumppoints:
- 'sendByte' (which puts the byte in the sendbuffer ans sends it out though TXD)
- 'filterByte' (which skips a)
First, the incoming byte is examined if its a Common/Realtime-Byte. If the Bit in the dipStatus-Register is not set, we jump to 'filterByte' else we jump to 'sendByte'. (you might wonder why i filter if dipstatus is NOT set. Thats just because of the direction i soldered the dipswitch onto the board. I wanted the dipswitch to say ON if the filtering for this switch is ENABLED. ON means -> Pin is pulled to gound, means NOT set.)
Second we distinguish between 'statusByte' or 'dataByte', we finds that out because only statusBytes have their MSB (MostSignificantBit) set. The statusByte is cleaned from its midichannel, we dont distinguish channels and filter on all channels.
Third we detect runningStatus by comparing a 'byteCounterTotal' with 3 which is set to 0 on every statusByte. If 'byteCounterTotal' exceeds 2 we set runningStatus to ON. We need this flag later.
Then the filtering of messages>2bytes starts:
Note, Pressure, (all) Controllers, Pitchbend are all the same:
____________________________________
is dipSwitch set for this message?
yes1: is statusByte suitable to actual message ?
yes2: set filterFlag for this message
no2: continue testing with next message
no1: jump to 'filterByte'
filterBit for this message is set (this must be a dataBye)?
yes3: jump to 'filterByte'
no3: continue testing with next message
____________________________________
Sysex starts with a statusByte of 0hF0 and ends with a 0hF7 - easy to filter.
At the very last place, the filtering for different controllers is made. The principle is, to hold back 3 Bytes beginning with the statusByte and send them after they were examined. In the examination there are also the Bank-Controllers for Programchange filtered out (if ProgramChange should be filtered).
One important issue is to send the statusByte if you are in runningStatus and the Controllernumber changes from a filtered Number to an UNFILTERED number. Runningstatus is NOT ended when changing controllernumbers inside runningStatus. Took some hours for my brain to got it solved. To the right you find the functiondiagram.
project finished.
|