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
{
public:
OwnedArray<MidiInput> midiInputs;
MidiCommandManager* mcm;
ApplicationMidiCallback()
{
apc = 0;
StringArray mArray = MidiInput::getDevices();
for (int i = 0; i < mArray.size(); ++i) {
midiInputs.add( MidiInput::openDevice(i, this) );
midiInputs[midiInputs.size()-1]->start();
}
mcm = MidiCommandManager::getInstance();
}
~ApplicationMidiCallback()
{
for (int i=0; i < midiInputs.size(); ++i) {
midiInputs[i]->stop();
}
midiInputs.clear();
}
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,
Cheers,
Edwin[/code]