def _update_stop_scene_leds(self, index): scenes = self.song.scenes scene_index = index + self._session_ring.scene_offset if self.is_enabled( ) and self._stop_scene_clip_buttons is not None and index < len( self._stop_scene_clip_buttons): button = self._stop_scene_clip_buttons[index] if button is not None: value_to_send = None if scene_index < len( scenes) and scenes[scene_index].clip_slots: tracks = self._session_ring.tracks_to_use() if find_if( lambda x: x.playing_slot_index == scene_index and x .fired_slot_index != -2, tracks): value_to_send = self._stop_clip_value elif find_if( lambda x: x.fired_slot_index == -2 and x. playing_slot_index == scene_index, tracks): value_to_send = self._stop_clip_triggered_value else: value_to_send = u'Session.StoppedClip' if value_to_send is None: button.turn_off() elif in_range(value_to_send, 0, 128): button.send_value(value_to_send) else: button.set_light(value_to_send)
def find_drum_group_device(track_or_chain): u""" Looks up recursively for a drum_group device in the track. """ instrument = find_if(lambda d: d.type == Live.Device.DeviceType.instrument, track_or_chain.devices) if instrument: if instrument.can_have_drum_pads: return instrument if instrument.can_have_chains: return find_if(bool, imap(find_drum_group_device, instrument.chains))
def _update_stop_all_clips_button(self): button = self._stop_all_button if button: value_to_send = u'Session.StoppedClip' tracks = self._session_ring.tracks_to_use() if find_if( lambda x: x.playing_slot_index >= 0 and x.fired_slot_index != -2, tracks): value_to_send = self._stop_clip_value elif find_if(lambda x: x.fired_slot_index == -2, tracks): value_to_send = self._stop_clip_triggered_value if value_to_send is None: button.turn_off() else: button.set_light(value_to_send)
def _update_led_feedback(self): if self._drum_group_device: soloed_pads = find_if(lambda pad: pad.solo, self._all_drum_pads) for button in self.drum_matrix: pad = self._coordinate_to_pad_map.get(button.coordinate, None) if pad: self._update_pad_led(pad, button, soloed_pads)
def find_instrument_devices(track_or_chain): u""" Returns a list with all instrument rack descendants from a track or chain. """ instrument = find_if(lambda d: d.type == Live.Device.DeviceType.instrument, track_or_chain.devices) if instrument and not instrument.can_have_drum_pads and instrument.can_have_chains: return chain([instrument], *imap(find_instrument_devices, instrument.chains)) return []
def _get_scale_from_name(self, name): return find_if(lambda scale: scale.name == name, SCALES) or SCALES[0]