hammerspoon icon indicating copy to clipboard operation
hammerspoon copied to clipboard

hs.midi and multiple devices with the same name

Open woodensquares opened this issue 2 years ago • 3 comments

I have two launchpads connected to my mac, and hs.midi in its devices/virtual devices reports for both "Launchpad", this means that unless I am missing something obvious I can't create a listener that works for both (since the new call want a device name): would it be possible for hs.midi to automatically enumerate them in some way (say appending :a, :b, ... to the name) to enable individual addressing?

woodensquares avatar Apr 21 '22 15:04 woodensquares

That is a very good question!

If you type this in the Console, what does it return?

hs.inspect(hs.midi.devices())

latenitefilms avatar Apr 24 '22 06:04 latenitefilms

yeah, that's what I meant, both devices and virtualdevices return something like ..., "Launchpad", "Launchpad", ... so I think the enumeration logic should keep a table of seen device names and if the currently enumerated device has already been seen it could append ":a", ":b" etc.

I can try to see if I can get it to work and open a PR, unless you already know what to change in which case it might be faster for you to do it :)

woodensquares avatar Apr 24 '22 11:04 woodensquares

I was doing some investigating and apparently you can rename midi devices in the "audio and midi setup" control panel, if I do that then the devices call does return my renamed names so I can actually distinguish them (interesting the virtual devices still both say Launchpad). Given this this I don't need this fix for my use case, however it probably would be nice (possibly for other devices needing to distinguish virtual inputs) if in both the normal and virtual case repeated device names were disambiguated

woodensquares avatar Apr 24 '22 20:04 woodensquares