Пример #1
0
    def _on_press_loop_selector_matrix(self, page):

        def create_clip(pages):
            measure = self._one_measure_in_beats
            length = self._quantize_page_index(pages, measure) + measure
            create_clip_in_selected_slot(self._clip_creator, self.song, length)

        def handle_page_press_on_clip(page):
            l_start, l_length = self._get_loop_in_pages()
            page_in_loop = l_start <= page < l_start + l_length
            buttons_pressed = len(self._pressed_pages)
            if buttons_pressed == 1 and page_in_loop:
                self._try_select_page(page)
            elif buttons_pressed > 1 or not page_in_loop:
                self._try_set_loop()

        self._pressed_pages.append(page)
        absolute_page = page + self.page_offset
        if not self._select_button or not self._select_button.is_pressed():
            if not liveobj_valid(self._sequencer_clip) and not self.song.view.highlighted_clip_slot.has_clip:
                create_clip(absolute_page)
            elif liveobj_valid(self._sequencer_clip):
                handle_page_press_on_clip(absolute_page)
        elif not self.is_following:
            self._try_select_page(absolute_page)
Пример #2
0
 def __init__(self, clip_slot = None, track = None, *a, **k):
     raise liveobj_valid(clip_slot) or AssertionError
     raise liveobj_valid(track) or AssertionError
     super(CreateTrackWithSimpler, self).__init__(name_source=clip_slot.clip, color_source=clip_slot.clip, *a, **k)
     self._clip_slot = clip_slot
     self._track = track
     self.__on_has_clip_changed.subject = self._clip_slot
 def _update_warp_mode_source(self):
     display_value = "-"
     if liveobj_valid(self.clip):
         display_value = (
             WARP_MODE_NAMES[self.clip.warp_mode] if liveobj_valid(self.clip) and self.clip.warping else "Off"
         )
     self._value_sources[0].set_display_string(display_value)
 def _update_hotswap_target(self):
     try:
         browser = self.application.browser
         if liveobj_valid(self.selected_object) and liveobj_valid(browser.hotswap_target):
             browser.hotswap_target = self.selected_object
     except RuntimeError:
         pass
Пример #5
0
 def deviceType(self):
     device_type = 'default'
     device = self.device
     if liveobj_valid(device):
         device = self.parameter_provider.device()
         device_type = device.class_name if liveobj_valid(device) else device_type
     return device_type
Пример #6
0
def assign_parameters(controls, parameters):
    for control, parameter in izip_longest(controls, parameters):
        if control:
            if not liveobj_valid(parameter) or isinstance(parameter.canonical_parent, Live.MixerDevice.MixerDevice):
                control.mapped_parameter = parameter
            else:
                track = find_parent_track(parameter)
                control.mapped_parameter = parameter if liveobj_valid(track) and not track.is_frozen else None
Пример #7
0
def clip_name_from_clip_slot(clip_slot):
    clip_name = '[none]'
    if liveobj_valid(clip_slot):
        clip = clip_slot.clip
        clip_name = '[empty slot]'
        if liveobj_valid(clip):
            clip_name = get_clip_name(clip)
    return clip_name
Пример #8
0
 def _chain_color_for_pad(self, pad, color):
     if color == 'DrumGroup.PadFilled':
         raise pad.chains and liveobj_valid(pad.chains[0]) or AssertionError('Filled pads should have a chain')
         color = IndexedColor.from_live_index(pad.chains[0].color_index)
     elif color == 'DrumGroup.PadMuted':
         raise pad.chains and liveobj_valid(pad.chains[0]) or AssertionError('Filled pads should have a chain')
         color = IndexedColor.from_live_index(pad.chains[0].color_index, shade_level=1)
     return color
Пример #9
0
	def selected_note(self):
		selected_drum_pad = self._drum_group_device.view.selected_drum_pad if liveobj_valid(self._drum_group_device) else None
		if liveobj_valid(selected_drum_pad):
			debug('selected note:', selected_drum_pad.note)
			return selected_drum_pad.note
		else:
			debug('selected note:', self._selected_note)
			return int(self._selected_note)
