Beispiel #1
0
def main():

    mode = None

    if launchpad.MidiFighter64().Check(0):
        lp = launchpad.MidiFighter64()
        if lp.Open(0):
            print("Midi Fighter 64")
            mode = "F64"

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

    lp.LedAllOn(103)
    time.wait(500)

    lp.LedCtrlString('500BUCKS', 21, coloroff=103, direction=-1, waitms=10)
    for i in range(10):
        lp.LedAllOn(random.randint(0, 127))
        time.wait(50)
    lp.LedCtrlString('LOL', 5, coloroff=21, direction=-0, waitms=50)

    time.wait(50)
    lp.LedAllOn(103)

    print("bye ...")

    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.MidiFighter64().Check(0):
        lp = launchpad.MidiFighter64()
        if lp.Open(0):
            print("Midi Fighter 64")
            mode = "F64"

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

    # all red but off
    for x in range(8):
        for y in range(8):

            # Additionally there are these vars which can be used to change the animation:
            #   MODE_SQUARE
            #   MODE_CIRCLE
            #   MODE_STAR
            #   MODE_TRIANGLE

            # using if/elifs for better visibility:

            # --- BRIGHTNESS 0..15
            if y == 0:
                color = 5
                mode = lp.MODE_BRIGHT[1]
            elif y == 1:
                mode = lp.MODE_BRIGHT[5]
            elif y == 2:
                mode = lp.MODE_BRIGHT[10]
            elif y == 3:
                mode = lp.MODE_BRIGHT[15]
            # --- TOGGLING 0..7
            elif y == 4:
                color = 25
                mode = lp.MODE_TOGGLE[4]
            elif y == 5:
                mode = lp.MODE_TOGGLE[x]
            # --- PULSING 0..7
            elif y == 6:
                color = 78
                mode = lp.MODE_PULSE[5]
            elif y == 7:
                mode = lp.MODE_PULSE[x]

            lp.LedCtrlXY(x, y, color, mode)

    print("bye ...")

    lp.Reset()  # turn all LEDs off
    lp.Close(
    )  # close the Launchpad (will quit with an error due to a PyGame bug)
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
Beispiel #4
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)
Beispiel #5
0
def main():

    mode = None

    # create an instance for the Pro
    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"

    # 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 launchpad.LaunchpadMiniMk3().Check(1):
        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 launchpad.LaunchpadLPX().Check(1):
        lp = launchpad.LaunchpadLPX()
        if lp.Open(1, "lpx"):
            print("Launchpad X")
            mode = "Pro"

    elif launchpad.LaunchpadMk2().Check(0):
        lp = launchpad.LaunchpadMk2()
        if lp.Open(0, "mk2"):
            print("Launchpad Mk2")
            mode = "Mk2"

    elif launchpad.LaunchControlXL().Check(0):
        lp = launchpad.LaunchControlXL()
        if lp.Open(0, "control xl"):
            print("Launch Control XL")
            mode = "XL"

    elif launchpad.LaunchKeyMini().Check(0):
        lp = launchpad.LaunchKeyMini()
        if lp.Open(0, "launchkey"):
            print("LaunchKey (Mini)")
            mode = "LKM"

    elif launchpad.Dicer().Check(0):
        lp = launchpad.Dicer()
        if lp.Open(0, "dicer"):
            print("Dicer")
            mode = "Dcr"

    elif launchpad.MidiFighter64().Check(0):
        lp = launchpad.MidiFighter64()
        if lp.Open(0):
            print("Midi Fighter 64")
            mode = "MF64"

    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

    # scroll a string from right to left
    if mode == "Mk1":
        lp.LedCtrlString("HENLO!", 0, 3, -1)
    # the MF64's methods are not compatible with the Launchpad ones
    elif mode == "MF64":
        lp.LedCtrlString("HENLO!", 5, 0, -1, waitms=50)
    # for all others except the XL and the LaunchKey
    elif mode != "XL" and mode != "LKM" and mode != "Dcr":
        lp.LedCtrlString("HENLO!", 0, 63, 0, -1, waitms=50)

    # 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 == "MF64":
            lp.LedCtrlRaw(random.randint(36, 99), random.randint(0, 127))
        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)
Beispiel #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 = "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)