??? 07/13/04 02:55 Read: times |
#74121 - serial buffer and MIDI message handling |
I am developing a MIDI sequencer which has two pairs of MIDI I/O. I have the interrupt routines set up for a circular buffer, but now I have the challenge of dealing with the variable length multi byte MIDI messages.
I have been toying with a scheme to schedule a byte parser using a timer and then have a byte counter variable decrement based on what type of MIDI message is specified by the first byte (switch statement). The counter always starts at two and then either jumping to 0 or 1 as the message is reconstructed. System exclusive would have to be a different animal of course. I have quite a few examples of a circular serial buffer to handle TX/RX of single bytes, but I haven't been able to find any examples of multi byte message handling using the buffer as a start. I saw a reference to an example by Hans V. P. but it was a very old post and the example was never posted... so does anyone have any code they'd like to share? Preferably in C (Keil), but ASM would do as well. Thanks! John K. |