Пример #10
0
def find_instrument_meeting_requirement(requirement, track_or_chain):
    if liveobj_valid(track_or_chain):
        instrument = find_if(lambda d: d.type == Live.Device.DeviceType.instrument, track_or_chain.devices)
        if liveobj_valid(instrument):
            if requirement(instrument):
                return instrument
            if instrument.can_have_chains:
                recursive_call = partial(find_instrument_meeting_requirement, requirement)
                return find_if(bool, imap(recursive_call, instrument.chains))
 def __on_selected_drum_pad_changed(self):
     self._disable_and_check_enabled_state()
     drum_rack_view = self.__on_selected_drum_pad_changed.subject
     if liveobj_valid(drum_rack_view):
         selected_drum_pad = drum_rack_view.selected_drum_pad
         first_chain_or_none = None
         if liveobj_valid(selected_drum_pad):
             first_chain_or_none = selected_drum_pad.chains[0] if len(selected_drum_pad.chains) > 0 else None
         self.__on_drum_pad_chain_devices_changed.subject = first_chain_or_none
 def _update_button_state_colors(self):
     song = self.song
     selected_track = self._provider.selected_item
     if selected_track != song.master_track:
         self.mute_track_button.color = self._get_track_state_mode_state(
             "mute", selected_track.mute if liveobj_valid(selected_track) else False, "Mixer.MuteOff"
         )
         self.solo_track_button.color = self._get_track_state_mode_state(
             "solo", selected_track.solo if liveobj_valid(selected_track) else False, "Mixer.SoloOn"
         )
Пример #13
0
 def _on_matrix_pressed(self, button):
     if self.select_color_button.is_pressed and self._color_chooser is not None:
         pad = self._pad_for_button(button)
         if liveobj_valid(pad) and pad.chains and liveobj_valid(pad.chains[0]):
             self._color_chooser.object = DrumPadColorAdapter(pad)
         else:
             self.show_notification('Cannot color an empty drum pad')
     else:
         super(DrumGroupComponent, self)._on_matrix_pressed(button)
     self.notify_mute_solo_stop_cancel_action_performed()
def select_clip_and_get_name_from_slot(clip_slot, song):
    clip_name = '[none]'
    if liveobj_valid(clip_slot):
        if song.view.highlighted_clip_slot != clip_slot:
            song.view.highlighted_clip_slot = clip_slot
        clip = clip_slot.clip
        clip_name = '[empty slot]'
        if liveobj_valid(clip):
            clip_name = clip.name if clip.name != '' else '[unnamed]'
    return clip_name
Пример #15
0
	def _arming_select_value(self, value):
		if value and self.song.view.selected_track == self._track:
			self._do_toggle_arm(exclusive=self.song.exclusive_arm)
		else:
			if liveobj_valid(self._track) and self.song.view.selected_track != self._track:
				self.song.view.selected_track = self._track
		if value and liveobj_valid(self._track) and self._track.is_foldable and self._arming_select_button and self._arming_select_button.is_momentary():
			self._fold_task.restart()
		else:
			self._fold_task.kill()
Пример #16
0
 def _on_matrix_pressed(self, button):
     if liveobj_valid(self._simpler) and liveobj_valid(self._simpler.sample):
         slice_index = self._button_coordinate_to_slice_index(button)
         if self.delete_button.is_pressed:
             if not self._try_delete_notes_for_slice(slice_index):
                 self._try_delete_slice_at_index(slice_index)
         elif self.quantize_button.is_pressed:
             self._try_quantize_notes_for_slice(slice_index)
         elif self.select_button.is_pressed:
             self._try_select_slice_at_index(slice_index)
     super(SlicedSimplerComponent, self)._on_matrix_pressed(button)
Пример #17
0
def find_instrument_devices(track_or_chain):
    """
    Returns a list with all instruments from a track or chain.
    """
    if liveobj_valid(track_or_chain):
        instrument = find_if(lambda d: d.type == Live.Device.DeviceType.instrument, track_or_chain.devices)
        if liveobj_valid(instrument):
            if not instrument.can_have_drum_pads and instrument.can_have_chains:
                return chain([instrument], *imap(find_instrument_devices, instrument.chains))
            return [instrument]
    return []
Пример #18
0
 def _sensitivity(self, sensitivity_key, parameter):
     device = self.device()
     sensitivity = parameter_sensitivities(device.class_name, parameter)[sensitivity_key]
     if liveobj_valid(parameter) and is_simpler(device) and liveobj_valid(device.sample):
         if parameter.name in self.ZOOM_SENSITIVE_PARAMETERS:
             if device.waveform_navigation is not None:
                 sensitivity *= device.waveform_navigation.visible_proportion
         if parameter.name in self.PARAMETERS_RELATIVE_TO_ACTIVE_AREA:
             active_area_quotient = device.sample.length / float(device.sample.end_marker - device.sample.start_marker + 1)
             sensitivity *= active_area_quotient
     return sensitivity
Пример #19
0
 def set_simpler(self, simpler):
     self._simpler = simpler
     self.__on_selected_slice_changed.subject = simpler
     self.__on_file_changed.subject = simpler
     self.__on_slices_changed.subject = simpler.sample if liveobj_valid(simpler) else None
     self.__on_pad_slicing_changed.subject = simpler
     self.__on_slicing_style_changed.subject = simpler.sample if liveobj_valid(simpler) else None
     self.__on_track_color_changed.subject = self.song.view.selected_track if simpler else None
     self._update_led_feedback()
     self.update()
     self.notify_selected_target_note()
