コード例 #1
0
def get_chains_recursive(track_or_chain):
    instruments = list(find_instrument_devices(track_or_chain))
    chains = []
    if instruments and hasattr(instruments[0], b'chains'):
        for chain in instruments[0].chains:
            chains.append(chain)
            instruments = list(find_instrument_devices(chain))
            if instruments and hasattr(instruments[0], b'chains'):
                if instruments[0].is_showing_chains:
                    nested_chains = get_chains_recursive(chain)
                    chains.extend(nested_chains)

    return chains
コード例 #2
0
def get_racks_recursive(track_or_chain):
    instruments = list(find_instrument_devices(track_or_chain))
    racks = []
    if instruments and hasattr(instruments[0], b'chains'):
        racks.append(instruments[0])
        for chain in instruments[0].chains:
            instruments = list(find_instrument_devices(chain))
            if instruments and hasattr(instruments[0], b'chains'):
                if instruments[0].can_have_chains:
                    nested_racks = get_racks_recursive(chain)
                    racks.extend(nested_racks)

    return racks
コード例 #3
0
def possible_conversions(track, decorator_factory = None):
    category = NullConvertCategory()
    if liveobj_valid(track):
        if is_midi_track(track) and len(track.devices) > 0:
            drum_rack = find_drum_rack_instrument(track)
            if liveobj_valid(drum_rack):
                drum_pad = drum_rack.view.selected_drum_pad
                if liveobj_valid(drum_pad) and len(drum_pad.chains) == 1 and find_instrument_devices(drum_pad.chains[0]):
                    category = MidiTrackWithDrumRack(actions=[DrumPadToMidiTrack()], drum_pad=drum_pad, track=track)
            else:
                simpler = find_simpler(track)
                if simpler != None and simpler.playback_mode == Live.SimplerDevice.PlaybackMode.slicing:
                    category = MidiTrackWithSimpler(actions=[SlicesToDrumRack()], device=simpler, track=track)
                else:
                    category = MidiTrackWithoutSimpler(actions=[MoveDeviceChain()], device=simpler, track=track, decorator_factory=decorator_factory)
        elif is_audio_track(track):
            detail_clip = track.canonical_parent.view.detail_clip
            song = track.canonical_parent
            if liveobj_valid(detail_clip) and detail_clip.is_arrangement_clip:
                if not detail_clip.is_recording:
                    actions = [CreateTrackWithSimpler(), CreateTrackWithClipInDrumRackPad()]
                    if Live.Conversions.is_convertible_to_midi(song, detail_clip):
                        actions.extend([ConvertAudioClipToHarmonyMidi(), ConvertAudioClipToMelodyMidi(), ConvertAudioClipToDrumsMidi()])
                    category = AudioTrackWithArrangementClip(actions=actions, song_view=track.canonical_parent.view, track=track)
            else:
                highlighted_clip_slot = track.canonical_parent.view.highlighted_clip_slot
                clip_slot = find_if(lambda slot: slot.has_clip and highlighted_clip_slot == slot, track.clip_slots)
                if liveobj_valid(clip_slot) and not clip_slot.is_recording:
                    actions = [CreateTrackWithSimpler(), CreateTrackWithClipInDrumRackPad()]
                    if Live.Conversions.is_convertible_to_midi(song, clip_slot.clip):
                        actions.extend([ConvertAudioClipToHarmonyMidi(), ConvertAudioClipToMelodyMidi(), ConvertAudioClipToDrumsMidi()])
                    category = AudioTrackWithSessionClip(actions=actions, clip_slot=highlighted_clip_slot, track=track)
    return category
コード例 #4
0
 def _toggle_track_fold(self, track):
     if hasattr(track, 'is_foldable') and track.is_foldable:
         track.fold_state = not track.fold_state
     elif hasattr(track, 'is_showing_chains') and track.can_show_chains:
         track.is_showing_chains = not track.is_showing_chains
     else:
         instruments = list(find_instrument_devices(track))
         if instruments:
             instrument = instruments[0]
             if hasattr(instrument, 'is_showing_chains') and instrument.can_show_chains:
                 instrument.is_showing_chains = not instrument.is_showing_chains
コード例 #5
0
def find_simplers(chain):
    return ifilter(lambda i: hasattr(i, 'playback_mode'),
                   find_instrument_devices(chain))
コード例 #6
0
 def _update_listeners(self):
     devices = list(find_instrument_devices(self._track))
     racks = filter(lambda d: d.can_have_chains, devices)
     chains = list(chain([self._track], *[ d.chains for d in racks ]))
     self.__on_chains_changed.replace_subjects(racks)
     self.__on_devices_changed.replace_subjects(chains)
コード例 #7
0
 def _update_listeners(self):
     devices = list(find_instrument_devices(self._track))
     racks = [d for d in devices if d.can_have_chains]
     chains = list(chain([self._track], *[d.chains for d in racks]))
     self._FocusFollowComponent__on_chains_changed.replace_subjects(racks)
     self._FocusFollowComponent__on_devices_changed.replace_subjects(chains)
コード例 #8
0
def find_simplers(chain):
    return list(
        filter(lambda i: old_hasattr(i, u'playback_mode'),
               find_instrument_devices(chain)))