MidiInput used as GUI controller

Hi There,
I’ve created a ApplicationCommandManager kind of class wich uses Midi messages as shortcuts. So in fact it is an MidiCommandManager.
When i receive messages from a MidiInputCallback i forward them to my MidiCommandManager, however i don’t think i’m doing it in a right way because now i am locking the messagemanager each time i receive a midi message wich i think is not how it should be done.
here is my code:

class ApplicationMidiCallback : public MidiInputCallback
	OwnedArray<MidiInput> midiInputs;
	MidiCommandManager* mcm;

	  apc = 0;

      StringArray mArray = MidiInput::getDevices();
      for (int i = 0; i < mArray.size(); ++i) {
		  midiInputs.add( MidiInput::openDevice(i, this) );

	  mcm =  MidiCommandManager::getInstance();


		for (int i=0; i < midiInputs.size(); ++i) {

	void handleIncomingMidiMessage (MidiInput *source, const MidiMessage &message)
		const MessageManagerLock mmLock;
		mcm->handleMidiMessage( message );


Would i need to create a sort of buffer of midimessages and fill this with the new messages and let the MidiCommandManger check for new messages? Has anyone got suggestions on how to do this.

any help is appreciated,

I’d suggest putting the midi data into a Message object and posting it to the handler to deal with (make it a MessageListener).

Thanx, For the GUI part this would indeed be nice solution.
But i also use the midimessages to control my render engine, and we need the lowest possible latency. I guess the messagemanager is controlled by the main message thread, so using messages will cause a big delay.

How should i send messages to my engine without stalling the midiInput thread.

For that, you can just use a midibuffer and a criticalsection.

So i need to fill the Midibuffer with the incoming messages.
And use an MidiBuffer::Iterator in another thread to read the messages from this buffer both using the same criticalsection ?

yes, that’s the idea.

Or use a MidiMessageCollector…

Im trying to trigger commands from handleIncomingMidiMessage with invokeDirectly (is this i bad idea?), problem is that the command Flags then arent set (in perform()) like I did in getCommandInfo - so i cant use the isTicked flag e.g…

Building a new ApplicationCommandManager with Midi seems kind of a huge step, or would this be very easy??

greetz equinox