Пример #20
0
 def _color_for_button(self, button_index, is_selected):
     item = self.items[button_index]
     device_or_pad = item.item
     is_active = liveobj_valid(device_or_pad) and is_active_element(device_or_pad)
     chain = find_chain_or_track(device_or_pad)
     if not is_active:
         return 'DefaultButton.Off'
     elif is_selected:
         return 'ItemNavigation.ItemSelected'
     elif liveobj_valid(chain):
         return IndexedColor.from_live_index(chain.color_index, DISPLAY_BUTTON_SHADE_LEVEL)
     else:
         return 'ItemNavigation.ItemNotSelected'
 def _get_zoom_start_fudge(self):
     if liveobj_valid(self._parameter_host) and liveobj_valid(self._parameter_host.sample):
         sample_length = self._parameter_host.sample.length
         fudge_length_a = 200000
         fudge_factor_a = 0.4
         fudge_length_b = 2500000
         fudge_factor_b = 0.2
         if sample_length < fudge_length_a:
             return fudge_factor_a
         if sample_length > fudge_length_b:
             return fudge_factor_b
         return (sample_length - fudge_length_a) / (fudge_length_b - fudge_length_a) * (fudge_factor_b - fudge_factor_a) + fudge_factor_a
     else:
         return self.DEFAULT_ZOOM_START_FUDGE
Пример #22
0
	def _update_led_feedback(self):
		if liveobj_valid(self._drum_group_device):
			super(MonoDrumGroupComponent, self)._update_led_feedback()
		else:
			super(DrumGroupComponent, self)._update_led_feedback()
		for button in self.select_matrix:
			self._update_button_color(button)
 def _on_reselecting_object(self, device):
     if liveobj_valid(device) and device.can_have_chains:
         if not device.can_have_drum_pads:
             self._toggle(device)
     else:
         self._bank_selection.set_device(device)
         self._modes.selected_mode = 'bank_selection'
Пример #24
0
 def _on_launch_button_pressed(self):
     if self.select_color_button.is_pressed and self._color_chooser is not None:
         clip = self._clip_slot.clip if self.has_clip() else None
         if liveobj_valid(clip):
             self._color_chooser.object = ClipProxy(clip)
     else:
         super(ClipSlotComponent, self)._on_launch_button_pressed()
 def _get_value(self):
     try:
         if liveobj_valid(self._property_host):
             return self._from_internal(self._get_property_value(), self._property_host)
         return self.min
     except RuntimeError:
         return self.min
 def _update_control_element(self):
     if liveobj_valid(self.mapped_parameter):
         self._control_element.connect_to(self.mapped_parameter)
     else:
         self._control_element.release_parameter()
     self._update_control_sensitivity()
     self._quantized_stepper.reset()
	def _update_generic_new_button(self, new_button):
		if new_button and self.is_enabled():
			song = self.song
			selected_track = song.view.selected_track
			clip_slot = song.view.highlighted_clip_slot
			can_new = liveobj_valid(clip_slot) and clip_slot.clip or selected_track.can_be_armed and selected_track.playing_slot_index >= 0
			new_button.set_light('Recorder.NewOn' if can_new else 'Recorder.NewOff')
 def _on_matrix_pressed(self, button):
     has_levels = liveobj_valid(self.velocity_levels)
     levels = self.velocity_levels.levels if has_levels else []
     index = self._button_index(button)
     self._played_level = levels[index] if index < len(levels) else INVALID_LEVEL
     self._update_led_feedback()
     self.notify_velocity()
 def _set_value(self, new_value):
     raise self.min <= new_value <= self.max or AssertionError('Invalid value %f' % new_value)
     if liveobj_valid(self._property_host):
         try:
             setattr(self._property_host, self._source_property, self._to_internal(new_value, self._property_host))
         except RuntimeError:
             pass
 def set_device(self, device):
     self._simpler = device if is_simpler(device) else None
     self.__on_selected_slice_changed.subject = self._simpler
     with self._updating_nudge_parameter():
         self._nudge_parameter = find_if(
             lambda p: p.name == "Nudge", self._simpler.parameters if liveobj_valid(self._simpler) else []
         )
 def get_simpler_flag(name):
     return liveobj_valid(self._live_object) and getattr(
         self._live_object, name)
 def call_simpler_function(name, *a):
     if liveobj_valid(self._live_object):
         return getattr(self._live_object, name)(*a)
Пример #33
0
 def gain(self):
     if liveobj_valid(self.clip):
         return self._audio_clip_model.gain
     return 0.0
Пример #34
0
 def _in_multisample_mode(self):
     return liveobj_valid(self._decorated_device
                          ) and self._decorated_device.multi_sample_mode
