-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_component.py
47 lines (34 loc) · 2.02 KB
/
session_component.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Embedded file name: c:\Jenkins\live\output\win_64_static\Release\midi-remote-scripts\Push2\session_component.py
from itertools import imap
from pushbase.special_session_component import SpecialClipSlotComponent, SpecialSceneComponent, SpecialSessionComponent
from .clip_decoration import ClipDecoratedPropertiesCopier
from .colors import translate_color_index, WHITE_COLOR_INDEX_FROM_LIVE, WHITE_MIDI_VALUE
class ClipSlotComponent(SpecialClipSlotComponent):
_decorator_factory = None
def _color_value(self, slot_or_clip):
return WHITE_MIDI_VALUE if slot_or_clip.color_index == WHITE_COLOR_INDEX_FROM_LIVE else translate_color_index(slot_or_clip.color_index)
def _do_duplicate_clip(self):
def get_destination_clip(destination_slot_ix):
track = self._clip_slot.canonical_parent
return track.clip_slots[destination_slot_ix].clip
if self._clip_slot:
if not self._clip_slot.has_clip:
return
destination_slot_ix = super(ClipSlotComponent, self)._do_duplicate_clip()
destination_slot_ix is not None and self._decorator_factory and ClipDecoratedPropertiesCopier(target_clip=self._clip_slot.clip, destination_clip=get_destination_clip(destination_slot_ix), decorator_factory=self._decorator_factory).post_duplication_action()
return destination_slot_ix
def set_decorator_factory(self, factory):
self._decorator_factory = factory
class SceneComponent(SpecialSceneComponent):
clip_slot_component_type = ClipSlotComponent
def build_clip_slot_list(self):
scene_index = list(self.song.scenes).index(self._scene)
def slot_for_track(mixable):
if not hasattr(mixable, 'clip_slots') or len(mixable.clip_slots) == 0:
return None
else:
return mixable.clip_slots[scene_index]
return None
return imap(slot_for_track, self._session_ring.controlled_tracks())
class SessionComponent(SpecialSessionComponent):
scene_component_type = SceneComponent