[sdiy] MIDI bytestream parser

Jason Proctor jason at redfish.net
Wed Nov 17 06:20:07 CET 2010


>On 11/16/2010 3:16 PM, Neil Johnson wrote:
>
>>A hash generates a value from a small set of values given a value
>from a large set. There are bound to be clashes (multiple input values
>hash to the same output value), but in this specific case the sparse
>input values do not cause clashes in the output values, so it all works
>out nicely :) The end result is the values 0x80, 0x90, 0xA0, 0xB0,
>0xC0, 0xD0, 0xE0, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6 and 0xF7
>are hashed, without clashing, onto the range 0-15.
>
>Hi Neil,
>
>But what if the output of the hash created collisions?
>
>I suppose you could look for a different hash that was collision
>free, or you could let the collision occur, and then sort it
>out later.
>
>I guess I answered my own question.  :-p

another option might be a jumptable off (((byte - 0x80) >> 4) - 0x8), 
with a further jumptable for the selector off 0xf0.

first jumptable has 8 entries, the second has 16.

makes me less nervous than a hashtable, and faster too :-)




More information about the Synth-diy mailing list