def _update_editor_matrix_leds(self): """ update hardware LEDS to match offline array values """ if self.is_enabled() and self._matrix: for row, col in product(xrange(STEP_SEQ_HEIGHT), xrange(STEP_SEQ_WIDTH)): index = row * STEP_SEQ_WIDTH + col color = self._step_colors[index] self._matrix.set_light(col, row, color)
def _update_editor_matrix_leds(self): """ update hardware LEDS to match offline array values """ if self.is_enabled() and self._matrix: for row, col in product(xrange(self._height), xrange(self._width)): index = row * self._width + col color = self._step_colors[index] self._matrix.set_light(col, row, color)
def set_button_matrix(self, matrix): last_page_length = self.page_length self._matrix = matrix self._on_matrix_value.subject = matrix if matrix: self._width = matrix.width() self._height = matrix.height() matrix.reset() for button, _ in ifilter(first, matrix.iterbuttons()): button.set_channel(PAD_FEEDBACK_CHANNEL) for task in self._step_tap_tasks.itervalues(): task.kill() def trigger_modification_task(x, y): trigger = partial(self._trigger_modification, (x, y), done=True) return self._tasks.add( Task.sequence(Task.wait(Defaults.MOMENTARY_DELAY), Task.run(trigger))).kill() self._step_tap_tasks = dict([ ((x, y), trigger_modification_task(x, y)) for x, y in product(xrange(self._width), xrange(self._height)) ]) if matrix and last_page_length != self.page_length: self._on_clip_notes_changed() self.notify_page_length() else: self._update_editor_matrix()
def _update_measure_leds(self): """ update hardware leds to match precomputed map """ if self.is_enabled() and self._loop_selector_matrix: width = self._loop_selector_matrix.width() height = self._loop_selector_matrix.height() matrix_idx = product(xrange(height), xrange(width)) for (row, col), color in izip(matrix_idx, self._measure_colors): self._loop_selector_matrix.set_light(col, row, color)
def __init__(self, clip_creator=None, playhead=None, *a, **k): super(NoteEditorComponent, self).__init__(*a, **k) self.loop_steps = False self._selected_page_point = 0 self._page_index = 0 self._clip_creator = clip_creator self._matrix = None self._sequencer_clip = None self._step_colors = ["NoteEditor.StepEmpty"] * STEP_SEQ_SIZE self._note_settings_layer = None self._top_data_sources = map(DisplayDataSource, STEP_PARAM_NAMES) self._bottom_data_sources = [DisplayDataSource() for _ in xrange(8)] self._show_settings_task = self._tasks.add( Task.sequence(Task.wait(Defaults.MOMENTARY_DELAY), Task.run(self._show_settings)) ) self._show_settings_task.kill() self._mute_button = None self._velocity_offset = 0 self._length_offset = 0 self._nudge_offset = 0 self._attribute_deltas = [None for _ in xrange(3)] self._full_velocity = False self._pressed_steps = [] self._modified_steps = [] self._pressed_step_callback = None self._quantization_buttons = [] self._quantization_button_slots = self.register_slot_manager() self._modify_task = self._tasks.add(Task.run(self._do_modification)) self._modify_task.kill() self._modify_all_notes_enabled = False self._step_tap_tasks = dict( [ ( (x, y), self._tasks.add( Task.sequence( Task.wait(Defaults.MOMENTARY_DELAY), Task.run(partial(self._trigger_modification, (x, y), done=True)), ) ), ) for x, y in product(xrange(STEP_SEQ_WIDTH), xrange(STEP_SEQ_HEIGHT)) ] ) for task in self._step_tap_tasks.itervalues(): task.kill() self._clip_notes = [] self._note_index = 36 self._triplet_factor = 1.0 self._set_quantization_index(3) self._playhead = playhead self._playhead_notes = range(92, 100) + range(84, 92) + range(76, 84) + range(68, 76) self._playhead_triplet_notes = range(92, 98) + range(84, 90) + range(76, 82) + range(68, 74) with self._playhead_update_guard(): self._update_full_playhead()
def __init__(self, clip_creator=None, playhead=None, *a, **k): super(NoteEditorComponent, self).__init__(*a, **k) self.loop_steps = False self._selected_page_point = 0 self._page_index = 0 self._clip_creator = clip_creator self._matrix = None self._sequencer_clip = None self._step_colors = ['NoteEditor.StepEmpty'] * STEP_SEQ_SIZE self._note_settings_layer = None self._top_data_sources = map(DisplayDataSource, STEP_PARAM_NAMES) self._bottom_data_sources = [DisplayDataSource() for _ in xrange(8)] self._show_settings_task = self._tasks.add( Task.sequence(Task.wait(Defaults.MOMENTARY_DELAY), Task.run(self._show_settings))) self._show_settings_task.kill() self._mute_button = None self._velocity_offset = 0 self._length_offset = 0 self._nudge_offset = 0 self._attribute_deltas = [None for _ in xrange(3)] self._full_velocity = False self._pressed_steps = [] self._modified_steps = [] self._pressed_step_callback = None self._quantization_buttons = [] self._quantization_button_slots = self.register_slot_manager() self._modify_task = self._tasks.add(Task.run(self._do_modification)) self._modify_task.kill() self._modify_all_notes_enabled = False self._step_tap_tasks = dict([ ((x, y), self._tasks.add( Task.sequence( Task.wait(Defaults.MOMENTARY_DELAY), Task.run( partial(self._trigger_modification, (x, y), done=True))))) for x, y in product(xrange(STEP_SEQ_WIDTH), xrange( STEP_SEQ_HEIGHT)) ]) for task in self._step_tap_tasks.itervalues(): task.kill() self._clip_notes = [] self._note_index = 36 self._triplet_factor = 1.0 self._set_quantization_index(3) self._playhead = playhead self._playhead_notes = range(92, 100) + range(84, 92) + range( 76, 84) + range(68, 76) self._playhead_triplet_notes = range(92, 98) + range(84, 90) + range( 76, 82) + range(68, 74) with self._playhead_update_guard(): self._update_full_playhead()
def _create_and_set_pad_translations(self, matrix): def create_translation_entry((y, x)): button = matrix.get_button(x, y) return (x, y + NUM_PADS_Y - matrix.height(), button.message_identifier() if button is not None else 0, button.message_channel() if button is not None else 0) translations = map(create_translation_entry, product(xrange(matrix.height()), xrange(matrix.width()))) self._set_pad_translations(tuple(translations))
def set_clip_launch_buttons(self, buttons): assert not buttons or buttons.width( ) == self._num_tracks and buttons.height() == self._num_scenes if buttons: for button, (x, y) in buttons.iterbuttons(): scene = self.scene(y) slot = scene.clip_slot(x) slot.set_launch_button(button) else: for x, y in product(xrange(self._num_tracks), xrange(self._num_scenes)): scene = self.scene(y) slot = scene.clip_slot(x) slot.set_launch_button(None) return
def set_button_matrix(self, matrix): last_page_length = self.page_length self._matrix = matrix self._on_matrix_value.subject = matrix if matrix: self._width = matrix.width() self._height = matrix.height() matrix.reset() for button, _ in ifilter(first, matrix.iterbuttons()): button.set_channel(PAD_FEEDBACK_CHANNEL) for task in self._step_tap_tasks.itervalues(): task.kill() def trigger_modification_task(x, y): trigger = partial(self._trigger_modification, (x, y), done=True) return self._tasks.add(Task.sequence(Task.wait(Defaults.MOMENTARY_DELAY), Task.run(trigger))).kill() self._step_tap_tasks = dict([ ((x, y), trigger_modification_task(x, y)) for x, y in product(xrange(self._width), xrange(self._height)) ]) if matrix and last_page_length != self.page_length: self._on_clip_notes_changed() self.notify_page_length() else: self._update_editor_matrix()
#Embedded file name: /Users/versonator/Jenkins/live/Binary/Core_Release_64_static/midi-remote-scripts/Push/GridResolution.py import Live GridQuantization = Live.Clip.GridQuantization from _Framework.SubjectSlot import subject_slot, SlotManager, Subject from _Framework.Util import product QUANTIZATION_FACTOR = 24 QUANTIZATION_LIST = [2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0, 24.0] CLIP_VIEW_GRID_LIST = tuple( product([ GridQuantization.g_thirtysecond, GridQuantization.g_sixteenth, GridQuantization.g_eighth, GridQuantization.g_quarter ], [True, False])) CLIP_LENGTH_LIST = [2.0, 4.0, 4.0, 8.0, 8.0, 16.0, 16.0, 32.0] DEFAULT_INDEX = 3 class GridResolution(SlotManager, Subject): __subject_events__ = ('index', ) def __init__(self, *a, **k): super(GridResolution, self).__init__(*a, **k) self._index = DEFAULT_INDEX self._quantization_buttons = [] self._quantization_button_slots = self.register_slot_manager() def _get_index(self): return self._index def _set_index(self, index): self._index = index self.notify_index()
#Embedded file name: /Users/versonator/Jenkins/live/Binary/Core_Release_static/midi-remote-scripts/Push/GridResolution.py import Live GridQuantization = Live.Clip.GridQuantization from _Framework.SubjectSlot import subject_slot, SlotManager, Subject from _Framework.Util import product QUANTIZATION_FACTOR = 24 QUANTIZATION_LIST = [2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0, 24.0] CLIP_VIEW_GRID_LIST = tuple(product([GridQuantization.g_thirtysecond, GridQuantization.g_sixteenth, GridQuantization.g_eighth, GridQuantization.g_quarter], [True, False])) CLIP_LENGTH_LIST = [2.0, 4.0, 4.0, 8.0, 8.0, 16.0, 16.0, 32.0] DEFAULT_INDEX = 3 class GridResolution(SlotManager, Subject): __subject_events__ = ('index',) def __init__(self, *a, **k):
def xiterbuttons(self): for i, j in product(xrange(self.width()), xrange(self.height())): button = self.get_button(i, j) yield (button, (i, j))
STEP_SEQ_SIZE = STEP_SEQ_WIDTH * STEP_SEQ_HEIGHT STEP_SEQ_OVERALL_LENGTH = STEP_SEQ_SIZE * 4.0 STEP_STATE_INITIAL = -1 STEP_STATE_DONT_DELETE = 0 STEP_STATE_ALLOW_DELETE = 1 STEP_STATE_ADDED_MUTED = 2 DEFAULT_VELOCITY = 100 QUANTIZATION_FACTOR = 24 BEAT_TIME_EPSILON = 1e-05 QUANTIZATION_LIST = [2.0, 3.0, 4.0, 6.0, 8.0, 12.0, 16.0, 24.0] CLIP_VIEW_GRID_LIST = tuple( product( [ GridQuantization.g_thirtysecond, GridQuantization.g_sixteenth, GridQuantization.g_eighth, GridQuantization.g_quarter, ], [True, False], ) ) CLIP_LENGTH_LIST = [2.0, 4.0, 4.0, 8.0, 8.0, 16.0, 16.0, 32.0] def color_for_note(note): velocity = note[3] muted = note[4] if not muted: if velocity == 127: return "NoteEditor.StepFullVelocity" elif velocity >= 100: