obeezzy / lpminimk3

Python API for the Launchpad Mini MK3
https://pypi.org/project/lpminimk3/
MIT License
25 stars 2 forks source link

find_launchpads() method broken in Windows 10 #95

Closed matthewwachter closed 3 years ago

matthewwachter commented 3 years ago

There seems to be an issue with the SystemMidiPortParser class for windows.

This is what MidiOut and MidiIn return on my system:

['Microsoft GS Wavetable Synth 0', 'LPMiniMK3 MIDI 1', 'MIDIOUT2 (LPMiniMK3 MIDI) 2'] ['LPMiniMK3 MIDI 0', 'MIDIIN2 (LPMiniMK3 MIDI) 1']

So the find_launchpads() method doesn't find it because the prefixes do not include the windows version and if I add them to the list of prefixes it has an issue parsing it. (e.g 'LPMiniMK3 MIDI')

I think the way you have it set it up it's expecting a ":" in the port name which doesn't appear to be there in windows (or at least on my machine).

obeezzy commented 3 years ago

@matthewwachter, I currently don't have a Windows computer to test my code changes with so I just made a commit based on what SystemMidiPortParser returns on your PC. I will test it once I get the chance.

matthewwachter commented 3 years ago

@obeezzy nice work! I always appreciate a good regular expression solution.

So this got me past the parsing issue but it did reveal another issue with setting the client name not being allowed on my system via the rtmidi library. I was able to resolve the issue by commenting out lines 185 and 192 in _utils.py (in the open method of the MidiPort class).

I'm not sure if these are necessary for linux/mac but it seems to be functioning normally on my system without setting the client name.

Here's the full output of error:

  File "C:\Users\W\AppData\Local\Programs\Python\Python37\lib\site-packages\lpminimk3\__init__.py", line 50, in open
    self._midi_client.open(interface)
  File "C:\Users\W\AppData\Local\Programs\Python\Python37\lib\site-packages\lpminimk3\_core\_utils.py", line 472, in open
    self.midi_in_port.open()
  File "C:\Users\W\AppData\Local\Programs\Python\Python37\lib\site-packages\lpminimk3\_core\_utils.py", line 192, in open
    self._midi_in.set_client_name(MidiPort.DEFAULT_CLIENT_NAME)
  File "src\_rtmidi.pyx", line 686, in rtmidi._rtmidi.MidiBase.set_client_name
NotImplementedError: API backend does not support changing the client name.
obeezzy commented 3 years ago

@matthewwachter, thanks for your feedback! I've added an if condition to skip setting the client name on Windows.

matthewwachter commented 3 years ago

Yep that works well for me! Thanks!

yatesdr commented 1 year ago

This issue cropped up for me in MacOS 13.3.1 using python 3.9.

Same issue, solved by commenting out these same lines in utils.py.

Commenting as it does not seem to be limited to Windows at this time.

Error showed as below: Traceback (most recent call last): File "test.py", line 8, in lp.open() File "/opt/homebrew/lib/python3.9/site-packages/lpminimk3/_lpminimk3.py", line 49, in open self._midi_client.open(interface) File "/opt/homebrew/lib/python3.9/site-packages/lpminimk3/_core/utils.py", line 481, in open self.midi_in_port.open() File "/opt/homebrew/lib/python3.9/site-packages/lpminimk3/_core/utils.py", line 197, in open self._midi_in.set_client_name(MidiPort.DEFAULT_CLIENT_NAME) File "src/_rtmidi.pyx", line 686, in rtmidi._rtmidi.MidiBase.set_client_name NotImplementedError: API backend does not support changing the client name.

Using CoreMIDI and otherwise a pretty generic setup.

The fix was to comment out lines 186, 187, 196, and 197 completely in utils.py, and it appears to function normally with that fix applied. If you're testing on Linux, it may be the only platform that directly supports renaming the Midi outputs, and I'd see if it makes sense to simply not do this at all to avoid bugs on other OS's.