kallaballa / MidiPatch

MidiPatch is a scriptable and modular real-time software synthesizer using the PatchScript API
GNU Affero General Public License v3.0
12 stars 2 forks source link

Research how to do cross-platform USB-MIDI device detection #114

Open kallaballa opened 4 years ago

kallaballa commented 4 years ago

We'd like to be able to detect what exact midi devices are connected to MidiPatch. That enables us to automatically map the MIDI device to the current patch if someone already created a profile for that device.

seclorum commented 4 years ago

TODO: Test all available USB/MIDI Hardware controllers and see what they respond to the MIDI Identify Device message:

http://midi.teragonaudio.com/tech/midispec/identity.htm

See also:

http://midi.teragonaudio.com/tech/midispec.htm

Like, if the LPD or LPK and Arturia controller &etc devices respond to this MIDI message, that'd be a good cross-platform solution ..

Otherwise, platform-specific shims for doing device ID (USB VID/PID identity) could be another option, but would probably require a bit of glue on each platform ..

kallaballa commented 4 years ago

Sounds to me like we should implement both, because we can't test all the synths. what do you think?

seclorum commented 4 years ago

I agree we should probably support multiple methods - so to start, we can use MIDI ID detection for dev purposes, but then the next step would be to add a 'manual configuration' mechanism that allows the end-user to create/share their own profiles for other devices.

I will make a test setup to find out what the situation is with the devices we have at hand.

seclorum commented 4 years ago

Would need to define the following events that can be triggered by MIDI messages:

This way, a user could use a single Note Off (for example) message to increment which parameter group is selected, and this would then also set the MIDI CC offset value accordingly, while also updating the GUI - or, in the case of a rotary encoder which sends MIDI CC 0-127, we could use the CC Value as the "selected control group" index, with the same effect. That way we can accommodate diverse controllers.

Perhaps there are some other engine-side event/command types to be defined?

seclorum commented 4 years ago

Maybe "Switch Tabs" would be a nice option to have as well.

kallaballa commented 4 years ago

I agree

kallaballa commented 4 years ago

This library (https://github.com/pololu/libusbp) seems to do the job, except there are some weird limitations that i do not fully understand:

The library only supports certain types of USB devices.

On Windows, any generic interface that you want to access with this library must use WinUSB as its driver, so you will need to provide a driver package or use some other mechanism to make sure WinUSB is installed. The generic interface must have a registry key named "DeviceInterfaceGUIDs" which is a REG_MULTI_SZ, and the first string in the key must be a valid GUID. The "DeviceInterfaceGUID" key is not supported.

Both composite and non-composite devices are supported.

There is no support for switching device configurations or switching between alternate settings of an interface.

There is no support for accessing a generic interface that is included in an interface association and is not the first interface in the association.

What does "certain types of usb devices" mean? also is this a limitation for all platforms? I have no idea what the consequences of the windows limitations are. are usb devices usually using "WinUSB". Are those registry keys usual used? What is the standard way to get device information from usb devices on windows, without relying on certain drivers and registry keys?