简体   繁体   English

是否可以在portmidi / pyportmidi中找出MIDI设备连接到哪个USB端口

[英]Is it possible to find out which USB port a MIDI device is connected to in portmidi / pyportmidi

I'm connecting a several identical USB-MIDI devices and talking to them using Python and pyportmidi. 我正在连接几个相同的USB-MIDI设备,并使用Python和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. 我注意到,当我在Linux上运行我的代码时,偶尔会以不同的顺序枚举设备的MIDI端口,因此我将消息发送到错误的设备。 As the devices do not have unique identifiers, I am told that I should identify them by which USB port they are connected to. 由于设备没有唯一标识符,我被告知我应该通过它们连接的USB端口来识别它们。

Is there any way to retrieve this information? 有没有办法检索这些信息? My app will run on Linux, but Mac OS support is useful for development. 我的应用程序将在Linux上运行,但Mac OS支持对开发很有用。

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. 这很烦人,因为它们通常按照合理的顺序进行枚举 - 集线器中的第一个设备是portmidi中的第一个设备,但有时它们没有 - 通常前两个设备被切换。 I have to physically move the devices without unplugging to fix them. 我必须在不拔掉插头的情况下移动设备来修复它们。

lsusb should do the trick. lsusb应该做的伎俩。 All devices and their respective hubs are listed there. 所有设备及其各自的集线器都列在那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM