Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua

Home Page:http://www.hammerspoon.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hs.midi and multiple devices with the same name

woodensquares opened this issue · 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?

That is a very good question!

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

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

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 :)

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