Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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()
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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"
			
	elif lp.Check( 0, "mk2" ):
		lp = launchpad.LaunchpadMk2()
		if lp.Open( 0, "mk2" ):
			print("Launchpad Mk2")
			mode = "Mk2"

	elif lp.Check( 1, "minimk3" ):
		lp = launchpad.LaunchpadMiniMk3()
		if lp.Open( 1, "minimk3" ):
			print("Launchpad Mk3")
			mode = "Mk3"

	elif lp.Check( 1, "x" ):
		lp = launchpad.LaunchpadLPX()
		if lp.Open( 1, "x" ):
			print("Launchpad X")
			mode = "X"

	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)
Ejemplo n.º 8
0
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 = "MiniMk3"

    elif launchpad.LaunchpadLPX().Check(1):
        lp = launchpad.LaunchpadLPX()
        if lp.Open(1):
            print("Launchpad X")
            mode = "LPX"

    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"

    elif launchpad.Launchpad().Check(0):
        lp = launchpad.Launchpad()
        if lp.Open(0):
            print("Launchpad Mk1/S/Mini")
            mode = "Mk1"

    if mode is None:
        print("Did not find any Launchpads, meh...")
        return

    print("QUIT: Push a single button for longer than 3s and release it.")

    lastBut = (-99, -99)
    tStart = time.time()
    while True:
        if mode == 'Pro' or mode == 'ProMk3':
            buts = lp.ButtonStateXY(mode='pro')
        else:
            buts = lp.ButtonStateXY()

        if buts != []:
            print(buts[0], buts[1], buts[2])

            # quit?
            if buts[2] > 0:
                lastBut = (buts[0], buts[1])
                tStart = time.time()
            else:
                if lastBut == (buts[0],
                               buts[1]) and (time.time() - tStart) > 2:
                    break

    print("bye ...")

    lp.Reset()  # turn all LEDs off
    lp.Close(
    )  # close the Launchpad (will quit with an error due to a PyGame bug)
Ejemplo n.º 9
0
	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 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

		# try the first Pro Mk3
		elif lp.Check( 0, "mk3" ):
			lp = launchpad.LaunchpadProMk3()
			if lp.Open( 0 ):
				print( " - Launchpad Pro Mk3: OK" )
				self.mode = "promk3"
			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" )
				self.mode = "lpx"
			else:
				print( " - Launchpad X: ERROR")
				return

		# nope
		else:
			raise Exception("No compatible Launchpad found. Only for Mk2, Mk3, Pro")

		self.lp = lp