ofxMidi - Handling several messages at the same time

Hi,

I’m trying to link Bitwig and OF, but as there is no OSC support at the moment (out port), I’m doing it with OfxMidi.
For example, I’m trying to draw some stuff with several note. C0 draw a rect. and C1 a sphere.
So i’m using :

 if (  (midiMessage.status == MIDI_NOTE_ON )& (midiMessage.pitch == 0)){
    bDrawSphere = true;
}
else {bDrawSphere = false;}

 if (  (midiMessage.status == MIDI_NOTE_ON )& (midiMessage.pitch == 12)){
    bDrawRect = true;
}
else {bDrawRect = false;}

But only one note is supported at the same time. Like if I press C0 (draw sphere), then C1 (draw sphere+Rect) and I release C1 (nothing drawn), all my shapes are disabled because a note off messages is sent so it breaks my if condition.

Does anyone know how to make a polyphony ?

Thank !
Cyril

the problem isn’t in ofxMidi but in your code, as your routine is processed each time a midi message is received the else routine are almost always executed, switching shapes off. Try with this code

if (  (midiMessage.status == MIDI_NOTE_ON )& (midiMessage.pitch == 0)){
    bDrawSphere = true;
}

if (  (midiMessage.status == MIDI_NOTE_OFF )& (midiMessage.pitch == 0)){bDrawSphere = false;}

if (  (midiMessage.status == MIDI_NOTE_ON )& (midiMessage.pitch == 12)){
    bDrawRect = true;
}

if (  (midiMessage.status == MIDI_NOTE_OFF )& (midiMessage.pitch == 12)){bDrawRect = false;}

now the messages should correctly switch shapes on and off

Yup, it works !
But midi isn’t fast enough I think because when I draw 10+ note, some events aren’t triggered.
I use Osculator to convert midi to Osc and it seems to work better.

Thank you,

Cyril

Strange, I thought MIDI was faster than OSC, as stated here


" In terms of throughput, MIDI can actually have better throughput than OSC because it takes fewer bytes to make common MIDI messages than it does to make comparable OSC messages."