Hi all,

Attached is a patch for Sean that allows our mapping system to handle
14-bit pitch messages in an elegant way. A regular note or CC MIDI
message contains a "status" header, a "note/control" byte indicating
the index of the control, and a final byte indicating the note
velocity or the control's value. A pitch bend MIDI message combines
the last two bytes into the LSB and MSB of a larger number. Our
mapping system was choking because we were mapping (status,
note/control) --> (mixxx control), but the "note/control" field is
part of the data for pitch messages (so we don't want to hash on
that).

The attached patch just stops us from hashing on the field we call
"midino" for pitch messages. Another minor change is that we were
using QMap before instead of QHash because I read the documentation
wrong. (We wanted to use QHash all along for fast lookups.) I also
removed the auxiliary operator< function for MidiMessage and
MixxxControl because they only existed to allow them to be used with
QMap.

Lastly, the hashing function is less-than-optimal because it has
branching in it. If someone l33t wants to rewrite this bit of code to
work without branching, please give it a shot!

uint qHash(const MidiMessage& key)
{
    if (key.getMidiType() == MIDI_PITCH) {
        //Ignore midino for pitch bend messages because those bits are
actually part of the 14-bit pitch bend payload.
        return (key.getMidiType() << 8) | (key.getMidiChannel() << 4);
    }
    else
        return (key.getMidiType() << 8) | (key.getMidiChannel() << 4)
| key.getMidiNo();
}
http://www.srm.com/qtma/davidsmidispec.html

Thanks,
Albert

Attachment: pitchpatchmishmash.diff
Description: Binary data

------------------------------------------------------------------------------
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to