def __init__(self, offset=(0, 1), record_state=False, cyclic=False, colorscheme=0): """ Stores all of the required vars to send signals to the launchpad Offset arg refers to x, y offset Color scale runs from 0-14 (fewer options, but acts as a simple spectrum) methods include a runner, which accepts a function to act on the object """ self.lp = Launchpad() self.lp.Open() self.lp.LedCtrlXY(0, 0, 0, 3) self.lp.LedCtrlXY(0, 0, 0, 0) self.offset = offset cols = ([(0, 3), (1, 3), (1, 2), (2, 2), (2, 1), (3, 1), (3, 0)], [(3, 0), (3, 1), (2, 1), (2, 1), (2, 0), (1, 0), (0, 0)]) tmp = cols[colorscheme] if cyclic == True: self.colorscale = { x: y for x, y in enumerate(tmp[:-1] + tmp[::-1][:-1]) } else: self.colorscale = {x: y for x, y in enumerate(tmp)} self.lp.Reset() self.record_state = record_state self.lp.state = {x: {y: -1 for y in xrange(8)} for x in xrange(8)}
def __init__(self): logging.basicConfig(level=logging.INFO) self.sub = [] self.handlers = [] self.load_all_modules_from_dir("subscriber") self.register_handlers() self.lp = Launchpad() self.lp.reset()
def __init__(self): args = _parse_args() if not args.port: print("ERROR: Please use -p option to specify device midi port.") sys.exit(1) # connect with the launchpad print("Connecting with launchpad") self.launchpad = Launchpad(args.port, self.process_midi_event) # load the plugins print("Loading plugins using config file: %s" % args.configfile) load_plugins(self.launchpad, args.configfile) # start reading midi events self.launchpad.read_midi_event()
def __init__(self, os_name, package_name, flair='flair', log_level=logging.INFO, is_compress=True): self._flair = Flair(flair) self._archive = Launchpad() self._os_name = os_name self._package_name = package_name self._is_compress = is_compress self._logger = logging.getLogger('Allirt') self._logger.setLevel(log_level) stream_handler = logging.StreamHandler() formatter = logging.Formatter('[%(levelname)s] %(message)s') stream_handler.setFormatter(formatter) self._logger.addHandler(stream_handler)
def __init__(self): super(MainWidget, self).__init__() self.audio = Audio(2)# two channel self.mixer = Mixer() self.audio.set_generator(self.mixer) # Initialize and create all the wave buffers from the regions self.wave_buffers = make_wave_buffers("data/unforgettable_regions.txt","data/unforgettable_beat.wav") keys = ["shelter","workit","harder","doit","stronger","drop","drop2","drop3","drop4","drop5","getdown","getdownbuild","getup","overtime","again","build","high A","high G","Ab","Gb","Db","Eb","entire", "oo", "blurp", "goochi", "lulpump", "yeuh", "gchgang"] self.songs = {} for key in keys: if os.path.exists("data/" + key + ".wav") is True: self.songs[key] = WaveFile("data/" + key + ".wav") # Initialize and create all the wave buffers from the regions self.wave_buffers2 = make_wave_buffers("data/gucci_gang_regions.txt","data/gucci_gang.wav") self.songs["high A"] = self.wave_buffers["high A"] self.songs["high G"] = self.wave_buffers["high G"] self.songs["Ab"] = self.wave_buffers["Ab"] self.songs["Gb"] = self.wave_buffers["Gb"] self.songs["Db"] = self.wave_buffers["Db"] self.songs["Eb"] = self.wave_buffers["Eb"] self.songs["entire"] = self.wave_buffers["entire"] self.songs["oo"] = self.wave_buffers2["oo"] self.songs["blurp"] = self.wave_buffers2["blurp"] self.songs["goochi"] = self.wave_buffers2["goochi"] self.songs["lulpump"] = self.wave_buffers2["lulpump"] self.songs["yeuh"] = self.wave_buffers2["yeuh"] self.songs["gchgang"] = self.wave_buffers2["gchgang"] self.shelter_gen = WaveGenerator(self.songs['shelter'],True) self.workit_gen = WaveGenerator(self.songs['workit']) self.doit_gen = WaveGenerator(self.songs['doit']) self.harder_gen = WaveGenerator(self.songs['harder']) self.stronger_gen = WaveGenerator(self.songs['stronger']) self.drop_gen = WaveGenerator(self.songs['drop'],True) self.drop_gen2 = WaveGenerator(self.songs['drop2'],True) self.drop_gen3 = WaveGenerator(self.songs['drop3'],True) self.drop_gen4 = WaveGenerator(self.songs['drop4'],True) self.drop_gen5 = WaveGenerator(self.songs['drop5'],True) self.getdown_gen = WaveGenerator(self.songs['getdown']) self.getdownbuild_gen = WaveGenerator(self.songs['getdownbuild'],True) self.getup_gen = WaveGenerator(self.songs['getup']) self.overtime_gen = WaveGenerator(self.songs['overtime']) self.again_gen = WaveGenerator(self.songs['again']) self.build_gen = WaveGenerator(self.songs['build'],True) # Create all of the generators for the song # sections allow for that self.high_a_gen = WaveGenerator(self.wave_buffers["high A"]) self.high_g_gen = WaveGenerator(self.wave_buffers["high G"]) self.ab_gen = WaveGenerator(self.wave_buffers["Ab"],True) self.gb_gen = WaveGenerator(self.wave_buffers["Gb"],True) self.db_gen = WaveGenerator(self.wave_buffers["Db"],True) self.eb_gen = WaveGenerator(self.wave_buffers["Eb"],True) self.entire_gen = WaveGenerator(self.wave_buffers["entire"],True) self.oo_gen = WaveGenerator(self.wave_buffers2["oo"]) self.blurp_gen = WaveGenerator(self.wave_buffers2["blurp"]) self.gooch_gen = WaveGenerator(self.wave_buffers2["goochi"]) self.lulpump_gen = WaveGenerator(self.wave_buffers2["lulpump"]) self.yeh_gen = WaveGenerator(self.wave_buffers2["yeuh"]) self.gucci_gang_gen = WaveGenerator(self.wave_buffers2["gchgang"], True) self.gens = [] self.gens.append(self.shelter_gen) self.gens.append(self.workit_gen) self.gens.append(self.doit_gen) self.gens.append(self.harder_gen) self.gens.append(self.stronger_gen) self.gens.append(self.drop_gen) self.gens.append(self.drop_gen2) self.gens.append(self.drop_gen3) self.gens.append(self.drop_gen4) self.gens.append(self.drop_gen5) self.gens.append(self.getdown_gen) self.gens.append(self.getdownbuild_gen) self.gens.append(self.getup_gen) self.gens.append(self.overtime_gen) self.gens.append(self.again_gen) self.gens.append(self.build_gen) self.gens.append(self.high_a_gen) self.gens.append(self.high_g_gen) self.gens.append(self.ab_gen) self.gens.append(self.gb_gen) self.gens.append(self.db_gen) self.gens.append(self.eb_gen) self.gens.append(self.entire_gen) self.gens.append(self.oo_gen) self.gens.append(self.blurp_gen) self.gens.append(self.gooch_gen) self.gens.append(self.lulpump_gen) self.gens.append(self.yeh_gen) self.gens.append(self.gucci_gang_gen) self.launchpad = {} for i in range(len(self.gens)): print(keys[i]) self.launchpad[keys[i]] = self.gens[i] self.mixer.add(self.gens[i]) self.gens[i].pause() self.L = Launchpad(self) # print('HI THERE\n HI THERE') self.L.calibration_mode()
ACTION_TYPE = { "0": "KEYIN", "1": "EXEC", "2": "NOTE", "3": "WAVE", "9": "SPECIAL" } settings = configparser.ConfigParser() settings.read("settings.ini") midiInPort = settings['midi']['midiInPort'] midiOutPort = settings['midi']['midiOutPort'] lp = Launchpad() if DEBUG is True: il, ol = lp.getDeviceList() print("now available input is {}".format(il)) print("now available output is {}".format(ol)) print("inport is {}, outport is {}".format(midiInPort, midiOutPort)) result = lp.connect(midiInPort, midiOutPort) if result is True: doloop = True while doloop: try: msg = lp.getMsg() if msg:
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.light_button_map = {} self.current_light = None self.lights = {} self.data_queue = {} self.recording = {'states': []} self.recording_ptr = -1 self.recording_to = self.config.get('RECORD') self.dim_speed = 0 if self.recording_to: if os.path.exists(self.recording_to): with open(self.recording_to, 'r') as fp: self.recording = json.load(fp) self.recording_ptr = len(self.recording['states']) - 1 if self.recording['states']: self.set_recording_state(-1) else: self.recording['states'].append({'lights': {}}) self.recording_ptr = 0 light_buttons = [] x = y = 0 for i in self.config.get('OUTPUTS', []): if not i['DEVICE'].endswith('Gobo'): # FIXME: this is hacky continue c = i.get('LABEL_COLOR') if c: if isinstance(c, str): c = Color(getattr(Colors, c), intensity=3) else: c = RGBColor(*c) else: c = Color(Colors.WHITE, intensity=4) light_buttons.append(Momentary(on_color=Color(Colors.WHITE, intensity=1), off_color=c, callback=self.select_light, buttons=ButtonGroup(x, y, x, y))) self.light_button_map[(x, y)] = i['NAME'] x += 1 if x > 7: x = 0 y += 1 record_buttons = [] if self.recording_to: record_buttons = [ Momentary(on_color=Color(Colors.WHITE), off_color=Color(Colors.GREEN), callback=self.record_prev, buttons=ButtonGroup('TOP', 'UP')), Momentary(on_color=Color(Colors.WHITE), off_color=Color(Colors.GREEN), callback=self.record_next, buttons=ButtonGroup('TOP', 'DOWN')), Momentary(on_color=Color(Colors.WHITE), off_color=Color(Colors.RED), callback=self.record_save, buttons=ButtonGroup('TOP', 'LEFT')), Momentary(on_color=Color(Colors.WHITE), off_color=Color(Colors.GREEN), callback=self.record_new_state, buttons=ButtonGroup('TOP', 'RIGHT')), ] reset_buttons = [ # Reset pan Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.WHITE), callback=self.gobo_pan_reset, buttons=ButtonGroup('RIGHT', 'VOLUME')), # Reset tilt Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.WHITE), callback=self.gobo_tilt_reset, buttons=ButtonGroup('RIGHT', 'PAN')), # Reset speed Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.GREEN), callback=self.gobo_speed_reset, buttons=ButtonGroup('RIGHT', 'STOP')), # Reset dim Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.YELLOW), callback=self.gobo_dim_reset, buttons=ButtonGroup('RIGHT', 'MUTE')), # Reset dim speed Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.ORANGE), callback=self.gobo_dim_speed_reset, buttons=ButtonGroup('RIGHT', 'SOLO')), # Reset all Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.RED), callback=self.gobo_all_reset, buttons=ButtonGroup('RIGHT', 'RECORDARM')), ] self.lp = Launchpad() fade = (0.1, 0.4, 0.6, 1) self.pages = { 'select_light': Page( include_top=True, include_right=True, controls=[ Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.GREEN), callback=self._no_op, buttons=ButtonGroup('TOP', 'SESSION')), ] + light_buttons + reset_buttons + record_buttons ), 'control_gobo': Page( include_top=True, include_right=True, controls=[ # Back to light sel Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.WHITE), callback=self.select_light, buttons=ButtonGroup('TOP', 'SESSION')), # Mode indicator Momentary(on_color=Color(Colors.BLUE), off_color=Color(Colors.GREEN), callback=self._no_op, buttons=ButtonGroup('TOP', 'MIXER')), # pan - decrease Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(v, 0, 0) for v in reversed(fade)], callback=self.gobo_pan_decrease, buttons=ButtonGroup(0, 0, 3, 0)), # pan - increase Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(0, v, 0) for v in fade], callback=self.gobo_pan_increase, buttons=ButtonGroup(4, 0, 7, 0)), # tilt - decrease Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(v, 0, 0) for v in reversed(fade)], callback=self.gobo_tilt_decrease, buttons=ButtonGroup(0, 1, 3, 1)), # tilt - increase Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(0, v, 0) for v in fade], callback=self.gobo_tilt_increase, buttons=ButtonGroup(4, 1, 7, 1)), # Colors # TODO: use real colors Momentary(on_color=Color(Colors.WHITE), off_color=[Color(getattr(Colors, v)) for v in ('WHITE', 'RED', 'YELLOW', 'GREEN', 'CYAN1', 'BLUE', 'PURPLE', 'PINK')], callback=self.gobo_color, buttons=ButtonGroup(0, 2, 7, 2)), # Gobo Momentary(on_color=Color(Colors.WHITE), off_color=Color(Colors.PURPLE), callback=self.gobo_gobo, buttons=ButtonGroup(0, 3, 7, 3)), # speed - decrease Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(v, 0, 0) for v in reversed(fade)], callback=self.gobo_speed_decrease, buttons=ButtonGroup(0, 4, 3, 4)), # speed - increase Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(0, v, 0) for v in fade], callback=self.gobo_speed_increase, buttons=ButtonGroup(4, 4, 7, 4)), # dim - decrease Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(v, 0, 0) for v in reversed(fade)], callback=self.gobo_dim_decrease, buttons=ButtonGroup(0, 5, 3, 5)), # dim - increase Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(0, v, 0) for v in fade], callback=self.gobo_dim_increase, buttons=ButtonGroup(4, 5, 7, 5)), # dim speed - decrease Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(v, 0, 0) for v in reversed(fade)], callback=self.gobo_dim_speed_decrease, buttons=ButtonGroup(0, 6, 3, 6)), # dim speed - increase Momentary(on_color=Color(Colors.WHITE), off_color=[RGBColor(0, v, 0) for v in fade], callback=self.gobo_dim_speed_increase, buttons=ButtonGroup(4, 6, 7, 6)), # Strobe Momentary(on_color=Color(Colors.WHITE), off_color=[Color(Colors.RED), Color(Colors.GREEN)], callback=self.gobo_strobe, buttons=ButtonGroup(0, 7, 1, 7)), ] + reset_buttons + record_buttons ) } self.lp.push_page(self.pages['select_light'])