I’m trying to setup midi routing and channel filtering per track in such a way that (1) each track may connect to the same or different physical midi devices, (2) each track must be able to filter midi channels and (3) configuration must be saved per project/edit.
At first, I thought of using VirtualMidiInputDevice, creating one one for each track and configuring them to achieve objectives 1 and 2. This worked but it not clear how to achieve objective 3: per project/edit configuration. In addition, it is cumbersome to manage these devices and I wondered if there was a more idiomatic way.
I found out about the trackDevices in AudioTrack but after investigation, it seems that their purpose is to redirect the track output and not to connect and filter the track input. Am I right on this point or am I missing something ?
Finally I found out about the EditInputDevice that lives in the Edit but I’m not sure what this object does and how to use it.
Note that in my application, I will only use a single Edit at any point in time (though user may load a new one of course).
Is my first approach the right one ? How to manage project/edit configuration (instead of global settings) ?
It would be simpler to use the sample MidiInputDeviceInstance and assign it to all tracks but you can’t set the filter per track, its a MidiInputDeviceInstance, not InputDeviceInstance::Destination which is what makes the connection to each track.
Do you need to filter it at the input or can you apply a filter to the output before the plugins?
At the moment there’s no way to save this local to the Edit, you’d have to save some meta-data and reload the global state of the MidiInputDeviceInstances when you open them.
I guess I can filter the output before the plugins ! The specification is that a single midi device can control multiple tracks, each listening to a configurable channel (can be shared or different for each).
Ok that’s what I thought since I saw that devices are stored in the PropertyStorage if I’m remembering correctly.
So if I understand correctly there’s two ways of doing it:
Create a VirtualMidiInputDevice per track, connect them to real devices and filter midi channels with them.
Directly connect the MidiInputDeviceInstance to tracks and use a midi filtering plugin to ignore unused channels.
In both case, we need to store metadata in the Edit to save these settings per Edit and update the state of devices (managing errors if the device has been disconnected in the meantime, …).