-
Notifications
You must be signed in to change notification settings - Fork 8
/
PedaledSessionComponent.py
executable file
·39 lines (32 loc) · 1.67 KB
/
PedaledSessionComponent.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
# http://remotescripts.blogspot.com
# emacs-mode: -*- python-*-
# -*- coding: utf-8 -*-
import Live
from APCSessionComponent import APCSessionComponent
from _Framework.ButtonElement import ButtonElement
class PedaledSessionComponent(APCSessionComponent):
""" Special SessionComponent with a button (pedal) to fire the selected clip slot """
def __init__(self, num_tracks, num_scenes):
APCSessionComponent.__init__(self, num_tracks, num_scenes)
self._slot_launch_button = None
def disconnect(self):
APCSessionComponent.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 set_slot_launch_button(self, button):
if not (button == None or isinstance(button, ButtonElement)):
raise AssertionError
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
self._slot_launch_button != None and self._slot_launch_button.add_value_listener(self._slot_launch_value)
self.update()
def _slot_launch_value(self, value):
if not value in range(128):
raise AssertionError
if not self._slot_launch_button != None:
raise AssertionError
if self.is_enabled():
(value != 0 or not self._slot_launch_button.is_momentary()) and self.song().view.highlighted_clip_slot != None and self.song().view.highlighted_clip_slot.fire()