FMMT666 / launchpad.py

Novation Launchpad (and Midi Fighter) control suite for Python
Other
350 stars 59 forks source link

Launchpad Classic being detected as Launchpad Pro #39

Closed nimaid closed 5 years ago

nimaid commented 5 years ago

Several users of my program which uses launchpad.py have reported their Launchpad Classic being detected as a Pro, thereby causing major issues. This only appears to happen to some Launchpads.

Here is a picture of one of the offending devices Here is the sticker on the back

And here is a test program which encapsulates the Launchpad detection code in my program:

try:
    import launchpad_py as launchpad
except ImportError:
    try:
        import launchpad
    except ImportError:
        sys.exit("[LPHK] Error loading launchpad.py")

lp = launchpad.Launchpad()

if lp.Check( 0, "mk2" ):
    lp = launchpad.LaunchpadMk2()
    if lp.Open( 0, "mk2" ):
        print('Connected to MkII! Yay!')
    else:
        raise Exception('MkII detected, but connection failed!')
elif lp.Check( 0, "pro" ):
    lp = launchpad.LaunchpadPro()
    if lp.Open( 0, "pro" ):
        print('Connected to Pro! Yay!')
    else:
        raise Exception('Pro detected, but connection failed!')
elif lp.Check( 0, "control xl" ) or lp.Check( 0, "launchkey" ) or lp.Check( 0, "dicer" ):
    raise Exception('Unsupported device detected!')
elif lp.Check():
    if lp.Open():
        print('Connected to Classic/Mini/S! Yay!')
    else:
        raise Exception('Classic/Mini/S detected, but connection failed!')
else:
    raise Exception('Launchpad appears to be unplugged!')

input("Press Enter to exit...")

This returns "Connected to Pro! Yay!" in the situations described above.

While I personally do not own a device that is incorrectly detected, I have a user on Discord who does and is eager to provide any additional info that may help you resolve this issue. Thank you for your hard work on this fantastic project!

FMMT666 commented 5 years ago

The Launchpads are identified by their names. Please see method "Open()" in "Readme.md". They also can be overridden.

You can check the name of the attached devices with

lp = launchpad.Launchpad()
lp.ListAll()

Example output ("Mini" on a Mac):

('CoreMIDI', 'Launchpad Mini', 1, 0, 0)
('CoreMIDI', 'Launchpad Mini', 0, 1, 0)

Could you post the results here?

nimaid commented 5 years ago

Here is the output of that command, run by a user on Discord:

pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
(b'MMSystem', b'Microsoft MIDI Mapper', 0, 1, 0)
(b'MMSystem', b'Mbox Pro External', 1, 0, 0)
(b'MMSystem', b'Mbox Pro Control', 1, 0, 0)
(b'MMSystem', b'2- Launchpad', 1, 0, 0)
(b'MMSystem', b'Microsoft GS Wavetable Synth', 0, 1, 0)
(b'MMSystem', b'Mbox Pro External', 0, 1, 0)
(b'MMSystem', b'Mbox Pro Control', 0, 1, 0)
(b'MMSystem', b'2- Launchpad', 0, 1, 0)

Please let me know if you need anything else to help resolve this issue.

nimaid commented 5 years ago

I resolved this. Here is how I fixed my detection method:

lp = launchpad.Launchpad()

if lp.Check( 0, "Launchpad MK2" ):
    lp = launchpad.LaunchpadMk2()
    if lp.Open( 0, "Launchpad MK2" ):
        print('Connected to MkII! Yay!')
    else:
        raise Exception('MkII detected, but connection failed!')
elif lp.Check( 0, "Launchpad Pro" ):
    lp = launchpad.LaunchpadPro()
    if lp.Open( 0, "Launchpad Pro" ):
        print('Connected to Pro! Yay!')
    else:
        raise Exception('Pro detected, but connection failed!')
elif lp.Check( 0, "control xl" ) or lp.Check( 0, "launchkey" ) or lp.Check( 0, "dicer" ):
    raise Exception('Unsupported device detected!')
elif lp.Check():
    if lp.Open():
        print('Connected to Classic/Mini/S! Yay!')
    else:
        raise Exception('Classic/Mini/S detected, but connection failed!')
else:
    raise Exception('Launchpad appears to be unplugged!')
FMMT666 commented 5 years ago

Yep, maybe just looking for "Pro" was a baaad idea. Guess I will change that. Thx for reporting.