3

I'm connecting a several identical USB-MIDI devices and talking to them using Python and pyportmidi. I have noticed that when I run my code on Linux, occasionally the MIDI ports of the devices are enumerated in a different order, so I send messages to the wrong devices. As the devices do not have unique identifiers, I am told that I should identify them by which USB port they are connected to.

Is there any way to retrieve this information? My app will run on Linux, but Mac OS support is useful for development.

It's annoying because they usually enumerate in a sensible order - the first device in the hub is the first device in portmidi, but sometimes they don't - usually the first 2 devices are switched. I have to physically move the devices without unplugging to fix them.

Charles
  • 50,943
  • 13
  • 104
  • 142
rjmunro
  • 27,203
  • 20
  • 110
  • 132
  • @Charles Why is this question not deserving of a portmidi tag? pyportmidi is just a python wrapper on portmidi. The answer that applies to portmidi will almost certainly apply to pyportmidi as well. – rjmunro May 15 '12 at 14:34
  • the question is actually about pyportmidi, not portmidi. There is no sense in creating a new tag when it would apply only to a question *not actually about* the subject defined by the tag. – Charles May 15 '12 at 16:02
  • @Charles: The answer would almost certainly apply to anyone using portmidi, whether directly, through pyPortMidi, through portmidi-ruby or any other simple wrapper. If the general portmidi answer didn't work in pyPortMidi, that would be a bug in pyPortMidi. – rjmunro May 16 '12 at 11:00

1 Answers1

0

lsusb should do the trick. All devices and their respective hubs are listed there.

devsnd
  • 7,382
  • 3
  • 42
  • 50
  • How do I map what I get from lsusb to the devices I have in pyPortMidi? – rjmunro Mar 20 '12 at 16:34
  • I didn't know pyPortMidi until now: I have looked into the sources and there should be something like `PmDeviceInfo`, which has an interface `interf` and a name `name` and should be mapped to a python function called `GetDeviceInfo`. Maybe you can find the missing link there. Unfortunately I can't test it myself right now. – devsnd Mar 20 '12 at 16:55