??? 07/13/04 15:20 Read: times |
#74171 - RE: serial buffer and MIDI message handling Responding to: ???'s previous message |
Lets say you wanted to do a box that transposed the value of the note on/off messages and just passed through every thing else - with MIDI we know the first byte of a command has bit 7 set so we can use that to determine that we have a new message. In the ISR(interrupt service routine) we can do a simple check of the command value to see if it is a note on/off message, if this is the case we would set a flag to say 'translate the next byte that comes through' otherwise we would just transmit out the incoming value without modification. The mainline code just has to do the user interface and pass the translate info to the ISR. The net result is that we don't use ram to buffer the data and we pass the data through with only a 1 character delay - you can't get too much faster than that! Most MIDI boxes that intersperse between units will just trap a small number of message types and perform simple 'magic' on the values therefore most of this can be done in the ISR. You've got 305uS between bytes to perform your magic. |