示例#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
示例#2
0
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
示例#3
0
def main():
    lp = launchpad.LaunchpadMk2()

    init(lp)
    setLayout(lp)
    pressed = []

    while True:
        but = lp.ButtonStateXY()
        if but != []:
            highlightPressed(lp, but)
            if (but[2] == 127):  #pressed
                pressed.append(but)
            else:
                removal = 0
                for i in range(len(pressed)):
                    if ([pressed[i][0], pressed[i][1]] == [but[0], but[1]]):
                        removal = i
                try:
                    del pressed[removal]
                    releaseFunction(lp, but)
                except IndexError:
                    pass

        if (pressed != []):
            print(pressed)
        pressedFunctions(lp, pressed)
        time.sleep(0.025)
示例#4
0
 def possibly_load_shared_lp(self, lp):
     if lp != None:
         self.lp = lp
         self.shared_lp = True
     else:
         self.lp = launchpad_py.LaunchpadMk2()
         self.shared_lp = False
示例#5
0
 def __init__(self):
     # if not pygame.get_init():
     #     pygame.init()
     #     pygame.mixer.init()
     self.running = True
     self.need_redraw = True
     self.lp = launchpad.LaunchpadMk2()
     if self.lp.Open(0, "mk2"):
         print("[INFO] Opened Launchpad mk2")
     else:
         print("[ERROR] Cound not find a Launchpad!")
         # return
     self.lp.ButtonFlush()
     self.lp.LedAllOn(0)
     print("[INFO] Loading settings . . .")
     self.data = json.load(open("settings.json", "r"))
     self.mode = self.data["default_mode"]
     self.music_page = self.data["music"]["default_page"]
     self.music_mode_button = (self.data["music"]["pages"][str(
         self.music_page)]["button_x"], self.data["music"]["pages"][str(
             self.music_page)]["button_y"], self.data["music"]["pages"][str(
                 self.music_page)]["button_color"])
     self.pages = [[]]
     print("[INFO] Loading music files . . .")
     for item in self.data["music"]["pages"][str(self.music_page)]["songs"]:
         self.pages[-1].append(
             Button(self.data["music"]["directory"] + item["file"],
                    item["name"], item["x"], item["y"], item["color"],
                    item["loop"], item["volume"], 1000))
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()
示例#7
0
def main():
    lp = launchpad_py.LaunchpadMk2()
    res = lp.Open()
    lp.Reset()

    try:

        board = Board(lp)
        board.initBoard()
        sequence = Sequence(lp)
        rounds = 0
        while board.isAlive():
            coord = SequenceCoords.generateCoord()
            sequence.addCoords(coord)
            sequence.displaySequence()
            board.displayTurnTransition()
            success = sequence.checkUserSequence()
            if success:
                board.displaySuccessTransition()
            else:
                board.decreaseHp()
                board.displayFailureTransition()
            rounds += 1
            print("*** ROUND %s FINISHED ***" % rounds)

    except KeyboardInterrupt as ki:
        print("Exit game...")
    finally:
        lp.Reset()
        lp.Close()
示例#8
0
 def __init__(self):
     self.sweeper = None
     self.old_board = None
     self.lp = launchpad.LaunchpadMk2()
     if not self.lp.Open():
         print("Error opening LaunchpadMK2")
         exit(1)
     self.lp.LedAllOn(0)
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()
示例#10
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.LaunchpadMk2()

    # open the first Launchpad Mk2
    if lp.Open(0, "mk2"):
        print(" - Launchpad Mk2: OK")
    else:
        print(" - Launchpad Mk2: ERROR")
        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()
示例#11
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
示例#12
0
def initPad():
    """
    Sets up launchpad using launchpad_py
    Currently supports LaunchpadMk2(), can be edited, but may require user input troubleshooting
    :Resources: https://github.com/FMMT666/launchpad.py
    :return:
    """
    lp = launchpad.LaunchpadMk2()
    lp.Open()
    lp.ButtonFlush()
    lp.LedCtrlString('OK', 63, 3, 63, direction=-1, waitms=0)
    return lp
示例#13
0
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
示例#14
0
def main():

	# 60, 23, 10

	# some basic info
	print( "\nRunning..." )
	print( " - Python " + str( sys.version.split()[0] ) )

	ledCodes = [[1,1,0,0,0,5,0,5,5],
				[90,90,0,82,82,0,0,0,9],
				[90,90,0,82,82,0,5,5,0],
				[0,0,0,0,0,0,0,0,13],
				[126,126,0,109,109,0,9,9,0],
				[126,126,0,109,109,0,0,0,82],
				[0,0,0,0,0,0,13,13,90],
				[9,9,0,13,13,0,0,0,5],
				[9,9,0,13,13,0,21,21,21]]

	# create an instance
	lp = launchpad.LaunchpadMk2()

	# open the first Launchpad Mk2
	if lp.Open( 0, "mk2" ):
		print( " - Launchpad Mk2: OK" )
	else:
		print( " - Launchpad Mk2: ERROR" )
		return

	# Clear the buffer because the Launchpad remembers everything
	lp.ButtonFlush()
	
	for i in range(9):
		for j in range(9):
			lp.LedCtrlXYByCode(i, j, ledCodes[j][i])

	# buttonThread = Thread(target = process_buttons, args = (lp, ))
	# buttonThread.start()

	application = tornado.web.Application([(r'/', WSHandler,{"lp": lp})],)

	http_server = tornado.httpserver.HTTPServer(application)
	http_server.listen(5802)
	tornado.ioloop.IOLoop.instance().start()

	# close this instance
	print( " - More to come, goodbye...\n" )
	lp.Close()
