[sdiy] MIDI bytestream parser
Olivier Gillet
ol.gillet at gmail.com
Tue Nov 16 11:51:36 CET 2010
> 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?
When I mean user I really mean "user of the library". It looks like
Neil's library exposes to the user of the library the channel numbers
as 1-16. Just look here:
http://code.google.com/p/miby/source/browse/trunk/src/miby.c#148
> 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?
Switch statements are likely to generate heavier code, because some
compilers are unable to optimize them properly as jump tables - and
they end up being compiled as a bunch of comparison / jump. Given that
this kind of code could very well be embedded on platforms with 2 or
4k of code memory with lousy compilers, this is a sane thing to do.
Olivier
More information about the Synth-diy
mailing list