-
Notifications
You must be signed in to change notification settings - Fork 4
/
SpecialMixerComponent.py
78 lines (70 loc) · 3.22 KB
/
SpecialMixerComponent.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import Live
from _Framework.MixerComponent import MixerComponent
from DefChannelStripComponent import DefChannelStripComponent
from _Framework.ButtonElement import ButtonElement
class SpecialMixerComponent(MixerComponent):
""" Class encompassing several defaultable channel strips to form a mixer """
def __init__(self, num_tracks, num_returns = 0, with_eqs = False, with_filters = False):
MixerComponent.__init__(self, num_tracks, num_returns, with_eqs, with_filters)
self._unarm_all_button = None
self._unsolo_all_button = None
self._unmute_all_button = None
def disconnect(self):
if self._unarm_all_button != None:
self._unarm_all_button.remove_value_listener(self._unarm_all_value)
self._unarm_all_button = None
if self._unsolo_all_button != None:
self._unsolo_all_button.remove_value_listener(self._unsolo_all_value)
self._unsolo_all_button = None
if self._unmute_all_button != None:
self._unmute_all_button.remove_value_listener(self._unmute_all_value)
self._unmute_all_button = None
MixerComponent.disconnect(self)
def set_global_buttons(self, unarm_all, unsolo_all, unmute_all):
assert isinstance(unarm_all, (ButtonElement, type(None)))
assert isinstance(unsolo_all, (ButtonElement, type(None)))
assert isinstance(unmute_all, (ButtonElement, type(None)))
if (self._unarm_all_button != None):
self._unarm_all_button.remove_value_listener(self._unarm_all_value)
self._unarm_all_button = unarm_all
if (self._unarm_all_button != None):
self._unarm_all_button.add_value_listener(self._unarm_all_value)
self._unarm_all_button.turn_off()
if (self._unsolo_all_button != None):
self._unsolo_all_button.remove_value_listener(self._unsolo_all_value)
self._unsolo_all_button = unsolo_all
if (self._unsolo_all_button != None):
self._unsolo_all_button.add_value_listener(self._unsolo_all_value)
self._unsolo_all_button.turn_off()
if (self._unmute_all_button != None):
self._unmute_all_button.remove_value_listener(self._unmute_all_value)
self._unmute_all_button = unmute_all
if (self._unmute_all_button != None):
self._unmute_all_button.add_value_listener(self._unmute_all_value)
self._unmute_all_button.turn_off()
def _create_strip(self):
return DefChannelStripComponent()
def _unarm_all_value(self, value):
assert self.is_enabled()
assert (self._unarm_all_button != None)
assert (value in range(128))
if ((value != 0) or (not self._unarm_all_button.is_momentary())):
for track in self.song().tracks:
if track.can_be_armed and track.arm:
track.arm = False
def _unsolo_all_value(self, value):
assert self.is_enabled()
assert (self._unsolo_all_button != None)
assert (value in range(128))
if value != 0 or not self._unsolo_all_button.is_momentary():
for track in tuple(self.song().tracks) + tuple(self.song().return_tracks):
if track.solo:
track.solo = False
def _unmute_all_value(self, value):
assert self.is_enabled()
assert (self._unmute_all_button != None)
assert (value in range(128))
if value != 0 or not self._unmute_all_button.is_momentary():
for track in tuple(self.song().tracks) + tuple(self.song().return_tracks):
if track.mute:
track.mute = False