Can you make multiple connections to a Midi Port?


#1

I am recording and replaying midi streams to an external synthesizer. I need to be able to hook multiple tracks to different channels of the same midi port. I am filtering by port in the handleIncomingMidiMessage code, but only the first attempt to connect to the port succeeds. Is it not possible to make multiple connections to the same input and output port? I have multiple instances of a class that wants to connect to any of the 20 ports on my machine and use any of the 16 channels. But some need to use the same port, different channels.

Even if I record on one port and then change ports to another and test by playing it back, I can not connect a different class instance to the first port I recorded through.
I have AudioDeviceManager deviceManager; declared locally in each instance of the class. Whichever one I use for a port first works and others afterwards fail.

Multiple tracks work as long as each is linked to a different midi port, but that is very limiting.

Is there a trick to sharing a midi ports?


#2

I can make multiple connections to an output port, just not an input port. First connection there wins.


#3

Presumably you’re talking about Windows, where the drivers can only be opened once.

Easiest fix: Go via an AudioDeviceManager, which will open the midi devices once and then share them for multiple listeners.


#4

Thanks. Yes I build on Windows and then recompile on Mac.
That was the only thing I could think to do - make a class just to open a single Midi in connection and then pass it to any tracks that wanted to use it as input AND were actually using it at the moment. Wanted to make sure I wasn’t missing something major as I learn to use JUCE. Didn’t know windows only allowed a single connection. My previous apps never needed multiple ports.