[sdiy] MIDI bytestream parser
Tom Wiltshire
tom at electricdruid.net
Tue Nov 16 11:36:33 CET 2010
On 16 Nov 2010, at 10:08, Olivier Gillet wrote:
>> What's all this 'real' and 'encoded' stuff? Is that what the hash is for? What are you up to?
>
> I think it's just shifting the channel number from 1-16 (what's
> exposed to the user) to 0-15 values (what's used internally by MIDI).
The MIDI bytestream never shows you the channel values as displayed to the user. Channel "One" is always '0x0'. In fact, aside from the actual user display, there isn't anywhere that MIDI channel 16 actually exists, is there?
> The HASH( ) is used to implement a lookup map from status byte to
> handler function, by observing that there are no two status byte with
> the same nibble checksum (they are either nx, with n between 8 and E
> and x for channel messages, or Fn, with n below 8 for system messages.
I'm not sure I get this. Ok, status bytes are unique, I get that. And there are only certain values possible, I get that. And we have a function to call for each type of message. So far so good.
But what's the point of the hash? A lookup map, you say? So it maps from status byte x to function y? Why not use an array, a switch statement, a long if/elseif, or any of the other possible constructions that would provide this mapping? If that is really what it's for, I still don't understand why you'd do it like this.
Thanks,
Tom
More information about the Synth-diy
mailing list