def _assign_notes_to_matrix(self): if self.is_enabled() and self._matrix: self._used_pads = [] self._unused_pads = [] if self._captured_notes: num_notes = len(self._captured_notes) w, h = self._matrix.width(), self._matrix.height() for btn, (column, row) in self._matrix.iterbuttons(): if btn: inv_row = h - 1 - row note_index = inv_row * w + column if note_index in xrange(num_notes): note = self._captured_notes[ note_index] + self._octave_offset color = 'Instrument.Notes.Sharp' if pitch_is_sharp( note) else 'Instrument.Notes.Natural' assign_button_to_note( btn, note, channel=self._translation_channel, color=color) self._used_pads.append(btn) else: reset_button(btn) self._unused_pads.append(btn) else: reset_group_buttons(self._matrix) self._unused_pads = self._matrix self.handle_unused_pads()
def set_buttons(self, buttons): """ Sets the buttons to use with the parsed assignments. """ buttons = list(buttons) if buttons else None if buttons: for k, v in self._assignable_controls.iteritems(): v.set_button(buttons[k]) if self._global_comp_layer is None and self._global_comp_dict: layer_dict = {} for k, v in self._global_comp_dict.iteritems(): layer_dict[v] = buttons[k] self._global_comp_layer = Layer(**layer_dict) self._global_comp_dict = None self._global_comp.layer = self._global_comp_layer if self._cx_button_indexes: cx_buttons = [ b if i in self._cx_button_indexes else None for i, b in enumerate(buttons) ] self._cx_comp.set_buttons(cx_buttons) unassigned = [ b for i, b in enumerate(buttons) if i not in self._assigned_button_indexes ] self._unassigned_button_listener.replace_subjects(unassigned) reset_group_buttons(unassigned) else: if self._assignable_controls: for v in self._assignable_controls.values(): v.set_button(None) if self._global_comp: self._global_comp.layer = None if self._cx_comp: self._cx_comp.set_buttons(None) if self._unassigned_button_listener: self._unassigned_button_listener.replace_subjects([]) return
def set_matrix(self, matrix): """ Sets the matrix to use for playing notes. """ self._unused_pads = [] self._used_pads = [] matrix_to_reset = matrix if matrix else self._matrix reset_group_buttons(matrix_to_reset) self._matrix = matrix if matrix: self._assign_notes_to_matrix()
def set_matrix(self, matrix): """ Sets the matrix to use for playing captured notes. """ self._unused_pads = [] self._used_pads = [] matrix_to_reset = matrix if matrix else self._matrix reset_group_buttons(matrix_to_reset) self._matrix = matrix if matrix: self._num_buttons = matrix.width() * matrix.height() self._assign_notes_to_matrix()
def set_matrix(self, matrix): """ Sets the matrix to use for playing Simpler. The matrix must be at least 4 wide. """ assert matrix is None or matrix.width() >= WIDTH matrix_to_reset = matrix if matrix else self._matrix reset_group_buttons(matrix_to_reset) self._matrix = matrix if matrix: self._num_note_controls = len(list(matrix)) self._row_xrange = xrange(matrix.height() - 1, -1, -1) self.set_simpler(self._simpler) return
def set_matrix(self, matrix): """ Sets the matrix to use for playing scales. The matrix must be 8 columns wide. """ self._unused_pads = [] self._used_pads = [] matrix_to_reset = matrix if matrix else self._matrix reset_group_buttons(matrix_to_reset) self._matrix = matrix if matrix: self._settings.can_change_layout = True self._settings.can_change_orientation = matrix.width( ) == matrix.height() self.update()
def set_matrix(self, matrix): """ Sets the matrix to use for playing drum instruments. """ self._used_pads = [] matrix_to_reset = matrix if matrix else self._matrix reset_group_buttons(matrix_to_reset) self._matrix = matrix if matrix: if self._invert_rows: self._row_xrange = xrange(matrix.height() - 1, -1, -1) else: self._row_xrange = xrange(matrix.height()) self._num_buttons = len(matrix) self._update_all_pad_settings()
def set_drum_matrix(self, matrix): """ Sets the matrix to use for playing/controlling the drum rack. """ assert matrix is None or matrix.height() % 2 == 0 self._unused_pads = [] self._used_pads = [] matrix_to_reset = matrix if matrix else self._drum_matrix reset_group_buttons(matrix_to_reset) self._drum_matrix = matrix if matrix: if self._invert_rows: self._row_xrange = xrange(matrix.height() - 1, -1, -1) else: self._row_xrange = xrange(matrix.height()) self._update_all_pad_settings() self._update_all_pad_leds() return
def _assign_notes_to_matrix(self): if self.is_enabled() and self._matrix: self._used_pads = [] self._unused_pads = [] if self._note_settings: for btn, (column, row) in self._matrix.iterbuttons(): setting = self._note_settings.get((row, column), None) if setting: assign_button_to_note(btn, setting['note'], channel=setting['channel'], color=setting['color']) self._used_pads.append(btn) else: reset_button(btn) self._unused_pads.append(btn) else: reset_group_buttons(self._matrix) self._unused_pads = self._matrix self.handle_unused_pads() return
def _update_all_slice_pad_settings(self): if self.is_enabled() and self._matrix: self._unused_pads = [] self._used_pads = [] if self._is_slicing(): last_id = SIMPLER_START_NOTE + self._octave_offset has_side_by_side = self._matrix.width() == MAX_WIDTH for row in self._row_xrange: for col in xrange(WIDTH): self._update_slice_pad_settings(row, col, last_id) last_id += 1 if has_side_by_side: for row in self._row_xrange: for col in xrange(WIDTH, MAX_WIDTH): self._update_slice_pad_settings(row, col, last_id) last_id += 1 else: reset_group_buttons(self._matrix) self._unused_pads = self._matrix self.handle_unused_pads()
def _update_all_pad_settings(self): if self.is_enabled(): self._unused_pads = [] self._used_pads = [] if self._drum_matrix: if self._drum_rack: last_id = self._drum_rack.visible_drum_pads[0].note has_side_by_side = self._drum_matrix.width() == MAX_WIDTH for row in self._row_xrange: for col in xrange(WIDTH): self._update_pad_settings(row, col, last_id) last_id += 1 if has_side_by_side: for row in self._row_xrange: for col in xrange(WIDTH, MAX_WIDTH): self._update_pad_settings(row, col, last_id) last_id += 1 else: reset_group_buttons(self._drum_matrix) self._unused_pads = self._drum_matrix self.handle_unused_pads()
def set_sequence_buttons(self, buttons): """ Sets the buttons to use for sequencing. """ matrix_to_reset = buttons if buttons else self._original_sequence_buttons self._original_sequence_buttons = list(buttons) if buttons else [] reset_group_buttons(matrix_to_reset) self._refresh_sequence_button_observers()