def _clean_heap(self): debug(self.name, '______________________clean_heap:', self._modes_heap) for _, _, observer in self._modes_heap: if observer != None: observer.disconnect() self._modes_heap = []
def _on_handshake_successful(self): debug('Launchpad._on_handshake_successful') self._suppress_send_midi = False self.set_enabled(True) self._selector.selected_mode = 'Session' self._selector.set_enabled(True) debug(self._selector.selected_mode)
def __init__(self, script = None, *a, **k): self._script = script self._main_offset = 0 self._troll_offset = 1 self._mode_on_troll_entrance = 'global' debug('making track mixer...') super(TrollMixerControlComponent, self).__init__(*a, **k)
def send(self, call = None, message = [], *a, **k): call = get_call_type(call) if call: message = self._prefix + self._model + call + message + [247] self._send_midi(tuple(message)) else: debug(call, 'is not a valid lividsettings call')
def _init_device(self, *a, **k): super(AumPush, self)._init_device(*a, **k) self._device = self._device_component debug('device_provider:', self._device_component._device_provider) #self._device_component._current_bank_details = self._make_current_bank_details(self._device_component) #self.modhandler.set_device_component(self._device_component) self._on_new_device_set.subject = self._device_provider
def _check_track_mixer_entry(self): debug('_check_track_mixer_entry') if self._troll_modes.selected_mode is 'enabled': if not self._mix_modes.selected_mode is 'track': self._mix_modes.push_mode('track') self._track_mixer_control.notify_scroll_offset() self._track_mixer_control.update()
def _setup_troll(self): debug('setup_troll') self._troll = AumPushTrollComponent(self, self._device_component) self._crossfader_strip = TouchStripControllerComponent() self._crossfader_strip.layer = Layer(touch_strip = self.elements.touch_strip_control) self._crossfader_strip.set_enabled(False) self._troll._mixer._master_strip.layer = Layer(priority = 6, select_button = self._with_select(self.elements.master_select_button)) self._troll._mixer._sends_layer = LayerMode(self._troll._mixer, Layer(priority = 6, track_select_buttons = self.elements.select_buttons, right_select_buttons = self.elements.track_state_buttons.submatrix[:4, :], return_select_buttons = self.elements.track_state_buttons.submatrix[4:, :], selected_controls = self.elements.global_param_controls.submatrix[:4, :], send_return_names_display=self.elements.display_line1, send_return_values_display=self.elements.display_line2, send_return_graphics_display=self.elements.display_line3, return_controls = self.elements.global_param_controls.submatrix[4:, :])) #, self._troll._mixer._left_layer = LayerMode(self._troll._mixer, Layer(priority = 6, track_select_buttons = self.elements.select_buttons, right_select_buttons = self.elements.track_state_buttons.submatrix[:4, :], return_select_buttons = self.elements.track_state_buttons.submatrix[4:, :], volume_controls = self.elements.global_param_controls, track_names_display=self.elements.display_line1, volume_values_display=self.elements.display_line2, volume_graphics_display=self.elements.display_line3)) self._troll._mixer._right_layer = LayerMode(self._troll._mixer, Layer(priority = 6, track_select_buttons = self.elements.select_buttons, right_select_buttons = self.elements.track_state_buttons.submatrix[:4, :], return_select_buttons = self.elements.track_state_buttons.submatrix[4:, :], right_volume_controls = self.elements.global_param_controls.submatrix[:4, :], input_volume_controls = self.elements.global_param_controls.submatrix[4:, :], right_track_names_display=self.elements.display_line1, right_volume_values_display=self.elements.display_line2, right_volume_graphics_display=self.elements.display_line3)) self._troll._mixer._device_layer = LayerMode(self._troll._mixer, Layer(priority = 6, track_select_buttons = self.elements.select_buttons, right_select_buttons = self.elements.track_state_buttons.submatrix[:4, :], return_select_buttons = self.elements.track_state_buttons.submatrix[4:, :], )) self._troll._send_reset.layer = Layer(priority = 6, send_a_button = self._with_select(self.elements.track_state_buttons_raw[4]), send_b_button = self._with_select(self.elements.track_state_buttons_raw[5]), send_c_button = self._with_select(self.elements.track_state_buttons_raw[6]), send_d_button = self._with_select(self.elements.track_state_buttons_raw[7])) self._troll._device_selector.layer = Layer(priority = 6, matrix = self.elements.matrix.submatrix[:, :4]) self._troll._device1.layer = Layer(priority = 6, parameter_controls = self.elements.global_param_controls, name_display_line=self.elements.display_line1, value_display_line=self.elements.display_line2, graphic_display_line=ComboElement('display_line3', 'any_touch_button')) self._troll._device2.layer = Layer(priority = 6, parameter_controls = self.elements.global_param_controls, name_display_line=self.elements.display_line1, value_display_line=self.elements.display_line2, graphic_display_line=ComboElement('display_line3', 'any_touch_button')) static_modes = CompoundMode(self._troll._mixer, self._crossfader_strip, tuple([self._grab_crossfader, self._release_crossfader]), self._troll._device_selector, self._troll._send_reset) self._troll._trollmodes.add_mode('sends', [static_modes, self._troll._mixer._sends_layer]) self._troll._trollmodes.add_mode('left', [static_modes, self._troll._mixer._left_layer]) self._troll._trollmodes.add_mode('right', [static_modes, self._troll._mixer._right_layer, self._troll._mixer.find_inputs]) self._troll._trollmodes.add_mode('device', [static_modes, self._troll._mixer._device_layer, self._device_parameter_component]) self._troll._trollmodes.add_mode('fx1', [static_modes, self._troll._mixer._device_layer, self._troll._device1, self._troll._find_device1]) self._troll._trollmodes.add_mode('fx2', [static_modes, self._troll._mixer._device_layer, self._troll._device2, self._troll._find_device2]) self._troll._trollmodes.selected_mode = 'sends' self._troll._trollmodes.layer = Layer(priority = 6, sends_button = self.elements.side_buttons_raw[0], left_button = self.elements.side_buttons_raw[1], right_button = self.elements.side_buttons_raw[2], device_button = self.elements.side_buttons_raw[3], fx1_button = self.elements.side_buttons_raw[4], fx2_button = self.elements.side_buttons_raw[5]) self._troll.set_enabled(False)
def _select_note_mode(self, mod_device=None): if not self._main_modes.selected_mode is 'troll': track = self.song.view.selected_track drum_device, sliced_simpler = self._percussion_instruments_for_track( track) self._drum_component.set_drum_group_device(drum_device) self._slicing_component.set_simpler(sliced_simpler) channelized = False debug('select_note_mode: ' + str(self.modhandler.active_mod()) + ' ' + str(len(track.devices))) if not (self._note_modes.selected_mode is 'mod' and self.modhandler.is_locked()): if track == None or track.is_foldable or track in self.song.return_tracks or track == self.song.master_track or ( hasattr(track, 'is_frozen') and track.is_frozen): self._note_modes.selected_mode = 'disabled' elif self.modhandler.active_mod(): self._note_modes.selected_mode = 'mod' elif track and track.has_audio_input: self._note_modes.selected_mode = 'looperhack' elif drum_device: self._note_modes.selected_mode = 'drums' elif sliced_simpler: self._note_modes.selected_mode = 'slicing' else: self._note_modes.selected_mode = 'instrument' self.reset_controlled_track() debug('new note mode is:', self._note_modes.selected_mode)
def update(self): debug('nav_box.update()') nav_grid = self._on_navigation_value.subject left_button = self._on_nav_left_value.subject right_button = self._on_nav_right_value.subject up_button = self._on_nav_up_value.subject down_button = self._on_nav_down_value.subject xinc = self._x_inc yinc = self._y_inc xoff = self.x_offset yoff = self.y_offset xmax = xoff+self._window_x ymax = yoff+self._window_y if nav_grid: for button, coord in nav_grid.iterbuttons(): x = coord[0] y = coord[1] button and button.set_light('Mod.Nav.OnValue' if ((x*xinc) in range(xoff, xmax)) and ((y*yinc) in range(yoff, ymax)) else 'Mod.Nav.OffValue') left_button and left_button.set_light('DefaultButton.On' if (xoff>0) else 'DefaultButton.Off') right_button and right_button.set_light('DefaultButton.On' if (xoff<(self.width()-self._window_x)) else 'DefaultButton.Off') up_button and up_button.set_light('DefaultButton.On' if (yoff>0) else 'DefaultButton.Off') down_button and down_button.set_light('DefaultButton.On' if (yoff<(self.height()-self._window_y)) else 'DefaultButton.Off') #a
def send_value(self, value, force=False): debug('send_value:', value, force) if (type(self) != type(None)): assert (value != None) assert isinstance(value, int) assert (value in range(128)) if (force or self._force_next_send or ((value != self._last_sent_value) and self._is_being_forwarded)): data_byte1 = self._original_identifier if value in list(range(1, 127)): data_byte2 = self._color_map[(value - 1) % (self._num_colors)] elif value == 127: data_byte2 = self._color_map[self._num_colors - 1] else: data_byte2 = self._darkened self._color = data_byte2 self.send_RGB(data_byte2) self._last_sent_message = [value] if self._report_output: is_input = True self._report_value(value, (not is_input)) self._flash_state = math.floor((value - 1) / self._num_colors) debug('flash_state:', math.floor( (value - 1) / self._num_colors), my_round((value - 1) / self._num_colors)) self._force_next_value = False
def _check_track_mixer_entry(self): debug('_check_track_mixer_entry') if self._troll_modes.selected_mode is 'enabled': if not self._mix_modes.selected_mode is 'track': #self._mix_modes.push_mode('track') self._mix_modes.selected_mode = 'track' self._track_mixer_control.notify_scroll_offset() self._track_mixer_control.update()
def Alt_button(self, button): debug('alt_button.pressed') self._is_alted = True mod = self.active_mod() if mod: mod.send('alt', 1) mod._device_proxy._alted = True mod._device_proxy.update_parameters() self.alt_layer and self.alt_layer.enter_mode() self.update()
def _default_volume_value(self, value): debug('_default_volume_value', value) assert self._default_volume_button != None assert value in range(128) if self.is_enabled() and self._track != None: if ( value != 0 or not self._default_volume_button.is_momentary() ) and self._track.mixer_device.volume and self._track.mixer_device.volume.is_enabled: self._track.mixer_device.volume.value = self._track.mixer_device.volume.default_value
def Shift_button(self, button): debug('shift_button.pressed') self._is_shifted = True mod = self.active_mod() if mod: mod.send('shift', 1) self.shift_layer and self.shift_layer.enter_mode() if mod and mod.legacy: self.legacy_shift_layer and self.legacy_shift_layer.enter_mode() self.update()
def _grab_track_mode(self): debug('grab device mode') """self._main_modes.pop_unselected_modes() if not self._main_modes.selected_mode is 'device': self._main_modes.push_mode('device') self._device_component._update_parameters()""" self._track_mixer_control._mode_on_troll_entrance = self._mix_modes.selected_mode self._track_mixer_control._main_offset = self._track_mixer_control.scroll_offset self._track_mixer_control._scroll_offset = self._track_mixer_control._troll_offset if self._main_modes.selected_mode is 'mix': self._check_track_mixer_entry()
def _on_handshake_success(self): debug('Handshake succeded with firmware version %.2f!' % self._handshake.firmware_version) self.update() if hasattr(self._c_instance, 'set_firmware_version'): debug('setting firmware version:', self._handshake.firmware_version) self._c_instance.set_firmware_version(self._handshake.firmware_version) if self._handshake.has_version_requirements(1, 16): self._user.settings = self._settings else: settings = copy(self._settings) del settings['aftertouch_threshold'] self._user.settings = settings
def _on_device_changed(self): debug('on device changed') device = self._device_provider.device if device: found = -1 for index in range(16): key = str('@loop' + str(index + 1)) preset = None if (match(key, str(device.name)) != None): found = index break if found > -1: self._looper._select_looper(index)
def press_immediate(self, component, mode): active_modes = component.active_modes groups = component.get_mode_groups(mode) if mode in active_modes: """can_cancel_mode = any(imap(lambda other: groups & component.get_mode_groups(other), active_modes)) debug('mode not in active_modes', can_cancel_mode) if can_cancel_mode: groups and component.pop_groups(groups) else:""" component.pop_mode(mode) self.restore_previous_mode(component) else: debug('mode in active_modes') self.remember_previous_mode(component) component.push_mode(mode)
def _release_track_mode(self): debug('release device mode') """if self._troll_modes.selected_mode is 'enabled': self._troll_modes.selected_mode = 'disabled' if len(self._main_modes.active_modes) > 1: self._main_modes.pop_mode('device') self._device_component._update_parameters()""" self._track_mixer_control._troll_offset = self._track_mixer_control.scroll_offset self._track_mixer_control._scroll_offset = self._track_mixer_control._main_offset if self._main_modes.selected_mode is 'mix': self._mix_modes.selected_mode = self._track_mixer_control._mode_on_troll_entrance if self._track_mixer_control._mode_on_troll_entrance is 'track': self._track_mixer_control.notify_scroll_offset() self._track_mixer_control.update()
def _shift_value(self, value, *a, **k): debug('mod shift value:', value) self._is_shifted = not value is 0 mod = self.active_mod() if mod: mod.send('shift', value) if self._is_shifted: self.shift_layer and self.shift_layer.enter_mode() if mod and mod.legacy: self.legacy_shift_layer and self.legacy_shift_layer.enter_mode() else: self.legacy_shift_layer and self.legacy_shift_layer.leave_mode() self.shift_layer and self.shift_layer.leave_mode() self.update()
def _alt_value(self, value, *a, **k): self._is_alted = not value is 0 button = self._alt_value.subject debug('alt button:', button) button and self._is_alted and button.set_light('DefaultButton.On') or button.set_light('DefaultButton.Off') mod = self.active_mod() if mod: mod.send('alt', value) mod._device_proxy._alted = bool(value) mod._device_proxy.update_parameters() if self.is_alted(): self.alt_layer and self.alt_layer.enter_mode() else: self.alt_layer and self.alt_layer.leave_mode() self.update()
def update(self): super(MainSelectorComponent, self).update() assert self._modes_buttons != None if self.is_enabled(): for index in range(len(self._modes_buttons)): self._modes_buttons[index].set_force_next_value() if index == self._mode_index: self._modes_buttons[index].turn_on() else: self._modes_buttons[index].turn_off() for scene_index in range(8): self._side_buttons[scene_index].set_enabled(True) for track_index in range(8): button = self._matrix.get_button(track_index, scene_index) if not button is None: button.set_enabled(True) for button in self._nav_buttons: button.set_enabled(True) as_active = True as_enabled = True self._session.set_allow_update(False) #self._zooming.set_allow_update(False) self._config_button.send_value(40) self._config_button.send_value(1) release_buttons = self._mode_index == USER_1_MODE self._mode_index == SESSION_MODE and self._setup_mixer( not as_active) self._setup_session(as_active, as_enabled) elif self._mode_index == USER_1_MODE: self._setup_session(not as_active, not as_enabled) self._setup_mixer(not as_active) self._setup_user(release_buttons) elif self._mode_index == USER_2_MODE: self._setup_session(not as_active, not as_enabled) self._setup_mixer(not as_active) self._setup_user(release_buttons) elif self._mode_index == MIXER_MODE: self._setup_session(not as_active, as_enabled) self._setup_mixer(as_active) else: #raise False or AssertionError debug('MainSelectorComponent._mode_index:', self._mode_index) self._session.set_allow_update(True) #self._zooming.set_allow_update(True) self._update_control_channels()
def _on_handshake_success(self): debug('Handshake succeded with firmware version %.2f!' % self._handshake.firmware_version) self.update() if hasattr(self._c_instance, 'set_firmware_version'): debug('setting firmware version:', self._handshake.firmware_version) self._c_instance.set_firmware_version( self._handshake.firmware_version) if self._handshake.has_version_requirements(1, 16): self._user.settings = self._settings else: settings = copy(self._settings) del settings['aftertouch_threshold'] self._user.settings = settings self._device_provider.reevaluate_device()
def _shift_value(self, value, *a, **k): debug('mod shift value:', value) self._is_shifted = not value is 0 mod = self.active_mod() if mod: mod.send('shift', value) if self._is_shifted: self.shift_layer and self.shift_layer.enter_mode() if mod and mod.legacy: self.legacy_shift_layer and self.legacy_shift_layer.enter_mode( ) else: self.legacy_shift_layer and self.legacy_shift_layer.leave_mode() self.shift_layer and self.shift_layer.leave_mode() self.update()
def _shift_value(self, value, *a, **k): debug('mod shift value:', value) self._is_shifted = not value is 0 button = self._shift_value.subject debug('shift button:', button) button and self._is_shifted and button.set_light('DefaultButton.On') or button.set_light('DefaultButton.Off') mod = self.active_mod() if mod: mod.send('shift', value) if self.is_shifted(): self.shift_layer and self.shift_layer.enter_mode() if mod and mod.legacy: self.legacy_shift_layer and self.legacy_shift_layer.enter_mode() else: self.legacy_shift_layer and self.legacy_shift_layer.leave_mode() self.shift_layer and self.shift_layer.leave_mode() self.update()
def receive_value(self, value): debug('exp val ' + str(value)) #value = min(127, max(0, (value - 96)*4)) #self._script.log_message('exp new val ' + str(value)) self._verify_value(value) if (value > self._last and (value - self._last) < 10) or (value < self._last and (self._last - value) < 10): self.notify_value(value) self._last = value if self._report_input: is_input = True self._report_value(value, is_input) else: orig_value = value value += int((value - self._last) > 0) * 5 self.notify_value(value) self._script.schedule_message(1, self.update_value, [orig_value, value]) self._last = value
def _select_note_mode(self, mod_device = None): track = self.song.view.selected_track drum_device, sliced_simpler = self._percussion_instruments_for_track(track) self._drum_component.set_drum_group_device(drum_device) self._slicing_component.set_simpler(sliced_simpler) debug('select_note_mode: ', self.modhandler.is_locked(), self.modhandler.active_mod(), len(track.devices)) if not (self._note_modes.selected_mode is 'mod' and self.modhandler.is_locked()): if track == None or track.is_foldable or track in self.song.return_tracks or track == self.song.master_track or track.is_frozen: self._note_modes.selected_mode = 'disabled' elif self.modhandler.active_mod(): self._note_modes.selected_mode = 'mod' elif track and track.has_audio_input: self._note_modes.selected_mode = 'looperhack' elif drum_device: self._note_modes.selected_mode = 'drums' elif sliced_simpler: self._note_modes.selected_mode = 'slicing' else: self._note_modes.selected_mode = 'instrument' self.reset_controlled_track()
def update(self): super(SubSelectorComponent, self).update() if not self._modes_buttons != None: debug('SubSelectorComponent.update:', self.is_enabled(), self._mode_index) if self.is_enabled(): if self._modes_buttons != None: for index in range(len(self._modes_buttons)): self._modes_buttons[index].set_on_off_values( GREEN_FULL, GREEN_THIRD) if index == self._mode_index: self._modes_buttons[index].turn_on() else: self._modes_buttons[index].turn_off() for button in self._side_buttons: button.set_on_off_values(127, LED_OFF) button.turn_off() for index in range(self._matrix.width()): self._sliders[index].set_disabled(self._mode_index == -1) self._mixer.set_allow_update(False) self._session.set_allow_update(False) if self._mode_index == -1: self._setup_mixer_overview() elif self._mode_index == 0: self._setup_volume_mode() elif self._mode_index == 1: self._setup_pan_mode() elif self._mode_index == 2: self._setup_send1_mode() elif self._mode_index == 3: self._setup_send2_mode() else: raise False or AssertionError self._update_callback != None and self._update_callback() self._mixer.set_allow_update(True) self._session.set_allow_update(True) else: self.release_controls()
def test_browser(self): debug('test_browser') browser = self.application.browser debug('browser is:', browser) user_folders = browser.user_folders debug('user_folders are:', user_folders) for item in user_folders: #debug('item is:', item, item.name) if item.name == 'defaultPresets': inneritems = item.iter_children for inneritem in inneritems: debug('inneritem:', inneritem) if inneritem.name == 'Default.aupreset': browser.load_item(inneritem) break
def _create_skin(self): debug('creating skin colors') return merge_skins(make_default_skin(), Skin(AumPushColors))
def _on_handshake_failure(self, bootloader_mode): debug('Handshake failed.')
def set_mode(self, mode): debug(self.name, '-----------------set_mode:', mode) self._clean_heap() self._modes_heap = [(mode, None, None)] if self._mode_index != mode: self._update_mode()
def fallback_send_midi(message = None, *a, **k): debug('control surface not assigned to the sysex call:', message);
def _grab_crossfader(self): debug('grab crossfader') self._crossfader_strip.set_parameter(self.song.master_track.mixer_device.crossfader)
def _create_main_modes_layer(self): debug('create_main_modes_layer') self._setup_troll() self._main_modes.add_mode('troll', [self._troll], behaviour = CancellableBehaviourWithRelease()) return Layer(priority = 6, troll_button='master_select_button', volumes_button='vol_mix_mode_button', pan_sends_button='pan_send_mix_mode_button', track_button='single_track_mix_mode_button', clip_button='clip_mode_button', device_button='device_mode_button', browse_button='browse_mode_button', add_effect_right_button='create_device_button', add_effect_left_button=self._with_shift('create_device_button'), add_instrument_track_button='create_track_button')
def set_alt_button(self, button): debug('setting alt button:', button) button and button.set_on_off_values('DefaultButton.On', 'DefaultButton.Off') button and button.set_light('DefaultButton.On') self._alt_value.subject = button
def _disable_troll(self): #self._troll_modes.selected_mode = 'disabled' debug('disable troll')
def select_mod(self, mod): super(PushModHandler, self).select_mod(mod) self._script._select_note_mode() self.update() debug('modhandler select mod: ' + str(mod))
def on_enabled_changed(self): debug('on_enabled_changed:', self._is_enabled) self.update()
def _check_track_mixer_exit(self): debug('_check_track_mixer_exit')
def update_device(self): if self.is_enabled() and not self._script._device_component is None: debug('modhandler.update_device') self._script._device_component.update() self._script._device_component._update_parameters()
def _detent_dial_value(self, value, *a, **k): debug('_detent_dial_value', value) if self._active_mod: self._active_mod.send('detent_dial', value)
def is_selected(self): debug('is selected:', self._index, self is self._parent._selected_loop or self._parent._all_loops_selected) return self is self._parent._selected_loop or self._parent._all_loops_selected
def _stop_selected_strip(self, value): debug('stop selected strip') track = self._mixer.selected_strip._track track and hasattr(track, 'stop_all_clips') and track.stop_all_clips()
def _on_main_mode_changed(self, mode): debug('main_mode selected mode is now:', mode)
def _troll_mode(self): val = False if hasattr(self._script, '_troll_modes'): val = self._script._troll_modes.selected_mode is 'enabled' debug('mixer._troll_mode():', val) return val