示例#15
0
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()
示例#16
0
def main(pad=None):
    if not pad:
        try:
            pad = launchpad.LaunchpadMk2()
            pad.Open()
            pad.Reset()
        except Exception as e:
            pad = None
    try:
        color_mapper = ColorMapper()
        pad_mapper = PadMapper(pad, color_mapper, use_pad=bool(pad))
        midi_sender = MidiSender()

        seq = StepSequencer(pad_mapper, midi_sender, bpm=100)
        listener = InputListener(pad, seq)

        if not pad:
            # test pattern
            seq.updateState(7, 0)
            seq.updateState(5, 2)
            seq.updateState(7, 4)
            seq.updateState(5, 6)
            seq.updateState(4, 7)

            seq.updateState(1, 0)
            seq.updateState(1, 2)
            seq.updateState(1, 4)
            seq.updateState(1, 6)
        while True:
            pass

    except KeyboardInterrupt:
        print("Stopping sequencer...")
    except Exception as e:
        traceback.print_exc()
    finally:
        seq.stop()
        listener.stop()
        midi_sender.stop()
        if pad:
            pad.Reset()
            pad.Close()
示例#17
0
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
示例#18
0
    def __init__(self):
        super().__init__()
        self.keyboard = KBController()
        self.mouse = MController()
        self.lp = launchpad_py.LaunchpadMk2()
        self.lp.Open(0)

        self.current_profile = None

        self.profiles = {}
        self.buttons = {}

        self.player = Player()

        self.events = {
            "on_button_press": None,
            "on_button_release": None,
            "on_settings_button_press": None,
            "on_exit": None,
            "on_profile_enter": None,
            "on_profile_exit": None
        }
示例#19
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
示例#20
0
    def start(self):

        self.lp = launchpad_py.LaunchpadMk2()
        opened = self.lp.Open()
        if not (opened):
            return "Not able to use device"
        self.lp.Reset()

        self.snake = Snake(self)
        self.default_color = 10

        self.lp.LedAllOn(self.default_color)
        global quit
        last_time = time.time()
        while (not quit):
            delta = time.time() - last_time
            last_time = time.time()
            self.process(delta)
            self.update(delta)
            self.render()

        self.lp.LedAllOn(self.lp.COLORS["black"])
        self.lp.Close()
        return "opened"
示例#21
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()
示例#22
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)
示例#23
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)
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)
示例#25
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, "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)
示例#26
0
 def __init__(self):
     self.lp = launchpad_py.LaunchpadMk2()
     self.res = self.lp.Open()
     self.lp.Reset()
     #self.lp = None
     hol = 1
示例#27
0
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:
示例#28
0
from pygame import time
import launchpad_py as launchpad 
import threading
import json
from playsound import playsound

DetectMidi = True
GetFile = None
PathProj = None
mode = None
lp = None	

if launchpad.LaunchpadPro().Check(0):
	lp = launchpad.LaunchpadPro()
	lp.Open(0)
elif launchpad.LaunchpadMk2().Check(0):
	lp = launchpad.LaunchpadMk2()
	lp.Open(0)
else:
	print("Lanchpad not connected")
	input()
	exit(0)

LedValue = [5,9,13,21,37,45,49,0]
sleep = 20
sleep2 = [30, 50, 30, 30, 30, 30, 30, 30]

Page = 0

ButtonClick = {}
ButtonSound = {}
示例#29
0
            pixel_array[pixel_index] = color_array[pixel_index]

def criaFogo():
    for coluna in range(0,largura):
        OverflowPixel = altura * largura
        pixel_index = (OverflowPixel - largura) + coluna

        pixel_array[pixel_index] = 7

def criaPropagacao(pixel_index_atual):
    pixel_de_baixo = pixel_index_atual + largura
    
    if pixel_de_baixo >= largura * altura:
        return
    decay = math.floor(np.random.random()*3)
    fogo_de_baixo = pixel_array[pixel_de_baixo]
    if fogo_de_baixo - decay >=0:
        novo_fogo = fogo_de_baixo - decay
    else:
        novo_fogo = 0

    pixel_array[pixel_index_atual - math.floor(decay*0.3)] = novo_fogo


if __name__ == "__main__":
    lp = lp.LaunchpadMk2()
    # lp.ListAll()
    lp.Open(0,"Mk2")
    start()
    print('\n\nLaunchpad conectado')
示例#30
0
import launchpad_py
import time

lp = launchpad_py.LaunchpadMk2()

res = lp.Open()
lp.Reset()
while 1:
    ll = lp.ButtonStateXY()
    if len(ll) != 0:
        lp.LedCtrlXYByCode(ll[0], ll[1], ll[2])
        time.sleep(0.5)
        lp.LedCtrlXYByCode(ll[0], ll[1], 0)