def main(): # create two Launchpad instances lp1 = launchpad.Launchpad() lp2 = launchpad.Launchpad() # open them lp1.Open(0) lp2.Open(1) while 1: # random light show lp1.LedCtrlRaw( random.randint(0,127), random.randint(0,3), random.randint(0,3) ) lp2.LedCtrlRaw( random.randint(0,127), random.randint(0,3), random.randint(0,3) ) # some extra time to give the button events a chance to come through... time.wait( 5 ) # wait until the arm button (lower right) is hit but = lp1.ButtonStateRaw() if but != []: print( but ) if but[0] == 120: break
def main(): LP = launchpad.Launchpad( ) # creates a Launchpad instance (first Launchpad found) LP.Open() # start it LP.LedCtrlString('HELLO ', 0, 3, -1) # scroll "HELLO" from right to left # random output until button "arm" (lower right) is pressed print("---\nRandom madness. Stop by hitting the ARM button (lower right)") print("Remember the PyGame MIDI bug:") print("If the ARM button has no effect, hit an automap button (top row)") print("and try again...") while 1: LP.LedCtrlRaw(random.randint(0, 127), random.randint(0, 3), random.randint(0, 3)) time.wait(5) but = LP.ButtonStateRaw() if but != []: print(but) if but[0] == 120: break LP.Reset() # turn all LEDs off LP.Close() # close the Launchpad
def scanIO(): inputs = mido.get_input_names() outputs = mido.get_output_names() print("input names: ", inputs) print("output names: ", outputs) openMIDIlst = [] for i in inputs: string = "open " + i + "? Type anything for yes, or just hit enter for no" x = input(string) if x: newDevice = launchpad.Launchpad(i) openMIDIlst.append(newDevice) return openMIDIlst
def __init__(self, nickname=''): self.player_id = None self.nickname = nickname[:8] self.lp = launchpad.Launchpad() self.mirror_state = None self.modifiers = [False] * 8 self.selected_effector = 1 self.client_timestamp = None self.server_timestamp = None # TODO: decrease max frac_pos/time_offset on server side, and lower this. self.packet_jitter_buffer = 0.25 # 250 ms # Queue of incoming cursor changes, as list of (timestamp, [cursors]). self.cursor_updates = [] self.cursor_timestamp = 0
def scanIO(self): inputs = mido.get_input_names() outputs = mido.get_output_names() print("input names: ", inputs) print("output names: ", outputs) openmidiinputs = [] for i in inputs: string = "open " + i + "? Type anything for yes, or just hit enter for no" x = input(string) if x: newDevice = launchpad.Launchpad(i) openmidiinputs.append(newDevice) self.lpl = launchpadLayout.LaunchpadLayout(openmidiinputs) self.lpl.assignAsLayout( openmidiinputs) #to facilitate later changes in layouts self.setupPorts() #instance variable assigned to a Launchpad return openmidiinputs
import socket import sys from thread import * import launchpad HOST = '' PORT = 8888 BUFFER_SIZE = 10 lp = launchpad.Launchpad() lp.Open() text = "" s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print 'Socket erstellt.' try: s.bind((HOST, PORT)) except socket.error as msg: print 'Binden fehlgeschlagen. Errorcode : ' + str( msg[0]) + ' Message ' + msg[1] sys.exit() print 'Binden des Sockets abgeschlossen.' s.listen(10) print 'Socket hoert jetzt die Nachrichten ab.' def clientthread(conn): conn.send("Welcome to Sessho's Launchpad @ 33c3. Type text:\n") while 1: data = conn.recv(1024)
import time import launchpad import conway import renderer TIME_STEP_SECONDS = 0.5 TIME_CHANGE_FACTOR = 1.6 if __name__ == '__main__': lpad = launchpad.Launchpad() past_time = time.time_ns() step_timer = 0.0 playing = True lpad.get_pad(launchpad.CONTROL_PAD_FORWARD).set_on( launchpad.COLOR_GREEN) # show we're playing to start grid = conway.init_grid() print("ready...") while True: # update dt current_time = time.time_ns() delta_time = (current_time - past_time) / 1e+9 past_time = current_time if playing: step_timer += delta_time if step_timer > TIME_STEP_SECONDS: step_timer = 0.0
def main(): print 'main started' print 'connecting to launchpad' LP = launchpad.Launchpad( ) # creates a Launchpad instance (first Launchpad found) print 'connected, opening launchpad' LP.Open() # start it print 'opened, reset launchpad' LP.Reset() print 'reset' print 'connecting to drone' drone = libardrone.ARDrone("192.168.1.1") print 'connected' print 'asking for navdata' print drone.navdata while not drone.navdata: time.wait(33) print drone.navdata LP.LedCtrlString('UB', 0, 3, -1) if 'emergency_mask' in drone.navdata['drone_state']: while drone.navdata['drone_state']['emergency_mask'] == 1: print 'resetting' drone.reset() time.wait(16) print 'reset' LP.LedCtrlString('RY', 3, 0, 1) #controller, sequencer, stable mode = "controller" currentV = [0, 0, 0] currentY = 0 print "Checking for presses. 'arm' to end." while True: time.wait(10) but = LP.ButtonStateXY() if but != []: if mode == "controller": #big controller :^) LP.LedCtrlXY(but[0], but[1], 0, 3) print(but) if but[2]: current, currentY = handleButton(but, drone, currentV, currentY) if but[2] == False: LP.LedCtrlXY(but[0], but[1], 0, 0) LP.LedCtrlXY(5, 0, 3, 0) if mode == "sequencer": #record, sequence LP.LedCtrlXY(6, 0, 3, 0) if mode == "stable": currentV = stabilizeParrot(drone) LP.LedCtrlXY(4, 0, 3, 0) if but == [5, 0, True]: LP.LedCtrlXY(4, 0, 0, 0) LP.LedCtrlXY(6, 0, 0, 0) mode = "controller" if but == [6, 0, True]: LP.LedCtrlXY(4, 0, 0, 0) LP.LedCtrlXY(5, 0, 0, 0) mode = "sequencer" if but == [4, 0, True]: LP.LedCtrlXY(5, 0, 0, 0) LP.LedCtrlXY(6, 0, 0, 0) mode = "stable" if but == [8, 2, True]: print 'breaking' break drone.halt() LP.Reset() # turn all LEDs off LP.Close() # close the Launchpad
import time import pyxhook import launchpad log_file = 'log.txt' LP = launchpad.Launchpad() msg = "" dic = { "Return": "\\n", "space": " ", "Tab": "\\t", "period": ".", "colon": ":", "semicolon": ";", "Shift_L": "", "exclam": "!", "BackSpace": "BS", "asciicircum": "^", "asciitilde": "~", "minus": "-", "equal": "=", "Escape": "ESC", "parenleft": "(", "parenright": ")", "bracketleft": "[", "bracketright": "]", "braceleft": "{", "braceright": "}", "greater": ">", "less": "<", "quotedbl": "\"",
# find the tempo tempo_file = open("samples/%d/tempo" % (this_id, )) tempo_string = tempo_file.read() tempo = 120 if len(tempo_string) > 0: tempo = int(tempo_string) tempo_file.close() iteration_period = 60.0 / tempo total_iterations = 300 / iteration_period # create the objects play_objects = [ sounds.PlayoutObject("samples/%d/%d.wav" % (this_id, n)) for n in range(0, 6) ] lpd = launchpad.Launchpad() try: os.setpriority(os.PRIO_PROCESS, os.getpid(), -8) except: pass start_time = time.time() iteration = -1 while iteration < total_iterations: iteration += 1 current_column = iteration % 8 # start making the right combination of noises for n in range(0, model.Model.rows): if lpd.selected(current_column, n):