Пример #35
0
 def _update_real_time_channel(self, channel_name):
     if liveobj_valid(self._decorated_device):
         rt_data = getattr(self, '_%s_real_time_data' % channel_name)
         setattr(self._decorated_device,
                 channel_name + '_real_time_channel_id', rt_data.channel_id)
Пример #36
0
 def gain(self):
     if liveobj_valid(self._adaptee) and liveobj_valid(
             self._adaptee.sample):
         return self._adaptee.sample.gain
     return 0.0
Пример #37
0
 def warping(self):
     if liveobj_valid(self._adaptee) and liveobj_valid(
             self._adaptee.sample):
         return self._adaptee.sample.warping
     return False
Пример #38
0
 def rack_color_index(self):
     if liveobj_valid(self._rack_chain):
         return convert_color_index(self._rack_chain.color_index)
     return -1
Пример #39
0
 def zoom(self):
     if liveobj_valid(self.clip):
         return getattr(self.clip, 'zoom', None)
     return
Пример #40
0
 def _parameter_released(self, parameter):
     if liveobj_valid(self._decorated_device) and liveobj_valid(parameter):
         self._decorated_device.zoom.release_object(parameter)
     self._update_visualisation_view_data(self._visualisation_data())
Пример #41
0
 def _focus_grid_window(self):
     if liveobj_valid(
             self.clip) and self.get_static_view_data()['ShowGridWindow']:
         self.clip.timeline_navigation.change_object(self.grid_window_focus)
Пример #42
0
 def sample_available():
     return liveobj_valid(self._live_object) and liveobj_valid(
         self._live_object.sample)
Пример #43
0
 def selected_envelope_type(self):
     if liveobj_valid(self._decorated_device):
         return self._decorated_device.envelope_type_index
     return 0
Пример #44
0
 def crop_button(self, button):
     if liveobj_valid(self.clip):
         self.clip.crop()
Пример #45
0
 def _update_selected_mode(self, clip):
     if liveobj_valid(clip):
         self._mode_selector.selected_mode = 'audio' if clip.is_audio_clip else 'midi'
     else:
         self._mode_selector.selected_mode = 'no_clip'
Пример #46
0
 def _is_parameter_available(self, parameter):
     name = parameter.name if liveobj_valid(parameter) else ''
     return not self._in_multisample_mode(
     ) or name not in self.ZOOM_SENSITIVE_PARAMETERS + (u'Zoom', )
Пример #47
0
 def _update_scene_name_display(self):
     scene = self._scene
     self.scene_name_display[0] = scene.name if liveobj_valid(
         scene) else b''
Пример #48
0
 def audio_parameters(self):
     if liveobj_valid(self.clip):
         return self._audio_clip_parameters
     return []
Пример #49
0
 def _should_be_decorated(cls, device):
     return liveobj_valid(
         device) and device.class_name in cls.DECORATOR_CLASSES
Пример #50
0
 def _update_recording_state(self):
     clip = self._loop_model.clip
     if liveobj_valid(clip):
         recording = clip.is_recording and not clip.is_overdubbing
         self._looping_settings[1].recording = recording
         self._non_looping_settings[1].recording = recording
Пример #51
0
 def _update_loop_button(self):
     self.loop_button.enabled = liveobj_valid(self.clip)
     if liveobj_valid(self.clip):
         self.loop_button.is_toggled = self._loop_model.looping
Пример #52
0
 def warping(self):
     if liveobj_valid(self.clip):
         return self._audio_clip_model.warping
     return False
Пример #53
0
 def is_valid(self):
     return liveobj_valid(self._adaptee)
 def __on_last_played_level(self):
     if self._takeover_pads or liveobj_valid(self.velocity_levels):
         played = self.velocity_levels.last_played_level if 1 else INVALID_LEVEL
         self._played_level = played
         self._update_led_feedback()
         self._notification_task.restart()
Пример #55
0
 def slicing_sensitivity(self):
     if liveobj_valid(self._adaptee) and liveobj_valid(
             self._adaptee.sample):
         return self._adaptee.sample.slicing_sensitivity
     return 0.0
Пример #56
0
 def timeline_navigation(self):
     if liveobj_valid(self.clip):
         return getattr(self.clip, 'timeline_navigation', None)
     return
Пример #57
0
 def end_marker(self):
     if liveobj_valid(self._adaptee) and liveobj_valid(
             self._adaptee.sample):
         return self._adaptee.sample.end_marker
     return 0
Пример #58
0
def _get_parameter_by_name(device, name):
    parameters = device.parameters if liveobj_valid(device) else []
    return find_if(lambda x: x.name == name, parameters)
Пример #59
0
def has_monitoring_state(track):
    return liveobj_valid(track) and track.can_be_armed
Пример #60
0
 def __init__(self, adaptee=None, *a, **k):
     assert liveobj_valid(adaptee)
     super(ModelAdapter, self).__init__(*a, **k)
     self._adaptee = adaptee