Exemplo n.º 1
0
	def _note_translation_for_button(self, button):
		if liveobj_valid(self._drum_group_device):
			identifier = None
			channel = None
			if self.has_assigned_pads:
				identifier = self._button_coordinates_to_pad_index(first(self._assigned_drum_pads).note, button.coordinate)
				channel = self._translation_channel
			return (identifier, channel)
		else:
			identifier = self._button_coordinates_to_pad_index(self._raw_position*4, button.coordinate)
			channel = self._translation_channel
			return (identifier, channel)
Exemplo n.º 2
0
	def _note_translation_for_button(self, button):
		if liveobj_valid(self._drum_group_device):
			identifier = None
			channel = None
			if self.has_assigned_pads:
				identifier = self._button_coordinates_to_pad_index(first(self._assigned_drum_pads).note, button.coordinate)
				channel = self._translation_channel
			return (identifier, channel)
		else:
			identifier = self._button_coordinates_to_pad_index(self._raw_position*4, button.coordinate)
			channel = self._translation_channel
			return (identifier, channel)
    def _get_time_range(self, step):
        def note_compare(left, right):
            return note_start_time(left) - note_start_time(right)

        time = self.get_step_start_time(step)
        notes = self._time_step(time).filter_notes(self._clip_notes)
        if notes:
            beginning_note = first(sorted(notes, key=cmp_to_key(note_compare)))
            start = note_start_time(beginning_note)
            end = start + note_length(beginning_note)
            if len(notes) > 1:
                end_note = notes[-1]
                end = note_start_time(end_note) + note_length(end_note)
            return (start, end)
        return (time, time + self._get_step_length())
Exemplo n.º 4
0
    def _get_time_range(self, step):
        def note_compare(left, right):
            return left.start_time - right.start_time

        time = self.get_step_start_time(step)
        notes = self._time_step(time).filter_notes(self._clip_notes)
        if notes:
            beginning_note = first(
                sorted(notes, key=(cmp_to_key(note_compare))))
            start = beginning_note.start_time
            end = start + beginning_note.duration
            if len(notes) > 1:
                end_note = notes[(-1)]
                end = end_note.start_time + end_note.duration
            return (start, end)
        return (time, time + self._get_step_length())
    def _update_listeners(self):

        def get_rack_views(racks):
            return map(lambda x: first(x).view, racks)

        racks = filter(lambda x: getattr(first(x), 'can_have_chains', False), self._devices)
        rack_views = get_rack_views(racks)
        device_parents = chain(imap(lambda x: x.selected_chain, rack_views), [self._device_parent])

        def is_empty_pad_drum_rack(item):
            rack = first(item)
            return rack.can_have_drum_pads and rack.view.selected_drum_pad and len(rack.view.selected_drum_pad.chains) == 0

        empty_pad_drum_rack_views = get_rack_views(ifilter(is_empty_pad_drum_rack, racks))
        self._devices_changed.replace_subjects(device_parents)
        self._selected_chain_changed.replace_subjects(rack_views)
        self._collapsed_state_changed.replace_subjects(rack_views)
        self._chain_devices_visibility_changed.replace_subjects(rack_views)
        self._selected_pad_changed.replace_subjects(empty_pad_drum_rack_views)
Exemplo n.º 6
0
    def _update_listeners(self):
        def get_rack_views(racks):
            return map(lambda x: first(x).view, racks)

        racks = filter(lambda x: getattr(first(x), u'can_have_chains', False),
                       self._devices)
        rack_views = get_rack_views(racks)
        device_parents = chain(imap(lambda x: x.selected_chain, rack_views),
                               [self._device_parent])

        def is_empty_pad_drum_rack(item):
            rack = first(item)
            return rack.can_have_drum_pads and rack.view.selected_drum_pad and len(
                rack.view.selected_drum_pad.chains) == 0

        empty_pad_drum_rack_views = get_rack_views(
            ifilter(is_empty_pad_drum_rack, racks))
        self._devices_changed.replace_subjects(device_parents)
        self._selected_chain_changed.replace_subjects(rack_views)
        self._collapsed_state_changed.replace_subjects(rack_views)
        self._chain_devices_visibility_changed.replace_subjects(rack_views)
        self._selected_pad_changed.replace_subjects(empty_pad_drum_rack_views)
 def _first_device_on_pad(self, drum_pad):
     chain = drum_rack_for_pad(drum_pad).view.selected_chain
     if chain and chain.devices:
         return first(chain.devices)
 def is_empty_pad_drum_rack(item):
     rack = first(item)
     return rack.can_have_drum_pads and rack.view.selected_drum_pad and len(rack.view.selected_drum_pad.chains) == 0
 def get_rack_views(racks):
     return map(lambda x: first(x).view, racks)
Exemplo n.º 10
0
 def _first_device_on_pad(self, drum_pad):
     chain = drum_rack_for_pad(drum_pad).view.selected_chain
     if chain and chain.devices:
         return first(chain.devices)
     else:
         return None
Exemplo n.º 11
0
 def is_empty_pad_drum_rack(item):
     rack = first(item)
     return rack.can_have_drum_pads and rack.view.selected_drum_pad and len(
         rack.view.selected_drum_pad.chains) == 0
Exemplo n.º 12
0
 def get_rack_views(racks):
     return map(lambda x: first(x).view, racks)