addMidiInputCallback with mulitple MIDI inputs


Hi Jules,

in AudioDeviceManager::addMidiInputCallback, you always call removeMidiInputCallback at the beginning.
This means that you can’t have multiple MIDI inputs using the same callbacks.

Is this a bug ?
Or what is the way to achieve this ?



Ah, that looks like a throwback to the days before I added support for multiple callbacks. I’m currently messing with that class so will fix it, but would advise that you remove the removeMidiCallback() line. Of course, that gives you a problem if you have add the same callback twice and want to remove just one of them, but I’ll sort that out when I release a new version.


Oki doki


By the way.

Instead of working on fixing issues in the midi and audio code(like the DS one), what about using portaudio and portmidi inside Juce ?

I think the licence of both library allows you to do that and from my experience it works pretty fine.

When doing the StandAlone version of UVIWorkstation, I hesitated between used back portaudio and portmidi(which I used in older product which didn’t use Juce) and the juce impl.
I moved to juce because of the already done UI regarding audio and midi configuration.
Still, now that we have some beta test report, I’m thinking to move back to portaudio because of the efficiency and the number of issues reported.

Let me know what do you think



Hmm… Not crazy about chucking away such a core part of the library, really. And I’m too much of a control freak to rely on other people’s code like that!


Regarding this issue, the current code still have some issue.

Still messing with this code ?

this line still do not allow to have the same callback for multiple midi inputs

if (! midiCallbacks.contains (callback))
  midiCallbacks.add (callback);
  midiCallbackDevices.add (enabledMidiInputs[i]);

perhaps should it be

if (! midiCallbacks.contains (callback))
  midiCallbacks.add (callback);
midiCallbackDevices.add (enabledMidiInputs[i]);



Yes, I’m still messing with that code!

In fact, it should just always add it:

const ScopedLock sl (midiCallbackLock); midiCallbacks.add (callback); midiCallbackDevices.add (enabledMidiInputs[i]); break;