class ActionsComponent(ControlSurfaceComponent): """ Simple component that provides undo/redo, record quantization toggle and clip quantization handling. """ undo_button = ButtonControl(**ACTION_BUTTON_COLORS) redo_button = ButtonControl( color="Misc.Shift", pressed_color="Misc.ShiftOn", disabled_color="DefaultButton.Disabled" ) quantization_on_button = ToggleButtonControl(untoggled_color="Misc.Shift", toggled_color="Misc.ShiftOn") def __init__(self, *a, **k): self.suppressing_control_notifications = BooleanContext() super(ActionsComponent, self).__init__(*a, **k) self._record_quantization = RecordingQuantization.rec_q_sixtenth self._on_record_quantization_changed_in_live.subject = self.song() self._on_record_quantization_changed_in_live() self._metronome_toggle = ToggleComponent("metronome", self.song()) def control_notifications_enabled(self): return self.is_enabled() and not self.suppressing_control_notifications def quantize_clip(self, clip): raise isinstance(clip, Live.Clip.Clip) or AssertionError clip.quantize(self._record_quantization, 1.0) @undo_button.pressed def undo_button(self, button): if self.song().can_undo: self.song().undo() @redo_button.pressed def redo_button(self, button): if self.song().can_redo: self.song().redo() @quantization_on_button.toggled def quantization_on_button(self, is_toggled, button): self._record_quantization_on = is_toggled self.song().midi_recording_quantization = ( self._record_quantization if self._record_quantization_on else RecordingQuantization.rec_q_no_q ) @subject_slot("midi_recording_quantization") def _on_record_quantization_changed_in_live(self): quant_value = self.song().midi_recording_quantization quant_on = quant_value != RecordingQuantization.rec_q_no_q if quant_on: self._record_quantization = quant_value self._record_quantization_on = quant_on with self.suppressing_control_notifications(): self.quantization_on_button.is_toggled = quant_on def set_metronome_button(self, button): self._metronome_toggle.set_toggle_button(button) def update(self): super(ActionsComponent, self).update() self._metronome_toggle.update()
def __init__(self, *a, **k): self.suppressing_control_notifications = BooleanContext() super(ActionsComponent, self).__init__(*a, **k) self._record_quantization = RecordingQuantization.rec_q_sixtenth self._on_record_quantization_changed_in_live.subject = self.song() self._on_record_quantization_changed_in_live() self._metronome_toggle = ToggleComponent('metronome', self.song())
def __init__(self, c_instance, session, parent): TransportComponent.__init__(self) self.c_instance = c_instance self._shift_pressed = False self._mixer9_button = None self._play_button = None self._record_button = None self._session = session self._parent = parent song = self.song() # self._automation_toggle= self.register_component(ToggleComponent('session_automation_record', song)) self._automation_toggle, self._re_enable_automation_toggle, self._delete_automation = self.register_components( ToggleComponent('session_automation_record', song), ToggleComponent('re_enable_automation_enabled', song, read_only=True), ToggleComponent('has_envelopes', None, read_only=True))
def __init__(self, clip_creator=None, view_controller=None, *a, **k): super(SessionRecordingComponent, self).__init__(*a, **k) raise clip_creator or AssertionError raise view_controller or AssertionError self._target_slots = [] self._clip_creator = clip_creator self._view_controller = view_controller self._new_button = None self._scene_list_new_button = None self._record_button = None self._length_press_state = None self._new_scene_button = None self._fixed_length = self.register_component( ToggleWithOptionsComponent()) self._length_selector = self._fixed_length.options self._length_selector.option_names = LENGTH_OPTION_NAMES self._length_selector.selected_option = 3 self._length_selector.labels = LENGTH_LABELS self._on_selected_fixed_length_option_changed.subject = self._length_selector length, _ = self._get_selected_length() self._clip_creator.fixed_length = length song = self.song() self._automation_toggle, self._re_enable_automation_toggle, self._delete_automation = self.register_components( ToggleComponent('session_automation_record', song), ToggleComponent('re_enable_automation_enabled', song, read_only=True), ToggleComponent('has_envelopes', None, read_only=True)) self._on_tracks_changed_in_live.subject = song self._on_is_playing_changed_in_live.subject = song self._track_subject_slots = self.register_slot_manager() self._reconnect_track_listeners() self.register_slot(song, self.update, 'overdub') self.register_slot(song, self.update, 'session_record_status') self.register_slot(song.view, self.update, 'selected_track') self.register_slot(song.view, self.update, 'selected_scene') self.register_slot(song.view, self.update, 'detail_clip')
class ActionsComponent(ControlSurfaceComponent): """ Simple component that provides undo/redo, record quantization toggle and clip quantization handling. """ undo_button = ButtonControl(**ACTION_BUTTON_COLORS) duplicate_button = ButtonControl(**ACTION_BUTTON_COLORS) redo_button = ButtonControl(color='Misc.Shift', pressed_color='Misc.ShiftOn', disabled_color='DefaultButton.Disabled') tap_button = ButtonControl(color='Misc.Shift', pressed_color='Misc.ShiftOn', disabled_color='DefaultButton.Disabled') quantization_on_button = ToggleButtonControl(untoggled_color='Misc.Shift', toggled_color='Misc.ShiftOn') def __init__(self, *a, **k): self.suppressing_control_notifications = BooleanContext() super(ActionsComponent, self).__init__(*a, **k) self._record_quantization = RecordingQuantization.rec_q_sixtenth self._on_record_quantization_changed_in_live.subject = self.song() self._on_record_quantization_changed_in_live() self._metronome_toggle = ToggleComponent('metronome', self.song()) def control_notifications_enabled(self): return self.is_enabled() and not self.suppressing_control_notifications def quantize_clip(self, clip): assert isinstance(clip, Live.Clip.Clip) clip.quantize(self._record_quantization, 1.0) @tap_button.pressed def tap_button(self, button): self.song().tap_tempo() @undo_button.pressed def undo_button(self, button): if self.song().can_undo: self.song().undo() @duplicate_button.released def duplicate_button(self, button): self.canonical_parent._copied_slot = None @redo_button.pressed def redo_button(self, button): if self.song().can_redo: self.song().redo() @quantization_on_button.toggled def quantization_on_button(self, is_toggled, button): self._record_quantization_on = is_toggled self.song().midi_recording_quantization = self._record_quantization if self._record_quantization_on else RecordingQuantization.rec_q_no_q @subject_slot('midi_recording_quantization') def _on_record_quantization_changed_in_live(self): quant_value = self.song().midi_recording_quantization quant_on = quant_value != RecordingQuantization.rec_q_no_q if quant_on: self._record_quantization = quant_value self._record_quantization_on = quant_on with self.suppressing_control_notifications(): self.quantization_on_button.is_toggled = quant_on def set_metronome_button(self, button): self._metronome_toggle.set_toggle_button(button) def update(self): super(ActionsComponent, self).update() self._metronome_toggle.update()
def __init__(self, *a, **k): super(MaschineTransport, self).__init__(*a, **k) song = self.song() self._automation_toggle, self._re_enable_automation_toggle, self._delete_automation, self._arrangement_overdub_toggle, self._back_to_arrange_toggle = self.register_components(ToggleComponent('session_automation_record', song), ToggleComponent('re_enable_automation_enabled', song, read_only=True), ToggleComponent('has_envelopes', None, read_only=True), ToggleComponent('arrangement_overdub', song), ToggleComponent('back_to_arranger', song)) return