def set_control(self, control): """ Sets the control to use for controlling this property. """ self._remove_property_listener() self._on_takeover_control_value_changed.subject = None self._on_relative_control_value_changed.subject = None release_parameters((self._control, )) self._control = control self._can_set_value_directly = True self._use_full_range = False if control: if isinstance(control, SpecialButtonSliderElement): self._can_set_value_directly = False control.set_property_to_map_to( self if live_object_is_valid(self._parent) else None) elif isinstance(control, SpecialEncoderElement): control.set_property_to_map_to( self if live_object_is_valid(self._parent) else None) self._can_suppress_feedback = control.should_suppress_feedback_for_property_controls( ) if control.message_map_mode() in ABS_MODES: self._can_enforce_takeover = self._can_enforce_takeover and control.needs_takeover( ) if self._can_set_value_directly: self._on_takeover_control_value_changed.subject = control else: self._on_relative_control_value_changed.subject = control self._use_full_range = True self._add_property_listener() return
def set_sample_selector_control(self, control): """ Sets the control to use for 128-style control of the selected pad. This will attach to chain selector of the pad's instrument rack or the sample selector of the pad's Sampler. """ release_parameters((self._sample_selector_control, )) self._sample_selector_control = control self._update_sample_selector_connection()
def _update_master_volume_connection(self): if not self._use_0_db_volume: release_parameters((self._master_volume_control, )) if self.is_enabled() and self._master_volume_control: control = self._master_volume_control control.connect_to( self.song().master_track.mixer_device.volume)
def set_master_volume_control(self, control): """ Sets the control to use for controlling master volume. """ if self._use_0_db_volume: self._wrapper_dict['master_volume'].set_control(control) else: release_parameters((self._master_volume_control, )) self._master_volume_control = control self._update_master_volume_connection()
def set_volume_control(self, control): """ Sets the control to use for controlling the volume of the selected pad. """ if self._use_0_db_volume: self._0_db_volume_property.set_control(control) else: release_parameters((self._volume_control, )) self._volume_control = control self._update_volume_connection()
def _update_send_connections(self): release_parameters(self._send_controls) if self.is_enabled() and self._selected_chain: num_sends = len(self._selected_chain.mixer_device.sends) for index, control in enumerate(self._send_controls): if control and index < num_sends: control.connect_to( self._selected_chain.mixer_device.sends[index])
def set_crossfader_control(self, control): """ Sets the control to use for controlling the crossfader. """ release_parameters((self._crossfader_control, )) self._crossfader_control = control self._display_crossfader_value.subject = None if control: self._display_crossfader_value.subject = self.song( ).master_track.mixer_device.crossfader self._update_crossfader_connection() return
def _update_encoder_connections(self): """ Connects encoders to specified parameters for the current page. """ release_parameters(self._encoder_controls) if self.is_enabled() and self._encoder_controls: for index, control in enumerate(self._encoder_controls): if control: param = self._get_parameter_for_control(control, self._encoder_mapping[index]) control.connect_to(param) self.notify_encoder_parameters()
def _update_volume_connection(self): if self._use_0_db_volume: self._0_db_volume_property.set_parent( self._selected_chain.mixer_device.volume if self. _selected_chain else None) else: release_parameters((self._volume_control, )) if self.is_enabled() and self._selected_chain: if self._volume_control: self._volume_control.connect_to( self._selected_chain.mixer_device.volume) return
def disconnect(self): self._remove_property_listener() super(PropertyControl, self).disconnect() release_parameters((self._control, )) self._control = None self._parent = None self._property_name = None self._full_range = None self._absolute_range = None self._value_items = None self._display_callback = None self.canonical_parent = None return
def disconnect(self): release_parameters(self._encoder_controls) super(UserDevicesComponent, self).disconnect() self._param_dict = None self._device_class_names = None self._device_instance_names = None self._encoder_mapping = None self._button_mapping = None self._current_devices = None self._encoder_controls = None self._button_controls = None self._button_params = None return
def _update_sample_selector_connection(self): release_parameters((self._sample_selector_control, )) self._on_sample_selector_change.subject = None if self.is_enabled() and self._selected_chain: if self._sample_selector_control: devs = self._selected_chain.devices if devs: d = devs[0] param = None if d.type == Live.Device.DeviceType.instrument and d.can_have_chains: param = d.parameters[CHAIN_SELECTOR_INDEX] elif d.class_name == 'MultiSampler': param = d.parameters[SAMPLE_SELECTOR_INDEX] self._sample_selector_control.connect_to(param) self._on_sample_selector_change.subject = param return
def _update_control_connections(self, track_changed=False): if self.is_enabled(): release_parameters(self._controls) for slot in self._control_slots: self.disconnect_disconnectable(slot) del self._control_slots[:] if self._controls: self._on_update_connections_method() for i, control in enumerate(self._controls): if control: param = self._get_parameter(i) if live_object_is_valid(param): control.connect_to(param) else: self._register_slot_for_control(control)
def set_controls(self, controls): """ Sets the group of controls to use for controlling assigned parameters. This will also store the name of the group of controls for displaying purposes and determine the type of controls (absolute or relative) being used. """ self._set_is_mapping(False, display=False) self._can_map = True release_parameters(self._controls) self._on_control_value.replace_subjects([]) self._controls = list(controls) if controls else [] if self._controls: first = self._controls[0] if len(self._controls) == 1: self._controls_name = format_control_name(first) else: self._controls_name = controls.name.replace('_', ' ') self._controls_are_absolute = first.message_map_mode() in ABS_MODES self._is_button_slider = isinstance(first, SpecialButtonSliderElement) self._update_control_connections()
def _on_shift_button_value(self, value): self._can_map = True self._clear_current() if self.is_enabled() and self._controls: if not self._is_mapping: if value: c_name = format_control_name(self._controls[0]) self.component_message( c_name, 'Inc toggles mapping, Dec deletes all', revert=False) release_parameters(self._controls) self._on_control_value.replace_subjects(self._controls) else: self.component_message('', display_type=DisplayType.PHYSICAL) self._on_control_value.replace_subjects([]) self._update_control_connections() self._update_shift_button() self._update_button_sliders()
def _set_parameter_controls(self, controls, insert_start): self._suppress_show_msg = True if self._parameter_controls is not None: release_parameters(self._parameter_controls) controls = controls or EMPTY_BANK num_current = len(self._parameter_controls) insert_end = insert_start + BANK_LENGTH if insert_end > num_current: num_to_pad = (insert_end - num_current) / BANK_LENGTH - 1 for _ in xrange(num_to_pad): self._parameter_controls.extend(EMPTY_BANK) self._parameter_controls.extend(controls) else: for index, control in enumerate(controls): self._parameter_controls[index + insert_start] = control filled = [p for p in self._parameter_controls if p] self._num_filled_banks = len(filled) / BANK_LENGTH if filled else 0 self.update() return
def _on_selected_parameter_changed(self, display=True): if self._selected_parameter_control: release_parameters((self._selected_parameter_control, )) if self.is_enabled(): is_locked = False if self._selected_parameter_is_locked: if live_object_is_valid(self._current_selected_parameter): is_locked = True else: self._selected_parameter_is_locked = False self._update_selected_parameter_lock_button() param = self._current_selected_parameter if is_locked else self.song( ).view.selected_parameter if live_object_is_valid(param): self._current_selected_parameter = param self._selected_parameter_control.connect_to(param) if display and not is_locked: p_info = resolve_path_name_for_parameter( self.song(), param) self.component_message( 'Selected Parameter Control assigned to', p_info)
def _update_crossfader_connection(self): release_parameters((self._crossfader_control, )) if self.is_enabled() and self._crossfader_control: control = self._crossfader_control control.connect_to( self.song().master_track.mixer_device.crossfader)
def _update_cue_volume_connection(self): release_parameters((self._cue_volume_control, )) if self._is_enabled and self._cue_volume_control: control = self._cue_volume_control control.connect_to( self.song().master_track.mixer_device.cue_volume)
def set_encoder_controls(self, controls): """ Sets the encoders/knobs/faders to use for controlling parameters. """ release_parameters(self._encoder_controls) self._encoder_controls = controls self._update_encoder_connections()
def set_pan_control(self, control): """ Sets the control to use for controlling the panning of the selected pad. """ release_parameters((self._pan_control, )) self._pan_control = control self._update_pan_connection()
def set_cue_volume_control(self, control): """ Sets the control to use for controlling cue volume. """ release_parameters((self._cue_volume_control, )) self._cue_volume_control = control self._update_cue_volume_connection()
def set_send_controls(self, controls): """ Sets the controls to use for controlling the sends of the selected pad. """ release_parameters(self._send_controls) self._send_controls = controls or [] self._update_send_connections()
def set_macro_controls(self, controls): """ Sets the controls to use for controlling the Drum Rack's macros. """ release_parameters(self._macro_controls) self._macro_controls = controls or [] self._update_macro_connections()
def _update_pan_connection(self): release_parameters((self._pan_control, )) if self.is_enabled() and self._selected_chain: if self._pan_control: self._pan_control.connect_to( self._selected_chain.mixer_device.panning)
def set_control(self, control): """ Sets the control to use for controlling assigned parameters. """ release_parameters(self._controls) self._controls = [control] if control else [] self._update_control_connections()
def set_selected_parameter_control(self, control): """ Sets the control to use for controlling the selected parameter. """ release_parameters((self._selected_parameter_control, )) self._selected_parameter_control = control self._on_selected_parameter_changed(False)
def _update_macro_connections(self): release_parameters(self._macro_controls) if self.is_enabled() and self._drum_rack: for index, control in enumerate(self._macro_controls): control.connect_to(self._drum_rack.parameters[(index + 1)])