def _display_message_on_maschine(self, track_type): self._tasks.clear() self._info_display.clear_display(3) message = 'Created New {} Track'.format(track_type) display_task = partial(self._info_display.display_message_on_maschine, message, 3) clear_display = partial(self._info_display.clear_display, 3) self._tasks.add(task.sequence(task.run(display_task), task.wait(1), task.run(clear_display)))
def __init__(self, default_notification_time=2.5, blinking_time=0.3, display_lines=[], *a, **k): super(NotificationComponent, self).__init__(*a, **k) self._display_lines = get_element(display_lines) self._token_control = _TokenControlElement() self._align_text_fn = self._default_align_text_fn self._message_box = MessageBoxComponent(parent=self) self._message_box.set_enabled(False) self._default_notification_time = default_notification_time self._blinking_time = blinking_time self._original_text = None self._blink_text = None self._blink_text_task = self._tasks.add( task.loop( task.sequence( task.run(lambda: self._message_box.__setattr__( 'text', self._original_text)), task.wait(self._blinking_time), task.run(lambda: self._message_box.__setattr__( 'text', self._blink_text)), task.wait(self._blinking_time)))).kill() return
def __init__(self, attribute_tag = None, *a, **k): self._attribute_tag = '@'+attribute_tag+':' super(TaggedSettingsComponent, self).__init__(*a, **k) self._read_tag_task = self._parent_task_group.add(task.sequence(task.wait(.1), task.run(self._read_attribute_tag))) self._read_tag_task.kill() self._set_tag_task = self._parent_task_group.add(task.sequence(task.wait(.1), task.run(self._set_attribute_tag))) self._set_tag_task.kill()
def __init__(self, device_provider=None, device_bank_registry=None, toggle_lock=None, *a, **k): super(SimpleDeviceParameterComponent, self).__init__(*a, **k) self._toggle_lock = toggle_lock self._device = None self._banks = [] self._bank_index = 0 self._parameter_controls = None self._empty_control_slots = self.register_disconnectable(EventObject()) self._device_bank_registry = device_bank_registry self._device_provider = device_provider self._device_name_slot = self.register_slot( None, self._update_device_name_display, u'name') self.__on_provided_device_changed.subject = device_provider self.__on_provided_device_changed() self._display_bank_name_task = self._tasks.add( task.sequence(task.run(self._display_bank_name), task.wait(BANK_NAME_DISPLAY_DURATION), task.run(self._update_device_name_display))) self._display_bank_name_task.kill() if toggle_lock: self.__on_is_locked_to_device_changed.subject = self._device_provider self.__on_is_locked_to_device_changed()
def __init__(self, note_settings_component=None, automation_component=None, initial_encoder_layer=None, encoder_layer=None, *a, **k): super(NoteEditorSettingsComponent, self).__init__(*a, **k) raise encoder_layer or AssertionError self._request_hide = False self.settings = self.register_component(note_settings_component) self.settings.set_enabled(False) self._automation = self.register_component(automation_component) self._automation.set_enabled(False) self._mode_selector = self.register_component( OptionsComponent(num_options=2, num_labels=0, num_display_segments=8)) self._mode_selector.set_enabled(False) self._on_selected_option.subject = self._mode_selector self._update_available_modes() self._mode_selector.selected_option = 0 self._visible_detail_view = 'Detail/DeviceChain' self._show_settings_task = self._tasks.add( task.sequence(task.wait(defaults.MOMENTARY_DELAY), task.run(self._show_settings))).kill() self._update_infos_task = self._tasks.add( task.run(self._update_note_infos)).kill() self._settings_modes = self.register_component(ModesComponent()) self._settings_modes.set_enabled(False) self._settings_modes.add_mode('automation', [ self._automation, self._mode_selector, partial(self._set_envelope_view_visible, True), self._show_clip_view ]) self._settings_modes.add_mode('note_settings', [ self.settings, self._update_note_infos, self._mode_selector, partial(self._set_envelope_view_visible, False), self._show_clip_view ]) self._encoders = None self._initial_encoders = None self.add_mode('disabled', []) self.add_mode('about_to_show', [ AddLayerMode(self, initial_encoder_layer), (self._show_settings_task.restart, self._show_settings_task.kill) ]) self.add_mode('enabled', [ DetailViewRestorerMode(self.application), AddLayerMode(self, encoder_layer), self._update_available_modes, self._settings_modes ]) self.selected_mode = 'disabled' self._editors = [] self._on_detail_clip_changed.subject = self.song.view self._on_selected_track_changed.subject = self.song.view self.__on_full_velocity_changed.subject = self.settings self.__on_setting_changed.subject = self.settings return
def _display_message_on_maschine(self, enabled): message = 'Note Repeate is {}'.format('Off' if enabled else 'Active') display_task = partial(self._info_display.display_message_on_maschine, message, 3) clear_task = partial(self._info_display.clear_display, 3) self._tasks.add( task.sequence(task.run(display_task), task.wait(2.5), task.run(clear_task)))
def _blink_task(self): blink_on = partial(self._set_blinking_color, self.blink_on_color) blink_off = partial(self._set_blinking_color, self.blink_off_color) return self.tasks.add( task.sequence( task.run(blink_on), task.wait(self._blink_period), task.run(blink_off), task.wait(self._blink_period), task.run(blink_on), task.wait(self._blink_period), task.run(blink_off)))
def _display_message_on_maschine(self, view): self._tasks.clear() message = 'In {} View'.format(view) display_task = partial(self._info_display.display_message_on_maschine, message, 3) clear_task = partial(self._info_display.clear_display, 3) self._tasks.add( task.sequence(task.run(display_task), task.wait(1.5), task.run(clear_task)))
def _display_temprary_message_on_maschine(self, message, display_index): self._tasks.clear() self._info_display.clear_display(display_index) temp_display = partial(self._info_display.display_message_on_maschine, message, display_index) clear_display = partial(self._info_display.clear_display, display_index) self._tasks.add( task.sequence(task.run(temp_display), task.wait(2.5), task.run(clear_display), task.run(self._display_message_on_maschine)))
def _create_new_return_track(self): if len(self.song.return_tracks) < 12: self.song.create_return_track() self._display_message_on_maschine('return') else: self._info_display.clear_display(3) self._tasks.clear() message = 'Only 12 sends allowed' display_task = partial(self._info_display.display_message_on_maschine, message, 3) clear_display = partial(self._info_display.clear_display, 3) self._tasks.add(task.sequence(task.run(display_task), task.wait(1), task.run(clear_display)))
def _display_scale_and_key_info(self): self._tasks.clear() self._info_display.clear_display(3) message = 'Key - {} | Scale - {}'.format(NOTE_NAMES[self.root_note], self.scale.name) display_task = partial(self._info_display.display_message_on_maschine, message, 3) clear_task = partial(self._info_display.clear_display, 3) self._tasks.add( task.sequence(task.run(display_task), task.wait(1.5), task.run(clear_task)))
def __init__(self, attribute_tag=None, *a, **k): self._attribute_tag = "@" + attribute_tag + ":" super(TaggedSettingsComponent, self).__init__(*a, **k) self._read_tag_task = self._parent_task_group.add( task.sequence(task.wait(0.1), task.run(self._read_attribute_tag)) ) self._read_tag_task.kill() self._set_tag_task = self._parent_task_group.add( task.sequence(task.wait(0.1), task.run(self._set_attribute_tag)) ) self._set_tag_task.kill()
def __init__(self, *a, **k): super(SessionRecordingMixin, self).__init__(*a, **k) blink_on = partial(self._set_record_button_color, 'Recording.CaptureTriggered') blink_off = partial(self._set_record_button_color, 'DefaultButton.Off') self._blink_task = self._tasks.add( task.sequence(task.run(blink_on), task.wait(BLINK_PERIOD), task.run(blink_off), task.wait(BLINK_PERIOD), task.run(blink_on), task.wait(BLINK_PERIOD), task.run(blink_off))) self._blink_task.kill()
def __init__(self, *a, **k): super(UndoComponent, self).__init__(*a, **k) self._light_undo_button_task = self._tasks.add( task.sequence( task.run( partial(self._set_undo_button_light, 'DefaultButton.On')), task.wait(1.0), task.run( partial(self._set_undo_button_light, 'DefaultButton.Off')))) self._light_undo_button_task.kill()
def __init__(self, note_settings_component_class=None, automation_component_class=None, grid_resolution=None, initial_encoder_layer=None, encoder_layer=None, *a, **k): super(NoteEditorSettingsComponent, self).__init__(*a, **k) assert encoder_layer assert note_settings_component_class is not None assert automation_component_class is not None self.settings = note_settings_component_class( grid_resolution=grid_resolution, parent=self, is_enabled=False) self.automation = automation_component_class(parent=self, is_enabled=False) self._mode_selector = ModeSelector(parent=self, is_enabled=False) self._visible_detail_view = b'Detail/DeviceChain' self._show_settings_task = self._tasks.add( task.sequence(task.wait(defaults.MOMENTARY_DELAY), task.run(self._show_settings))).kill() self._update_infos_task = self._tasks.add( task.run(self._update_note_infos)).kill() self._settings_modes = ModesComponent(parent=self) self._settings_modes.set_enabled(False) self._settings_modes.add_mode(b'automation', [ self.automation, self._mode_selector, partial(self._set_envelope_view_visible, True), partial(show_clip_view, self.application) ]) self._settings_modes.add_mode(b'note_settings', [ self.settings, self._update_note_infos, self._mode_selector, partial(self._set_envelope_view_visible, False), partial(show_clip_view, self.application) ]) self._settings_modes.selected_mode = b'note_settings' self.__on_selected_setting_mode_changed.subject = self._settings_modes self.add_mode(b'disabled', []) self.add_mode(b'about_to_show', [ AddLayerMode(self, initial_encoder_layer), (self._show_settings_task.restart, self._show_settings_task.kill) ]) self.add_mode(b'enabled', [ DetailViewRestorerMode(self.application), AddLayerMode(self, encoder_layer), self._settings_modes ]) self.selected_mode = b'disabled' self._editors = [] self._on_detail_clip_changed.subject = self.song.view self._on_selected_track_changed.subject = self.song.view self.__on_full_velocity_changed.subject = self.settings self.__on_setting_changed.subject = self.settings return
def __init__(self, preferences=dict(), commit_model_changes=None, selection=None, main_modes_ref=None, *a, **k): assert commit_model_changes is not None super(BrowserComponent, self).__init__(*a, **k) self._lists = [] self._browser = Live.Application.get_application().browser self._current_hotswap_target = self._browser.hotswap_target self._updating_root_items = BooleanContext() self._focused_list_index = 0 self._commit_model_changes = commit_model_changes self._preferences = preferences self._expanded = False self._unexpand_with_scroll_encoder = False self._delay_preview_list = BooleanContext() self._selection = selection self._main_modes_ref = main_modes_ref if main_modes_ref is not None else nop self._load_neighbour_overlay = self.register_component( LoadNeighbourOverlayComponent(is_enabled=False)) self._content_filter_type = None self._content_hotswap_target = None self._preview_list_task = self._tasks.add( task.sequence(task.wait(self.REVEAL_PREVIEW_LIST_TIME), task.run( self._replace_preview_list_by_task))).kill() self._update_root_items() self._update_navigation_buttons() self._update_context() self.prehear_button.is_toggled = preferences.setdefault( u'browser_prehear', True) self._on_selected_track_color_index_changed.subject = self.song.view self._on_selected_track_name_changed.subject = self.song.view self._on_detail_clip_name_changed.subject = self.song.view self._on_hotswap_target_changed.subject = self._browser self._on_load_next.subject = self._load_neighbour_overlay self._on_load_previous.subject = self._load_neighbour_overlay self._on_focused_item_changed.subject = self self.register_slot(self, self.notify_focused_item, u'focused_list_index') def auto_unexpand(): self.expanded = False self._update_list_offset() self._unexpand_task = self._tasks.add( task.sequence(task.wait(self.EXPAND_LIST_TIME), task.run(auto_unexpand))).kill() return
def __init__(self, on_pong_callback=None, on_ping_timeout=None, *a, **k): super(PingPongComponent, self).__init__(*a, **k) assert on_pong_callback is not None assert on_ping_timeout is not None self._on_pong_callback = on_pong_callback self._on_ping_timeout = on_ping_timeout self._ping = None self._pong_received = False self._keepalive_task = self._tasks.add(task.sequence(task.run(self._send_ping), task.wait(PING_PERIOD), task.run(self._check_pong_received))) self._keepalive_task.kill() self._keepalive_starter_task = self._tasks.add(task.run(self._keepalive_task.restart)) self._keepalive_starter_task.kill() return
def __init__(self, real_time_mapper = None, register_real_time_data = None, *a, **k): super(RoutingControlComponent, self).__init__(*a, **k) self.__on_current_monitoring_state_changed.subject = self.song.view self._real_time_channel_assigner = RoutingMeterRealTimeChannelAssigner(real_time_mapper=real_time_mapper, register_real_time_data=register_real_time_data, is_enabled=False) self._update_monitoring_state_task = self._tasks.add(task.run(self._update_monitoring_state)) input_type_router = self.register_disconnectable(InputTypeRouter(song=self.song)) output_type_router = self.register_disconnectable(OutputTypeRouter(song=self.song)) input_channel_router = self.register_disconnectable(InputChannelRouter(song=self.song)) output_channel_router = self.register_disconnectable(OutputChannelRouter(song=self.song)) input_channel_and_position_router = self.register_disconnectable(InputChannelAndPositionRouter(input_channel_router, input_type_router)) self._active_type_router = input_type_router self._active_channel_router = input_channel_and_position_router self._can_route = can_set_input_routing self._update_can_route() self._routing_type_list, self._routing_channel_list = self.register_disconnectables([RoutingTypeList(parent_task_group=self._tasks, router=self._active_type_router), RoutingChannelList(parent_task_group=self._tasks, rt_channel_assigner=self._real_time_channel_assigner, router=self._active_channel_router)]) self.__on_input_channel_position_index_changed.subject = input_channel_and_position_router self._routing_channel_position_list = None self._update_routing_channel_position_list() self.add_mode(u'input', [SetAttributeMode(self, u'_can_route', can_set_input_routing), partial(self._set_active_routers, input_type_router, input_channel_and_position_router), self._real_time_channel_assigner]) self.add_mode(u'output', [SetAttributeMode(self, u'_can_route', lambda *a: True), partial(self._set_active_routers, output_type_router, output_channel_router), self._real_time_channel_assigner]) self.selected_mode = u'input' self.__on_selected_track_changed.subject = self.song.view self.__on_selected_track_changed() self._connect_monitoring_state_encoder() self.input_output_choice_encoder.connect_static_list(self, u'selected_mode', list_values=[u'input', u'output']) self.__on_selected_mode_changed.subject = self self.__on_tracks_changed.subject = self.song self.__on_return_tracks_changed.subject = self.song self._update_track_listeners()
def _set_loop(self): song = self.song slot = song.view.highlighted_clip_slot if slot is None: return clip = slot.clip loop_set = False if self._length_press_state is not None: press_slot, press_position = self._length_press_state if press_slot == slot and slot.is_recording and not clip.is_overdubbing: length, _ = self._fixed_length_setting.get_selected_length( song) one_bar = 4.0 * song.signature_numerator / song.signature_denominator loop_end = int(press_position / one_bar) * one_bar loop_start = loop_end - length if loop_start >= 0.0: clip.loop_end = loop_end clip.end_marker = loop_end clip.loop_start = loop_start clip.start_marker = loop_start self._tasks.add( task.sequence( task.delay(0), task.run( partial( slot.fire, force_legato=True, launch_quantization=Quantization.q_no_q)))) self.song.overdub = False loop_set = True self._length_press_state = None return loop_set
def __init__(self, *a, **k): super(AutomationComponent, self).__init__(*a, **k) self._selected_time = [] self._parameter_floats = [] self._update_parameter_values_task = self._tasks.add( task.run(self._update_parameter_values)) self._update_parameter_values_task.kill()
def __init__( self, selection=None, browser_component=None, browser_mode=None, browser_hotswap_mode=None, insert_left=False, *a, **k ): super(CreateDeviceComponent, self).__init__(*a, **k) self._selection = selection self._add_effect_mode = BrowserAddEffectMode( selection=selection, browser=self.application().browser, application_view=self.application().view, insert_left=insert_left, ) self._create_device_modes = self.register_component(ModesComponent()) self._create_device_modes.add_mode( "create", [ SetAttributeMode(browser_component, "do_load_item", self._do_browser_load_item), self._add_effect_mode, browser_mode, browser_component.reset_load_memory, ], ) self._create_device_modes.add_mode("hotswap", [browser_hotswap_mode, browser_mode]) self._go_to_hotswap_task = self._tasks.add(task.sequence(task.delay(1), task.run(self._go_to_hotswap))) self._go_to_hotswap_task.kill()
def __init__(self, clip_creator = None, grid_resolution = None, skin_base_key = 'NoteEditor', velocity_range_thresholds = None, *a, **k): raise skin_base_key is not None or AssertionError super(NoteEditorComponent, self).__init__(*a, **k) self._skin_base_key = skin_base_key self.loop_steps = False self.full_velocity = False self._selected_page_point = 0 self._page_index = 0 self._clip_creator = clip_creator self._matrix = None self._width = 0 self._height = 0 self._sequencer_clip = None self._step_colors = [] self._mute_button = None self._pressed_steps = [] self._modified_steps = [] self._pressed_step_callback = None 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 = {} self._clip_notes = [] self._note_index = 36 self._grid_resolution = grid_resolution self._on_resolution_changed.subject = self._grid_resolution self._nudge_offset = 0 self._length_offset = 0 self._velocity_offset = 0 self._triplet_factor = 1.0 self._update_from_grid() self.background_color = self._skin_base_key + '.StepEmpty' self._velocity_range_thresholds = velocity_range_thresholds or DEFAULT_VELOCITY_RANGE_THRESHOLDS
def _create_tasks(self, notification_time): duration = notification_time if notification_time is not None else self._default_notification_time self._notification_timeout_task = self._tasks.add( task.sequence(task.wait(duration), task.run(self.hide_notification) )).kill() if duration != -1 else self._tasks.add( task.Task()) return
def create_welcome_component(self): self._welcome = MaschineWelcome(name='Welcome') self._welcome.layer = Layer(pads='pad_matrix', group_buttons='group_matrix') self._tasks.add( task.sequence(task.wait(2), task.run(partial(self._welcome.set_enabled, False))))
def __init__(self, *a, **k): super(MidiClipControllerComponent, self).__init__(*a, **k) self._configure_vis_task = self._tasks.add( task.sequence(task.delay(1), task.run(self._configure_visualisation))).kill() self._clip = None self._matrix_mode_watcher = None self._most_recent_base_note = DEFAULT_START_NOTE self._most_recent_max_note = DEFAULT_START_NOTE self._loose_follow_base_note = DEFAULT_START_NOTE self._most_recent_editable_pitches = (DEFAULT_START_NOTE, DEFAULT_START_NOTE) self._most_recent_row_start_times = [] self._most_recent_step_length = 1.0 self._most_recent_page_index = 0 self._most_recent_page_length = 1.0 self._most_recent_editing_note_regions = [] self._visualisation_real_time_data = RealTimeDataComponent( channel_type='visualisation', parent=self) self.__on_visualisation_channel_changed.subject = self._visualisation_real_time_data self.__on_visualisation_attached.subject = self._visualisation_real_time_data self._instruments = [] self._sequencers = [] self._mute_during_track_change_components = [] self._note_settings_component = None self._note_editor_settings_component = None self._real_time_data_attached = False self._drum_rack_finder = None self._drum_pad_color_notifier = self.register_disconnectable( DrumPadColorNotifier()) self.__on_note_colors_changed.subject = self._drum_pad_color_notifier return
def __init__(self, scrollable_list=None, data_sources=tuple(), *a, **k): super(ListComponent, self).__init__(*a, **k) self._data_sources = data_sources self._activation_task = task.Task() self._action_on_scroll_task = task.Task() self._scrollable_list = None self._scroller = ScrollComponent(parent=self) self._pager = ScrollComponent(parent=self) self.last_action_item = lambda: self._last_action_item self.item_formatter = DefaultItemFormatter() for c in (self._scroller, self._pager): for button in (c.scroll_up_button, c.scroll_down_button): button.color = b'List.ScrollerOn' button.pressed_color = None button.disabled_color = b'List.ScrollerOff' if scrollable_list == None: self.scrollable_list = ActionList( num_visible_items=len(data_sources)) else: self.scrollable_list = scrollable_list self._scrollable_list.num_visible_items = len(data_sources) self._delay_activation = BooleanContext() self._selected_index_float = 0.0 self._in_encoder_selection = BooleanContext(False) self._execute_action_task = self._tasks.add( task.sequence(task.delay(1), task.run(self._execute_action))) self._execute_action_task.kill() return
def __init__(self, *a, **k): super(Akai_Force_MPC, self).__init__(*a, **k) self._product_id = None self._element_injector = inject( element_container=const(None)).everywhere() self._is_initialized = False self._initialize_task = self._tasks.add(task.run(self._initialize)) self._initialize_task.kill() self._components_enabled = False with self.component_guard(): self._ping_element = SysexElement( send_message_generator=const(SYSEX_MSG_HEADER + (BROADCAST_ID, PING_MSG_TYPE, SYSEX_END_BYTE)), name=b'Ping_Element') self._pong_element = MultiElement( name=b'Pong_Multi_Element', *[ IdentifyingSysexElement( sysex_identifier=SYSEX_MSG_HEADER + (identifier, PONG_MSG_TYPE), name=(b'Pong_Element_{}').format(index)) for index, identifier in enumerate(SUPPORTED_PRODUCT_IDS) ]) self._ping_pong = PingPongComponent( on_pong_callback=self._identify, on_ping_timeout=partial(self._enable_components, False), name=b'Ping_Pong') self._ping_pong.layer = Layer(ping=self._ping_element, pong=self._pong_element) return
def _hide_focus_task(self): tasks = self._tasks if tasks is not None: return tasks.add( task.sequence(task.wait(EncoderControl.TOUCH_TIME), task.run(self.try_hide_focus))) return
def __init__(self, selection=None, browser_component=None, browser_mode=None, browser_hotswap_mode=None, insert_left=False, *a, **k): super(CreateDeviceComponent, self).__init__(*a, **k) self._selection = selection self._add_effect_mode = BrowserAddEffectMode( selection=selection, browser=self.application.browser, application_view=self.application.view, insert_left=insert_left) self._create_device_modes = ModesComponent(parent=self) self._create_device_modes.add_mode(u'create', [ SetAttributeMode(browser_component, u'do_load_item', self._do_browser_load_item), self._add_effect_mode, browser_mode, browser_component.reset_load_memory ]) self._create_device_modes.add_mode( u'hotswap', [browser_hotswap_mode, browser_mode]) self._go_to_hotswap_task = self._tasks.add( task.sequence(task.delay(1), task.run(self._go_to_hotswap))) self._go_to_hotswap_task.kill()
def __init__(self, clip_creator = None, grid_resolution = None, skin_base_key = 'NoteEditor', velocity_range_thresholds = None, velocity_provider = None, *a, **k): raise skin_base_key is not None or AssertionError super(NoteEditorComponent, self).__init__(*a, **k) self._skin_base_key = skin_base_key self.full_velocity = False self._provided_velocity = None self._selected_page_point = 0 self._page_index = 0 self._clip_creator = clip_creator self._sequencer_clip = None self._step_colors = [] self._pressed_steps = [] self._modified_steps = [] self._pressed_step_callback = None 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 = {} self._clip_notes = [] self._note_index = 36 self._grid_resolution = grid_resolution self._on_resolution_changed.subject = self._grid_resolution self.set_step_duplicator(None) self._nudge_offset = 0 self._length_offset = 0 self._velocity_offset = 0 self._triplet_factor = 1.0 self._update_from_grid() self.background_color = self._skin_base_key + '.StepEmpty' self._velocity_range_thresholds = velocity_range_thresholds or DEFAULT_VELOCITY_RANGE_THRESHOLDS self._velocity_provider = velocity_provider or NullVelocityProvider() self.__on_provided_velocity_changed.subject = self._velocity_provider return
def __init__(self, scrollable_list = None, data_sources = tuple(), *a, **k): super(ListComponent, self).__init__(*a, **k) self._data_sources = data_sources self._activation_task = task.Task() self._action_on_scroll_task = task.Task() self._scrollable_list = None self._scroller = self.register_component(ScrollComponent()) self._pager = self.register_component(ScrollComponent()) self.last_action_item = lambda : self._last_action_item self.item_formatter = DefaultItemFormatter() for c in (self._scroller, self._pager): for button in (c.scroll_up_button, c.scroll_down_button): button.color = 'List.ScrollerOn' button.pressed_color = None button.disabled_color = 'List.ScrollerOff' if scrollable_list == None: self.scrollable_list = ActionList(num_visible_items=len(data_sources)) else: self.scrollable_list = scrollable_list self._scrollable_list.num_visible_items = len(data_sources) self._delay_activation = BooleanContext() self._selected_index_float = 0.0 self._in_encoder_selection = BooleanContext(False) self._execute_action_task = self._tasks.add(task.sequence(task.delay(1), task.run(self._execute_action))) self._execute_action_task.kill()
def __init__(self, curve_sysex_element=None, threshold_sysex_element=None, settings=None, chunk_size=None, *a, **k): assert curve_sysex_element is not None assert threshold_sysex_element is not None assert settings is not None assert chunk_size is not None super(PadVelocityCurveSender, self).__init__(*a, **k) self._curve_sysex_element = curve_sysex_element self._threshold_sysex_element = threshold_sysex_element self._settings = settings self._chunk_size = chunk_size self._send_task = self._tasks.add( task.sequence(task.wait(self.SEND_RATE), task.run(self._on_send_task_finished))).kill() self._settings_changed = False self.register_slot(settings, self._on_setting_changed, u'sensitivity') self.register_slot(settings, self._on_setting_changed, u'gain') self.register_slot(settings, self._on_setting_changed, u'dynamics') self._update_curve_model() return
def __init__(self, led_brightness_element=None, display_brightness_element=None, settings=None, *a, **k): assert led_brightness_element is not None assert display_brightness_element is not None assert settings is not None super(HardwareSettingsComponent, self).__init__(*a, **k) self._settings = settings self._led_brightness_element = led_brightness_element self._display_brightness_element = display_brightness_element self._led_brightness_timer = Live.Base.Timer( callback=self._on_fade_in_led_brightness_timer, interval=LED_FADE_IN_FREQUENCY, repeat=True) self._target_led_brightness = 0 self._led_brightness = 0 self._fade_in_delay_task = self._tasks.add( task.sequence(task.wait(LED_FADE_IN_DELAY), task.run( self._led_brightness_timer.restart))).kill() self.__on_led_brightness_changed.subject = settings self.__on_display_brightness_changed.subject = settings return
def start(self): raise self.state == 'welcome' or AssertionError self.set_enabled(True) def set_state(): self.state = 'start' self._tasks.add(task.sequence(task.wait(WELCOME_STATE_TIME), task.run(set_state)))
def _on_scroll(self): if self._trigger_action_on_scrolling: trigger_selected = partial(self._trigger_action, self.selected_item) self._action_on_scroll_task.kill() self._action_on_scroll_task = self._tasks.add( task.sequence(task.wait(defaults.MOMENTARY_DELAY), task.delay(1), task.run(trigger_selected)))
def _do_conversion(self, action_index): self._update_possible_conversions() if action_index < len(self._available_conversions): action = self._available_conversions[action_index] if action.needs_deferred_invocation: self._tasks.add(task.sequence(task.delay(1), task.run(lambda : self._do_conversion_deferred(action)))) return False self._invoke_conversion(action) return True
def _do_load_item(self, item): self.do_load_item(item) self._update_load_memory(item) self._skip_next_preselection = True def reset_skip_next_preselection(): self._skip_next_preselection = False self._tasks.add(task.run(reset_skip_next_preselection))
def __init__(self, velocity_levels = None, target_note_provider = None, skin_base_key = None, *a, **k): super(VelocityLevelsComponent, self).__init__(*a, **k) self._target_note_provider = target_note_provider or NullTargetNoteProvider() self.__on_selected_target_note_changed.subject = self._target_note_provider self._played_level = INVALID_LEVEL self.set_skin_base_key(skin_base_key or 'VelocityLevels') self._notification_task = self._tasks.add(task.run(self._update_velocity)) self._notification_task.kill() self.set_velocity_levels(velocity_levels)
def __init__(self, all_pads = tuple(), parameter_sender = nop, default_profile = PadParameters(), update_delay = 0, *a, **k): raise find_if(lambda pad: pad < 0 or pad > 63, all_pads or []) == None or AssertionError super(PadUpdateComponent, self).__init__(*a, **k) self.parameter_sender = parameter_sender self._all_pads = set(all_pads) self._modified_pads = set(all_pads) self._profiles = {'default': default_profile} self._profile_for = dict(zip(all_pads, repeat('default'))) self._profile_count = {'default': len(all_pads)} self._update_task = self._tasks.add(task.sequence(task.wait(update_delay), task.run(self._update_modified))) self._update_task.restart()
def __init__(self, playing_clip_above_layer = None, playing_clip_below_layer = None, *a, **k): super(SelectPlayingClipComponent, self).__init__(*a, **k) self._update_mode_task = self._tasks.add(task.sequence(task.delay(1), task.run(self._update_mode))) self._update_mode_task.kill() self.add_mode('default', None) self.add_mode('above', [AddLayerMode(self, playing_clip_above_layer), partial(self._show_notification, MessageBoxText.PLAYING_CLIP_ABOVE_SELECTED_CLIP)]) self.add_mode('below', [AddLayerMode(self, playing_clip_below_layer), partial(self._show_notification, MessageBoxText.PLAYING_CLIP_BELOW_SELECTED_CLIP)]) self.selected_mode = 'default' self._on_detail_clip_changed.subject = self.song.view self._on_playing_slot_index_changed.subject = self.song.view.selected_track self._notification_reference = partial(nop, None)
def __init__(self, *a, **k): super(MonoChannelStripComponent, self).__init__(*a, **k) self._device_provider = ChannelStripStaticDeviceProvider() self._device_component = ChaanelStripDeviceComponent(device_provider = self._device_provider, device_bank_registry = DeviceBankRegistry(), *a, **k) self._device_component._show_msg_callback = lambda message: None self._track_state = self.register_disconnectable(TrackArmState()) self._fold_task = self._tasks.add(Task.sequence(Task.wait(TRACK_FOLD_DELAY), Task.run(self._do_fold_track))).kill() self._on_arm_state_changed.subject = self._track_state self._ChannelStripComponent__on_selected_track_changed.subject = None self._ChannelStripComponent__on_selected_track_changed = self.__on_selected_track_changed self.__on_selected_track_changed.subject = self.song.view self.__on_selected_track_changed()
def __init__(self, identity_control=None, presentation_control=None, dongle_control=None, dongle=(0, 0), *a, **k): super(HandshakeComponent, self).__init__(*a, **k) self._identity_control = identity_control self._presentation_control = presentation_control self._dongle_control = dongle_control self._dongle_one, self._dongle_two = dongle self._on_identity_value.subject = identity_control self._on_dongle_value.subject = dongle_control self._identification_timeout_task = self._tasks.add( task.sequence(task.wait(HANDSHAKE_TIMEOUT), task.run(self._do_fail)) ) self._identification_timeout_task.kill()
def __init__(self, selection = None, browser_mode = None, browser_component = None, browser_hotswap_mode = None, *a, **k): super(CreateInstrumentTrackComponent, self).__init__(*a, **k) self._selection = selection self._with_browser_modes = self.register_component(ModesComponent()) self._with_browser_modes.add_mode('create', [self._prepare_browser, SetAttributeMode(self.application.browser, 'filter_type', Live.Browser.FilterType.instrument_hotswap), SetAttributeMode(browser_component, 'do_load_item', self._do_browser_load_item), browser_mode, browser_component.reset_load_memory]) self._with_browser_modes.add_mode('hotswap', [browser_hotswap_mode, browser_mode]) self._go_to_hotswap_task = self._tasks.add(task.sequence(task.delay(1), task.run(self._go_to_hotswap))) self._go_to_hotswap_task.kill()
def __init__(self, default_notification_time = 2.5, blinking_time = 0.3, display_lines = [], *a, **k): super(NotificationComponent, self).__init__(*a, **k) self._display_lines = get_element(display_lines) self._token_control = _TokenControlElement() self._align_text_fn = self._default_align_text_fn self._message_box = self.register_component(MessageBoxComponent()) self._message_box.set_enabled(False) self._default_notification_time = default_notification_time self._blinking_time = blinking_time self._original_text = None self._blink_text = None self._blink_text_task = self._tasks.add(task.loop(task.sequence(task.run(lambda : self._message_box.__setattr__('text', self._original_text)), task.wait(self._blinking_time), task.run(lambda : self._message_box.__setattr__('text', self._blink_text)), task.wait(self._blinking_time)))).kill()
def start(self, firmware): raise firmware is not None or AssertionError raise self.state == 'welcome' or AssertionError logger.info('Start firmware update using %r', firmware.filename) self._firmware = firmware self.notify_firmware_file() self.set_enabled(True) def set_state(): self.state = 'start' self._tasks.add(task.sequence(task.wait(WELCOME_STATE_TIME), task.run(set_state)))
def __init__(self, *a, **k): super(SpecialChanStripComponent, self).__init__(*a, **k) self.empty_color = 'Option.Unused' self._invert_mute_feedback = True self._duplicate_button = None self._selector_button = None self._delete_handler = None self._track_parameter_name_sources = [ DisplayDataSource(' ') for _ in xrange(14) ] self._track_parameter_data_sources = [ DisplayDataSource(' ') for _ in xrange(14) ] self._track_parameter_graphic_sources = [ DisplayDataSource(' ') for _ in xrange(14) ] self._on_return_tracks_changed.subject = self.song self._on_selected_track_changed.subject = self.song.view self._fold_task = self._tasks.add(task.sequence(task.wait(TRACK_FOLD_DELAY), task.run(self._do_fold_track))).kill() self._cue_volume_slot = self.register_disconnectable(ParameterSlot())
def __init__(self, curve_sysex_element = None, threshold_sysex_element = None, settings = None, chunk_size = None, *a, **k): raise curve_sysex_element is not None or AssertionError raise threshold_sysex_element is not None or AssertionError raise settings is not None or AssertionError raise chunk_size is not None or AssertionError super(PadVelocityCurveSender, self).__init__(*a, **k) self._curve_sysex_element = curve_sysex_element self._threshold_sysex_element = threshold_sysex_element self._settings = settings self._chunk_size = chunk_size self._send_task = self._tasks.add(task.sequence(task.wait(self.SEND_RATE), task.run(self._on_send_task_finished))).kill() self._settings_changed = False self.register_slot(settings, self._on_setting_changed, 'sensitivity') self.register_slot(settings, self._on_setting_changed, 'gain') self.register_slot(settings, self._on_setting_changed, 'dynamics') self._update_curve_model()
def __init__(self, solo_layer=None, mute_layer=None, *a, **k): super(MixerComponent, self).__init__(*a, **k) self._allow_released_immediately_action = True self.mixer_button_state = self.register_disconnectable(MixerButtonStateManager()) self._mixer_button_state_task = self._tasks.add( task.sequence(task.wait(self.MIXER_BUTTON_STATE_DELAY), task.run(self._update_mixer_button_state)) ).kill() self.add_mode("default", None) self.add_mode("solo", AddLayerMode(self, solo_layer)) self.add_mode("mute", AddLayerMode(self, mute_layer)) self.selected_mode = "default" self._on_items_changed.subject = self._provider self._on_selected_item_changed.subject = self._provider self._on_selected_item_changed() self._update_channel_strip_button_colors() self.__on_channel_strip_mute_or_solo_changed.replace_subjects(self._channel_strips)
def __init__(self, led_brightness_element=None, display_brightness_element=None, settings=None, *a, **k): raise led_brightness_element is not None or AssertionError raise display_brightness_element is not None or AssertionError raise settings is not None or AssertionError super(HardwareSettingsComponent, self).__init__(*a, **k) self._settings = settings self._led_brightness_element = led_brightness_element self._display_brightness_element = display_brightness_element self._led_brightness_timer = Live.Base.Timer( callback=self._on_fade_in_led_brightness_timer, interval=LED_FADE_IN_FREQUENCY, repeat=True ) self._target_led_brightness = 0 self._led_brightness = 0 self._fade_in_delay_task = self._tasks.add( task.sequence(task.wait(LED_FADE_IN_DELAY), task.run(self._led_brightness_timer.restart)) ).kill() self.__on_led_brightness_changed.subject = settings self.__on_display_brightness_changed.subject = settings
def __init__(self, note_settings_component = None, automation_component = None, initial_encoder_layer = None, encoder_layer = None, *a, **k): super(NoteEditorSettingsComponent, self).__init__(*a, **k) raise encoder_layer or AssertionError self._request_hide = False self.settings = self.register_component(note_settings_component) self.settings.set_enabled(False) self._automation = self.register_component(automation_component) self._automation.set_enabled(False) self._mode_selector = self.register_component(OptionsComponent(num_options=2, num_labels=0, num_display_segments=8)) self._mode_selector.set_enabled(False) self._on_selected_option.subject = self._mode_selector self._update_available_modes() self._mode_selector.selected_option = 0 self._visible_detail_view = 'Detail/DeviceChain' self._show_settings_task = self._tasks.add(task.sequence(task.wait(defaults.MOMENTARY_DELAY), task.run(self._show_settings))).kill() self._update_infos_task = self._tasks.add(task.run(self._update_note_infos)).kill() self._settings_modes = self.register_component(ModesComponent()) self._settings_modes.set_enabled(False) self._settings_modes.add_mode('automation', [self._automation, self._mode_selector, partial(self._set_envelope_view_visible, True), self._show_clip_view]) self._settings_modes.add_mode('note_settings', [self.settings, self._update_note_infos, self._mode_selector, partial(self._set_envelope_view_visible, False), self._show_clip_view]) self._encoders = None self._initial_encoders = None self.add_mode('disabled', []) self.add_mode('about_to_show', [AddLayerMode(self, initial_encoder_layer), (self._show_settings_task.restart, self._show_settings_task.kill)]) self.add_mode('enabled', [DetailViewRestorerMode(self.application), AddLayerMode(self, encoder_layer), self._update_available_modes, self._settings_modes]) self.selected_mode = 'disabled' self._editors = [] self._on_detail_clip_changed.subject = self.song.view self._on_selected_track_changed.subject = self.song.view self.__on_full_velocity_changed.subject = self.settings self.__on_setting_changed.subject = self.settings
def __init__( self, value_dict=[False, True], parent_task_group=None, number_channels=16, default_value_index=0, default_channel=0, channel_list=CHANNELS, *a, **k ): self._value_dict = value_dict self._range = len(value_dict) self._number_channels = number_channels self._channel = default_channel self._values = [default_value_index for x in range(number_channels)] self._channel_list = channel_list self._parent_task_group = parent_task_group super(ChannelizedSettingsBase, self).__init__(*a, **k) self._on_selected_track_changed.subject = self.song.view self._update_task = parent_task_group.add(task.sequence(task.wait(0.01), task.run(self.update))) self._update_task.kill()
def _set_loop(self): song = self.song slot = song.view.highlighted_clip_slot if slot is None: return clip = slot.clip loop_set = False if self._length_press_state is not None: press_slot, press_position = self._length_press_state if press_slot == slot and slot.is_recording and not clip.is_overdubbing: length, _ = self._fixed_length_setting.get_selected_length(song) one_bar = 4.0 * song.signature_numerator / song.signature_denominator loop_end = int(press_position / one_bar) * one_bar loop_start = loop_end - length if loop_start >= 0.0: clip.loop_end = loop_end clip.end_marker = loop_end clip.loop_start = loop_start clip.start_marker = loop_start self._tasks.add(task.sequence(task.delay(0), task.run(partial(slot.fire, force_legato=True, launch_quantization=Quantization.q_no_q)))) self.song.overdub = False loop_set = True self._length_press_state = None return loop_set
def _set_recording_quantization(self, value): def doit(): self.song.midi_recording_quantization = value self._tasks.parent_task.add(task.run(doit))
def _create_tasks(self, notification_time): duration = notification_time if notification_time is not None else self._default_notification_time self._notification_timeout_task = self._tasks.add(task.sequence(task.wait(duration), task.run(self.hide_notification))).kill() if duration != -1 else self._tasks.add(task.Task())
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()
def _init_handshake(self): dongle_message, dongle = make_dongle_message(sysex.DONGLE_ENQUIRY_PREFIX) identity_control = create_sysex_element(sysex.IDENTITY_PREFIX, sysex.IDENTITY_ENQUIRY) dongle_control = create_sysex_element(sysex.DONGLE_PREFIX, dongle_message) presentation_control = create_sysex_element(sysex.DONGLE_PREFIX, sysex.make_presentation_message(self.application())) self._handshake = HandshakeComponent(identity_control=identity_control, dongle_control=dongle_control, presentation_control=presentation_control, dongle=dongle, is_root=True) self._on_handshake_success.subject = self._handshake self._on_handshake_failure.subject = self._handshake self._start_handshake_task = self._tasks.add(task.sequence(task.wait(HANDSHAKE_DELAY), task.run(self._start_handshake))) self._start_handshake_task.kill()
def _disabled_encoders(self): self._disable_all_encoders() yield self._tasks.add(task.sequence(task.wait(self.MOVE_DELAY), task.run(self._enable_all_encoders)))
def _create_notification_timeout_task(self, duration): self._notification_timeout_task = self._tasks.add( task.sequence(task.wait(duration), task.run(self.hide_notification)) )
def action_button(self, button): self._settings_task.kill() self._settings_task = self._tasks.add(task.sequence(task.wait(self.SETTINGS_DELAY), task.run(self._do_show_settings))) self.trigger_action()
def __init__(self, preferences = dict(), commit_model_changes = None, selection = None, *a, **k): raise commit_model_changes is not None or AssertionError super(BrowserComponent, self).__init__(*a, **k) self._lists = [] self._browser = Live.Application.get_application().browser self._current_hotswap_target = self._browser.hotswap_target self._updating_root_items = BooleanContext() self._focused_list_index = 0 self._commit_model_changes = commit_model_changes self._preferences = preferences self._expanded = False self._unexpand_with_scroll_encoder = False self._delay_preview_list = BooleanContext() self._selection = selection self._load_next = False self._content_filter_type = None self._content_hotswap_target = None self._preview_list_task = self._tasks.add(task.sequence(task.wait(self.REVEAL_PREVIEW_LIST_TIME), task.run(self._replace_preview_list_by_task))).kill() self._update_root_items() self._update_navigation_buttons() self._update_load_text() self._update_context() self.prehear_button.is_toggled = preferences.setdefault('browser_prehear', True) self._on_selected_track_color_index_changed.subject = self.song.view self._on_selected_track_name_changed.subject = self.song.view self._on_hotswap_target_changed.subject = self._browser self.register_slot(self, self.notify_focused_item, 'focused_list_index') def auto_unexpand(): self.expanded = False self._update_list_offset() self._unexpand_task = self._tasks.add(task.sequence(task.wait(self.EXPAND_LIST_TIME), task.run(auto_unexpand))).kill() return