-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSpecialSessionComponent.py
60 lines (44 loc) · 1.97 KB
/
SpecialSessionComponent.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
48
49
50
51
52
53
54
55
56
57
58
59
60
# emacs-mode: -*- python-*-
# -*- coding: utf-8 -*-
import Live
from _Framework.SessionComponent import SessionComponent
from _Framework.ButtonElement import ButtonElement
class SpecialSessionComponent(SessionComponent):
" Special SessionComponent for APC combination mode and button to fire selected clip slot "
__module__ = __name__
def __init__(self, num_tracks, num_scenes):
SessionComponent.__init__(self, num_tracks, num_scenes)
self._slot_launch_button = None
def disconnect(self):
SessionComponent.disconnect(self)
if (self._slot_launch_button != None):
self._slot_launch_button.remove_value_listener(self._slot_launch_value)
self._slot_launch_button = None
def link_with_track_offset(self, track_offset, scene_offset):
assert (track_offset >= 0)
assert (scene_offset >= 0)
if self._is_linked():
self._unlink()
self.set_offsets(track_offset, scene_offset)
self._link()
def unlink(self):
if self._is_linked():
self._unlink()
def set_slot_launch_button(self, button):
assert ((button == None) or isinstance(button, ButtonElement))
if (self._slot_launch_button != button):
if (self._slot_launch_button != None):
self._slot_launch_button.remove_value_listener(self._slot_launch_value)
self._slot_launch_button = button
if (self._slot_launch_button != None):
self._slot_launch_button.add_value_listener(self._slot_launch_value)
self.update()
def _slot_launch_value(self, value):
assert (value in range(128))
assert (self._slot_launch_button != None)
if self.is_enabled():
if ((value != 0) or (not self._slot_launch_button.is_momentary())):
if (self.song().view.highlighted_clip_slot != None):
self.song().view.highlighted_clip_slot.fire()
# local variables:
# tab-width: 4