def setup_launchpad(): mode = None if launchpad.LaunchpadPro().Check(0): lp = launchpad.LaunchpadPro() if lp.Open(0): lpName = "Launchpad Pro" mode = "Pro" elif launchpad.LaunchpadProMk3().Check(0): lp = launchpad.LaunchpadProMk3() if lp.Open(0): lpName = "Launchpad Pro Mk3" mode = "ProMk3" elif launchpad.LaunchpadMiniMk3().Check(1): lp = launchpad.LaunchpadMiniMk3() if lp.Open(1): lpName = "Launchpad Mini Mk3" mode = "MiniMk3" elif launchpad.LaunchpadLPX().Check(1): lp = launchpad.LaunchpadLPX() if lp.Open(1): lpName = "Launchpad X" mode = "LPX" elif launchpad.LaunchpadMk2().Check(0): lp = launchpad.LaunchpadMk2() if lp.Open(0): lpName = "Launchpad Mk2" mode = "Mk2" elif launchpad.Dicer().Check(0): lp = launchpad.Dicer() if lp.Open(0): lpName = "Dicer" mode = "Dcr" elif launchpad.MidiFighter64().Check(0): lp = launchpad.MidiFighter64() if lp.Open(0): lpName = "Midi Fighter 64" mode = "F64" elif launchpad.Launchpad().Check(0): lp = launchpad.Launchpad() if lp.Open(0): lpName = "Launchpad Mk1/S/Mini" mode = "Mk1" if mode == None: return None return lp, mode, lpName
def __init__(self): self.controller = lpad.Launchpad() self.model_params = [] #initialize model parameters #these are tedious mappings that bind the launchpad buttons to certain motor functionality and model parameters self.init_map = {0:[23,'u'],1:[24,'u'],2:[0,'u'],3:[1,'u'],4:[2,'u'],5:[3,'u'],16:[23,'d'],17:[24,'d'],18:[0,'d'],19:[1,'d'],20:[2,'d'],21:[3,'d'],32:[4,'u'],33:[5,'u'],34:[6,'u'],35:[7,'u'],36:[8,'u'],37:[9,'u'],48:[4,'d'],49:[5,'d'],50:[6,'d'],51:[7,'d'],52:[8,'d'],53:[9,'d'],64:[10,'u'],65:[11,'u'],66:[12,'u'],67:[13,'u'],68:[14,'u'],69:[15,'u'],80:[10,'d'],81:[11,'d'],82:[12,'d'],83:[13,'d'],84:[14,'d'],85:[15,'d'],96:[16,'u'],97:[17,'u'],98:[18,'u'],99:[19,'u'],100:[20,'u'],101:[21,'u'],102:[22,'u'],112:[16,'d'],113:[17,'d'],114:[18,'d'],115:[19,'d'],116:[20,'d'],117:[21,'d'],118:[22,'d']} self.param_map = {0:100,1:100,2:100,3:100,4:100,5:100,6:100,7:100,16:85.8,17:85.8,18:85.8,19:85.8,20:85.8,21:85.8,22:85.8,23:85.8,32:71.6,33:71.6,34:71.6,35:71.6,36:71.6,37:71.6,38:71.6,39:71.6,48:57.4,49:57.4,50:57.4,51:57.4,52:57.4,53:57.4,54:57.4,55:57.4,64:43.2,65:43.2,66:43.2,67:43.2,68:43.2,69:43.2,70:43.2,71:43.2,80:29,81:29,82:29,83:29,84:29,85:29,86:29,87:29,96:14.4,97:14.4,98:14.4,99:14.4,100:14.4,101:14.4,102:14.4,103:14.4,112:0.1,113:0.1,114:0.1,115:0.1,116:0.1,117:0.1,118:0.1,119:0.1,}
def main(): ### CONNECT ### lp = launchpad.Launchpad(); if lp.Open(): print("Launchpad Mk1/S/Mini") else: return lp.Reset() lp.ButtonFlush() ############### ### INIT ### while True: if lp.ButtonChanged() is True: status=lp.ButtonStateXY() output = callback(lp,status) if output == 'exit': break elif output == 'dice': dice(lp) elif output == 'draw': draw(lp,status) t.delay(100) lp.Reset() # turn all LEDs off lp.Close() # close the Launchpad (will quit with an error due to a PyGame bug)
def main(): lp = launchpad.Launchpad() lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print("Launchpad Mk2") lp.LedCtrlString("Chloe ", red=255, green=0, blue=255, direction=-1, waitms=100) # Clear the buffer because the Launchpad remembers everything :-) lp.ButtonFlush() # butHit = 10 # while 1: # # lp.LedCtrlRaw( random.randint(0,127), random.randint(0,63), random.randint(0,63), random.randint(0,63) ) # # time.wait( 5 ) # but = lp.ButtonStateRaw() # if but != []: # butHit -= 1 # if butHit < 1: # break # print( butHit, " event: ", but ) lp.Reset() # turn all LEDs off lp.Close()
def main(): launchpad = launchpadManager.Launchpad() for path in paths: k = KeyProfile(path) profiles.append(k) UI = GUI(launchpad, profiles)
def __init__(self): self.lp = launchpad.Launchpad() self.mode = 'a' self.lp.Open() try: self.json = self.read_json(CONFIG_FILE) except: # TODO: find error thrown sys.exit( "The configuration file could not be found or was not in the format specified." ) try: self.lp.LedAllOn(0) except AttributeError: sys.exit( "The launchpad is not plugged in. Please plug in the device and try again." ) if self.lp.Open(): # initial lighting self.workspace_control(False, i3.get_workspaces(), False) self.i3_menu(None, [0, 0], None) self.refresh_letter_buttons() self.refresh_grid() # subscribe to events self.button_monitor = Subscription(self.i3_menu, self.lp) self.workspace_monitor = i3.Subscription(self.workspace_control, 'workspace')
def main(): if len(sys.argv) != 3: print(f'Usage: {sys.argv[0]} 12:00 13:00') exit() h1, m1 = sys.argv[1].split(':') h2, m2 = sys.argv[2].split(':') dt1 = datetime.now().replace(hour=int(h1), minute=int(m1), second=0, microsecond=0) dt2 = datetime.now().replace(hour=int(h2), minute=int(m2), second=0, microsecond=0) lp = launchpad.Launchpad() if not lp.Open(): print('Error open()') exit(1) clear(lp) interval = dt2.timestamp() - dt1.timestamp() try: while True: now = datetime.now().timestamp() seconds = now - dt1.timestamp() frac = seconds / interval clamped = max(0, min(1, frac)) print(' ' * 78 + '\r', end='') print(f'elapsed: {seconds:.0f} / {interval:.0f} seconds ({frac*64:.2f} / 64)\r', end='') sys.stdout.flush() display(lp, clamped) time.sleep(0.02) except KeyboardInterrupt: clear(lp) print()
def init_lp(): """ initialize the launchpad :return: launchpad object """ # create launchpad instance lp = launchpad.Launchpad() mode = check_type(lp) success = False # check for the correct launchpad if mode == "Pro": lp = launchpad.LaunchpadPro() if lp.Open(0, "pro"): success = True elif mode == "Mk2": lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): success = True else: if lp.Open(): success = True lp.LedCtrlXY(0, 0, 10, 30, 64) # speed play and pause lp.LedCtrlXY(1, 0, 10, 30, 64) lp.LedCtrlXY(2, 0, 64, 30, 0) lp.LedCtrlXY(3, 0, 0, 64, 0) lp.LedCtrlXY(7, 0, 64, 0, 0) if not success: exit(1) else: return lp
def main2(): mode = "Mk1" lp = launchpad.Launchpad() lp.Open(name="Launchpad Mini", number=0) if mode == "Mk1": lp.LedCtrlString( "TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK ", 8, 0, -1)
def __enter__(self): try: self.lp = launchpad.Launchpad() self.lp.Open() self.lp.ButtonFlush() except: self.lp = launchpad.LaunchpadEmu() return self.lp
def main(): # create an instance lp = launchpad.Launchpad(); # try the first Mk2 if lp.Check( 0, "mk2" ): lp = launchpad.LaunchpadMk2() if lp.Open( 0, "mk2" ): print( " - Launchpad Mk2: OK" ) else: print( " - Launchpad Mk2: ERROR") return # try the first Mk3 elif lp.Check( 1, "mk3" ): lp = launchpad.LaunchpadMk3() if lp.Open( 1, "mk3" ): print( " - Launchpad Mk3: OK" ) else: print( " - Launchpad Mk3: ERROR") return # try the first Pro elif lp.Check( 0, "pro" ): lp = launchpad.LaunchpadPro() if lp.Open( 0, "pro" ): print( " - Launchpad Pro: OK" ) else: print( " - Launchpad Pro: ERROR") return else: print( " - No Launchpad available" ) return lp.ButtonFlush() for i in [ 5, 21, 79, 3]: lp.LedAllOn( i ) time.wait(500) lp.LedAllOn( 0 ) colors = [ [63,0,0],[0,63,0],[0,0,63],[63,63,0],[63,0,63],[0,63,63],[63,63,63] ] for i in range(4): for y in range( i + 1, 8 - i + 1 ): for x in range( i, 8 - i ): lp.LedCtrlXY( x, y, colors[i][0], colors[i][1], colors[i][2]) time.wait(500) # turn all LEDs off lp.Reset() # close this instance lp.Close()
def open_launchpad(): lp = launchpad.Launchpad() if lp.Open(): print("Launchpad S detected") return lp print("Did not find any Launchpads, retrying...") time.wait(1000) open_launchpad()
def main(): lp = launchpad.Launchpad(); if lp.Open(): print("Launchpad Mk1/S/Mini") # create an instance lp.LedAllOn() t.delay(1000) lp.Reset() lp.ButtonFlush() totalInput = 0 status = [0, 0, False] mode = 'green' while True: if lp.ButtonChanged() is True: status = lp.ButtonStateXY() print(status) if status[0] == 8 and status[1] == 8 and status[2] is False: break elif status[0] == 8 and status[1] == 7: mode = 'red' lp.LedCtrlXY(status[0], status[1], 3, 0) lp.LedCtrlXY(8, 6, 0, 0) lp.LedCtrlXY(8, 5, 0, 0) elif status[0] == 8 and status[1] == 6: mode = 'orange' lp.LedCtrlXY(status[0], status[1], 3, 3) lp.LedCtrlXY(8, 5, 0, 0) lp.LedCtrlXY(8, 7, 0, 0) elif status[0] == 8 and status[1] == 5: mode = 'green' lp.LedCtrlXY(status[0], status[1], 0, 3) lp.LedCtrlXY(8, 6, 0, 0) lp.LedCtrlXY(8, 7, 0, 0) else: if mode == 'green': colors = [0,3] elif mode == 'red': colors = [3,0] else: colors = [3,3] if status[2] is True: lp.LedCtrlXY(status[0], status[1], colors[0], colors[1]) lp.LedCtrlString( 'exit', 3, 3, -1, 50 ) t.delay(1000) lp.Reset() # turn all LEDs off lp.Close() # close the Launchpad (will quit with an error due to a PyGame bug)
def __init__(self): # remember the Launchpad type to adjust the mapping of the buttons self.mode = None # create an instance lp = launchpad.Launchpad() # try the first Mk2 if lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print(" - Launchpad Mk2: OK") self.mode = "mk2" else: print(" - Launchpad Mk2: ERROR") return # try the first Mini Mk3 elif lp.Check(1, "minimk3"): lp = launchpad.LaunchpadMiniMk3() if lp.Open(1, "minimk3"): print(" - Launchpad Mini Mk3: OK") self.mode = "mk3" else: print(" - Launchpad Mini Mk3: ERROR") return # try the first X elif lp.Check(1, "x"): lp = launchpad.LaunchpadLPX() if lp.Open(1, "x"): print(" - Launchpad X: OK") self.mode = "x" else: print(" - Launchpad X: ERROR") return # try the first Pro elif lp.Check(0, "pad pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "pad pro"): print(" - Launchpad Pro: OK") self.mode = "pro" else: print(" - Launchpad Pro: ERROR") return # nope else: raise Exception( "No compatible Launchpad found. Only for Mk2, Mk3, X, Pro") self.lp = lp
def __enter__(self): self.lp = None if self.always_emulate is True: self.lp = launchpad.emu.LaunchpadEmu() else: try: self.lp = launchpad.Launchpad() self.lp.Open() self.lp.ButtonFlush() except: if self.always_emulate is not False: self.lp = launchpad.emu.LaunchpadEmu() return self.lp
def get_launchpad(): lp = launchpad.Launchpad() if lp.Check(0, MK2_NAME): return launchpad.LaunchpadMk2() if lp.Check(0, PRO_NAME): return launchpad.LaunchpadPro() # unsupported pads if lp.Check(0, CTRL_XL_NAME) or lp.Check(0, LAUNCHKEY_NAME) or lp.Check(0, DICER_NAME): return -1 if lp.Check(): return lp return None
def box_init(): # create an instance global lp lp = launchpad.Launchpad() # check what we have here and override lp if necessary if lp.Check(0, "pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "pro"): print("Launchpad Pro") mode = "Pro" elif lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print("Launchpad Mk2") mode = "Mk2" elif lp.Check(0, "control xl"): lp = launchpad.LaunchControlXL() if lp.Open(0, "control xl"): print("Launch Control XL") mode = "XL" elif lp.Check(0, "launchkey"): lp = launchpad.LaunchKeyMini() if lp.Open(0, "launchkey"): print("LaunchKey (Mini)") mode = "LKM" elif lp.Check(0, "dicer"): lp = launchpad.Dicer() if lp.Open(0, "dicer"): print("Dicer") mode = "Dcr" else: if lp.Open(): print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return lp.Reset()
def main(): lp = launchpad.Launchpad() print("===\nAvailable MIDI devices:") lp.ListAll() print("===") print("Enter a part of the device name, that shall be monitored.") print("The string needs to cover the in- and output channels of a device!") print( "Otherwise, opening only one input or one output channel will result in an error." ) print("The search string is case-insensitive.") inName = cmdInput(" search string:") while True: print("===") lp.ListAll(searchString=inName) print("===") inOk = cmdInput(" ENTER to continue or new search string:") if inOk == '': break else: inName = inOk try: lp.Open(0, inName) except: print("error opening this device") sys.exit(-1) print("===") print("Now hit the keys, turn the knobs or push the buttons:") # DEBUG STUFF # lp.midi.RawWriteSysEx( [ 0, 32, 41, 2, 14, 14, 1 ] ) # Pro Mk3 programmer's mode ON # lp.midi.RawWriteSysEx( [ 0, 32, 41, 2, 14, 14, 0 ] ) # Pro Mk3 programmer's mode OFF (Live mode) while (True): events = lp.EventRaw() if events != []: print(events)
def main(): # create an instance lp = launchpad.Launchpad() # some basic info print("\nRunning...") print(" - OS : " + str(os.name)) print(" - Platform: " + str(platform.system())) print(" - Release : " + str(platform.release())) print(" - Arch : " + str(platform.architecture()[0])) print(" - struct : " + str(struct.calcsize("P") * 8)) print(" - Python : " + str(sys.version.split()[0])) print(" - PyGame : " + str(pygame.ver)) # print list of attached MIDI devices print("\nAvailable MIDI devices:") lp.ListAll() # print list of attached MIDI devices print("\n\ngoodbye ...")
def setup(): global lp # create launchpad instance lp = launchpad.Launchpad() global mode # Launchpad model set to none before scanning, to recognize the launchpad mode = None # try the first Mk2 if lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): mode = "Mk2" else: pass # try the first Pro elif lp.Check(0, "Pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "Pro"): mode = "Pro" else: pass # try the pro with cfw elif lp.Check(1, "Open"): lp = launchpad.LaunchpadPro() if lp.Open(1, "Open"): mode = "Pro" # experimental LPX implementation elif lp.Check(1, "lpx"): lp = launchpad.LaunchpadLPX() if lp.Open(1, "lpx"): mode = "X" else: pass
def main(): mode = None # create an instance lp = launchpad.Launchpad() # check what we have here and override lp if necessary if lp.Open(): print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return # Clear the buffer because the Launchpad remembers everything :-) lp.ButtonFlush() while 1: if mode == "Mk1" or mode == "XL": lp.LedCtrlRaw(random.randint(0, 127), random.randint(0, 3), random.randint(0, 3)) if mode == "XL" or mode == "LKM": but = lp.InputStateRaw() else: but = lp.ButtonStateRaw() if but != []: print(" event: ", but) # now quit... print( "Quitting might raise a 'Bad Pointer' error (~almost~ nothing to worry about...:).\n\n" ) lp.Reset() # turn all LEDs off lp.Close( ) # close the Launchpad (will quit with an error due to a PyGame bug)
def get_launchpad(): lp = launchpad.Launchpad() if lp.Check(0, MK2_NAME): return launchpad.LaunchpadMk2() # the MK3 has two midi devices, we need the second one if lp.Check(1, MK3MINI_NAME): return launchpad.LaunchpadMiniMk3() if lp.Check(0, PRO_NAME): return launchpad.LaunchpadPro() if lp.Check(1, LPX_NAME): return launchpad.LaunchpadLPX() # unsupported pads if lp.Check(0, CTRL_XL_NAME) or lp.Check(0, LAUNCHKEY_NAME) or lp.Check( 0, DICER_NAME): return -1 if lp.Check(): return lp return None
def main(): mode = ("Mk1") # create an instance lp = launchpad.Launchpad() # check what we have here and override lp if necessary lp.Open(name="Launchpad Mini", number=0) print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return if mode == "Mk1": lp.LedCtrlString( "TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK TEK", 8, 0, -1) lp.Reset() # turn all LEDs off lp.Close( ) # close the Launchpad (will quit with an error due to a PyGame bug)
def main(): # some basic info print( "\nRunning..." ) print( " - Python " + str( sys.version.split()[0] ) ) print( " - PyGame " + str( pygame.ver ) ) # create an instance lp = launchpad.Launchpad() # try the first Mk2 if lp.Check( 0, "mk2" ): lp = launchpad.LaunchpadMk2() if lp.Open( 0, "mk2" ): print( " - Launchpad Mk2: OK" ) else: print( " - Launchpad Mk2: ERROR") return # try the first Mini Mk3 elif lp.Check( 1, "minimk3" ): lp = launchpad.LaunchpadMiniMk3() if lp.Open( 1, "minimk3" ): print( " - Launchpad Mini Mk3: OK" ) else: print( " - Launchpad Mini Mk3: ERROR") return # try the first Pro elif lp.Check( 0, "pad pro" ): lp = launchpad.LaunchpadPro() if lp.Open( 0, "pad pro" ): print( " - Launchpad Pro: OK" ) else: print( " - Launchpad Pro: ERROR") return # try the first Pro Mk3 elif lp.Check( 0, "promk3" ): lp = launchpad.LaunchpadProMk3() if lp.Open( 0 ): print( " - Launchpad Pro Mk3: OK" ) else: print( " - Launchpad Pro Mk3: ERROR") return # try the first X # Notice that this is already built-in in the LPX class' methods Check() and Open, # but we're using the one from above! elif lp.Check( 1, "Launchpad X") or lp.Check( 1, "LPX" ): lp = launchpad.LaunchpadLPX() # Open() includes looking for "LPX" and "Launchpad X" if lp.Open( 1 ): print( " - Launchpad X: OK" ) else: print( " - Launchpad X: ERROR") return # nope else: print( " - No Launchpad available" ) return # Clear the buffer because the Launchpad remembers everything lp.ButtonFlush() # List the class's methods print( " - Available methods:" ) for mName in sorted( dir( lp ) ): if mName.find( "__") >= 0: continue if callable( getattr( lp, mName ) ): print( " " + str( mName ) + "()" ) # LedAllOn() test print( " - Testing LedAllOn()" ) for i in [ 5, 21, 79, 3]: lp.LedAllOn( i ) time.wait(500) lp.LedAllOn( 0 ) # LedCtrlXY() test # -> LedCtrlRaw() # -> midi.RawWriteSysEx() # -> devOut.write_sys_ex() print( " - Testing LedCtrlXY()" ) colors = [ [63,0,0],[0,63,0],[0,0,63],[63,63,0],[63,0,63],[0,63,63],[63,63,63] ] for i in range(4): for y in range( i + 1, 8 - i + 1 ): for x in range( i, 8 - i ): lp.LedCtrlXY( x, y, colors[i][0], colors[i][1], colors[i][2]) time.wait(500) # turn all LEDs off print( " - Testing Reset()" ) lp.Reset() # close this instance print( " - More to come, goodbye...\n" ) lp.Close()
def main(): mode = None # create an instance lp = launchpad.Launchpad() # check what we have here and override lp if necessary if lp.Check(0, "pad pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "pad pro"): print("Launchpad Pro") mode = "Pro" # experimental MK3 implementation # The MK3 has two MIDI instances per device; we need the 2nd one. # If you have two MK3s attached, its "1" for the first and "3" for the 2nd device elif lp.Check(1, "minimk3"): lp = launchpad.LaunchpadMiniMk3() if lp.Open(1, "minimk3"): print("Launchpad Mini Mk3") mode = "Pro" # experimental LPX implementation # Like the Mk3, the LPX also has two MIDI instances per device; we need the 2nd one. # If you have two LPXs attached, its "1" for the first and "3" for the 2nd device elif lp.Check(1, "lpx"): lp = launchpad.LaunchpadLPX() if lp.Open(1, "lpx"): print("Launchpad X") mode = "Pro" elif lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print("Launchpad Mk2") mode = "Mk2" elif lp.Check(0, "control xl"): lp = launchpad.LaunchControlXL() if lp.Open(0, "control xl"): print("Launch Control XL") mode = "XL" elif lp.Check(0, "launchkey"): lp = launchpad.LaunchKeyMini() if lp.Open(0, "launchkey"): print("LaunchKey (Mini)") mode = "LKM" elif lp.Check(0, "dicer"): lp = launchpad.Dicer() if lp.Open(0, "dicer"): print("Dicer") mode = "Dcr" else: if lp.Open(): print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return # scroll "HELLO" from right to left if mode == "Mk1": lp.LedCtrlString("HELLO ", 0, 3, -1) # for all others except the XL and the LaunchKey elif mode != "XL" and mode != "LKM" and mode != "Dcr": lp.LedCtrlString("HELLO ", 0, 63, 0, -1) # random output if mode == "LKM": print( "The LaunchKey(Mini) does not (yet) support LED activation, but you" ) print("can push some buttons or rotate some knobes now...") print("Auto exit if first number reaches 0") else: print( "---\nRandom madness. Create some events. Stops after reaching 0 (first number)" ) print( "Notice that sometimes, old Mk1 units don't recognize any button") print("events before you press one of the (top) automap buttons") print("(or power-cycle the unit...).") # Clear the buffer because the Launchpad remembers everything :-) lp.ButtonFlush() # Lightshow if mode == "XL" or mode == "LKM": butHit = 100 elif mode == "Dcr": butHit = 30 else: butHit = 10 while 1: if mode == "Mk1" or mode == "XL": lp.LedCtrlRaw(random.randint(0, 127), random.randint(0, 3), random.randint(0, 3)) elif mode == "Dcr": lp.LedCtrlRaw(random.randint(0, 130), random.randint(0, 7), random.randint(0, 15)) elif mode != "LKM": lp.LedCtrlRaw(random.randint(0, 127), random.randint(0, 63), random.randint(0, 63), random.randint(0, 63)) time.wait(5) if mode == "XL" or mode == "LKM": but = lp.InputStateRaw() else: but = lp.ButtonStateRaw() if but != []: butHit -= 1 if butHit < 1: break print(butHit, " event: ", but) # now quit... print( "Quitting might raise a 'Bad Pointer' error (~almost~ nothing to worry about...:).\n\n" ) lp.Reset() # turn all LEDs off lp.Close( ) # close the Launchpad (will quit with an error due to a PyGame bug)
def main(): mode = None if launchpad.LaunchpadPro().Check( 0 ): lp = launchpad.LaunchpadPro() if lp.Open( 0 ): print("Launchpad Pro") mode = "Pro" elif launchpad.LaunchpadProMk3().Check( 0 ): lp = launchpad.LaunchpadProMk3() if lp.Open( 0 ): print("Launchpad Pro Mk3") mode = "ProMk3" elif launchpad.LaunchpadMiniMk3().Check( 1 ): lp = launchpad.LaunchpadMiniMk3() if lp.Open( 1 ): print("Launchpad Mini Mk3") mode = "Pro" elif launchpad.LaunchpadLPX().Check( 1 ): lp = launchpad.LaunchpadLPX() if lp.Open( 1 ): print("Launchpad X") mode = "Pro" elif launchpad.LaunchpadMk2().Check( 0 ): lp = launchpad.LaunchpadMk2() if lp.Open( 0 ): print("Launchpad Mk2") mode = "Mk2" # elif launchpad.LaunchControlXL().Check( 0 ): # lp = launchpad.LaunchControlXL() # if lp.Open( 0 ): # print("Launch Control XL") # mode = "XL" # elif launchpad.LaunchKeyMini().Check( 0 ): # lp = launchpad.LaunchKeyMini() # if lp.Open( 0 ): # print("LaunchKey (Mini)") # mode = "LKM" elif launchpad.Dicer().Check( 0 ): lp = launchpad.Dicer() if lp.Open( 0 ): print("Dicer") mode = "Dcr" elif launchpad.MidiFighter64().Check( 0 ): lp = launchpad.MidiFighter64() if lp.Open( 0 ): print("Midi Fighter 64") mode = "F64" else: lp = launchpad.Launchpad() if lp.Open(): print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return print("\nQUIT: Push one single button ten times in a row.\n") butLast = -1 butCount = 0 while True: buts = lp.ButtonStateRaw() if buts != []: print( buts[0], buts[1]) # shall we quit? if buts[0] != butLast: butLast = buts[0] butCount = 1 continue else: # counts pressed and release events butCount += 1 if butCount >= 20: break print("bye ...") lp.Reset() # turn all LEDs off lp.Close() # close the Launchpad (will quit with an error due to a PyGame bug)
import launchpad_py import time import random import numberBinaryColor as nbc import letters8By8 as letters import signal import sys lp = launchpad_py.Launchpad() lp.ListAll() lp.Open() def arrayToDisplay(arr): for x in range(8): for y in range(8): if arr[y][x] == 1: lp.LedCtrlXY(x, y + 1, random.randint(1, 3), random.randint(1, 3)) def showNum(number): if number == 0: arrayToDisplay(nbc.zero) elif number == 1: arrayToDisplay(nbc.one) elif number == 2: arrayToDisplay(nbc.two) elif number == 3: arrayToDisplay(nbc.three) elif number == 4:
print("Log file (this file):", LOG_PATH, end="\n\n") # Try to import launchpad.py try: import launchpad_py as launchpad except ImportError: try: import launchpad except ImportError: sys.exit("[LPHK] Error loading launchpad.py") print("") import lp_events, scripts, kb, files, sound, window from utils import launchpad_connector lp = launchpad.Launchpad() EXIT_ON_WINDOW_CLOSE = True def init(): global EXIT_ON_WINDOW_CLOSE if len(sys.argv) > 1: if ("--debug" in sys.argv) or ("-d" in sys.argv): EXIT_ON_WINDOW_CLOSE = False print( "[LPHK] Debugging mode active! Will not shut down on window close." ) print( "[LPHK] Run shutdown() to manually close the program correctly." )
def main(): mode = None # create an instance lp = launchpad.Launchpad() # check what we have here and override lp if necessary if lp.Check(0, "pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "pro"): print("Launchpad Pro") mode = "Pro" elif lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print("Launchpad Mk2") mode = "Mk2" elif lp.Check(1, "mk3"): lp = launchpad.LaunchpadMk3() if lp.Open(1, "mk3"): print("Launchpad Mk3") mode = "Mk3" if mode is None: print("Did not find any compatible Launchpads, meh...") return # set flashing/pulsing frequency to 240bpm lp.LedCtrlBpm(240) # stupid lightshow from here on... for y in range(8): for x in range(8): lp.LedCtrlXYByCode(7 - x, 8 - y, 5 if y < 4 else 13) lp.LedCtrlXYByCode(x, y + 1, 21 if y < 4 else 13) time.wait(50) time.wait(1000) for y in range(8): for x in range(8): lp.LedCtrlFlashXYByCode(x, y + 1, 0) time.wait(3000) for y in range(8): for x in range(8): lp.LedCtrlPulseXYByCode(x, y + 1, 53) time.wait(3000) for x in range(4): for y in range(8): lp.LedCtrlXYByCode(7 - x, 8 - y, random.randint(0, 127)) lp.LedCtrlFlashXYByCode(7 - x, 8 - y, random.randint(0, 127)) lp.LedCtrlXYByCode(x, y + 1, random.randint(0, 127)) lp.LedCtrlFlashXYByCode(x, y + 1, random.randint(0, 127)) time.wait(250) time.wait(3000) lp.Reset() # turn all LEDs off lp.Close( ) # close the Launchpad (will quit with an error due to a PyGame bug)
def main(): mode = None # create an instance lp = launchpad.Launchpad() # check what we have here and override lp if necessary if lp.Check(0, "pro"): lp = launchpad.LaunchpadPro() if lp.Open(0, "pro"): print("Launchpad Pro") mode = "Pro" elif lp.Check(0, "mk2"): lp = launchpad.LaunchpadMk2() if lp.Open(0, "mk2"): print("Launchpad Mk2") mode = "Mk2" elif lp.Check(0, "control xl"): lp = launchpad.LaunchControlXL() if lp.Open(0, "control xl"): print("Launch Control XL") mode = "XL" elif lp.Check(0, "launchkey"): lp = launchpad.LaunchKeyMini() if lp.Open(0, "launchkey"): print("LaunchKey (Mini)") mode = "LKM" else: if lp.Open(): print("Launchpad Mk1/S/Mini") mode = "Mk1" if mode is None: print("Did not find any Launchpads, meh...") return # scroll "HELLO" from right to left if mode == "Mk1": lp.LedCtrlString("HELLO ", 0, 3, -1) # for all others except the XL and the LaunchKey elif mode != "XL" and mode != "LKM": lp.LedCtrlString("HELLO ", 0, 63, 0, -1) # random output if mode == "LKM": print( "The LaunchKey(Mini) does not (yet) support LED activation, but you" ) print("can push some buttons or rotate some knobes now...") print("Auto exit if first number reaches 0") else: print( "---\nRandom madness. Create some events. Stops after reaching 0 (first number)" ) print( "Notice that sometimes, old Mk1 units don't recognize any button") print("events before you press one of the (top) automap buttons") print("(or power-cycle the unit...).") # Clear the buffer because the Launchpad remembers everything :-) lp.ButtonFlush() # Lightshow if mode == "XL" or mode == "LKM": butHit = 100 else: butHit = 10 while 1: if mode == "Mk1" or mode == "XL": lp.LedCtrlRaw(random.randint(0, 127), random.randint(0, 3), random.randint(0, 3)) elif mode != "LKM": lp.LedCtrlRaw(random.randint(0, 127), random.randint(0, 63), random.randint(0, 63), random.randint(0, 63)) time.wait(5) if mode == "XL" or mode == "LKM": but = lp.InputStateRaw() else: but = lp.ButtonStateRaw() if but != []: butHit -= 1 if butHit < 1: break print(butHit, " event: ", but) # now crash it :-) print("\nNow let's crash PyGame...") print( "Don't worry, that's just a bug in PyGame's MIDI implementation.\n\n\n" ) lp.Reset() # turn all LEDs off lp.Close( ) # close the Launchpad (will quit with an error due to a PyGame bug)