-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMDChannelStripComponent.py
More file actions
executable file
·123 lines (109 loc) · 4.85 KB
/
CMDChannelStripComponent.py
File metadata and controls
executable file
·123 lines (109 loc) · 4.85 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import Live
from _Framework.ChannelStripComponent import ChannelStripComponent
from _Framework.DeviceComponent import DeviceComponent
class CMDChannelStripComponent(ChannelStripComponent):
""" Class extending CSC to have two buttons for toggling crossfader assign"""
_active_instances = []
@staticmethod
def set_log(func):
CMDChannelStripComponent.log_message = func
def update(self):
self._set_device_parameters()
CMDChannelStripComponent.log_message("UPDATE Channel strip!!")
super(CMDChannelStripComponent, self).update()
def __init__(self):
ChannelStripComponent.__init__(self)
self._first_device = DeviceComponent()
self._assign_a = None
self._assign_b = None
self._device_button1 = None
self._device_button2 = None
self._device_button3 = None
self._device_button4 = None
def set_assign_buttons(self, button1, button2):
if button1 != self._assign_a:
if self._assign_a is not None:
self._assign_a.remove_value_listener(self._assign_a_value)
self._assign_a.reset()
self._assign_a = button1
self._assign_a != None and self._assign_a.add_value_listener(self._assign_a_value)
if button2 != self._assign_b:
if self._assign_b is not None:
self._assign_b.remove_value_listener(self._assign_b_value)
self._assign_b.reset()
self._assign_b = button2
self._assign_b != None and self._assign_b.add_value_listener(self._assign_b_value)
self.update()
def set_device_buttons(self, button1, button2, button3, button4):
self._device_button1 = button1
self._device_button2 = button2
self._device_button3 = button3
self._device_button4 = button4
self._set_device_parameters()
self._track.add_devices_listener(self._on_change_devices)
def _set_device_parameters(self):
if self._track is not None and len(self._track.devices) > 0:
self._first_device.set_device(self._track.devices[0])
self._first_device.set_parameter_controls(
tuple([self._device_button1, self._device_button2, self._device_button3, self._device_button4]))
else:
self._first_device.set_device(None)
def _on_change_devices(self):
CMDChannelStripComponent.log_message("DEVICE changed")
self._set_device_parameters()
def _assign_a_value(self, value):
if value > 0:
if self._track.mixer_device.crossfade_assign == 0:
self._track.mixer_device.crossfade_assign = 1
self._assign_a.turn_off()
self._assign_b.turn_off()
else:
self._track.mixer_device.crossfade_assign = 0
self._assign_a.turn_on()
self._assign_b.turn_off()
if not self._assign_a is not None:
raise AssertionError
if not isinstance(value, int):
raise AssertionError
if self.is_enabled():
pass
def _assign_b_value(self, value):
if value > 0:
if self._track.mixer_device.crossfade_assign == 2:
self._track.mixer_device.crossfade_assign = 1
self._assign_a.turn_off()
self._assign_b.turn_off()
else:
self._track.mixer_device.crossfade_assign = 2
self._assign_b.turn_on()
self._assign_a.turn_off()
if not self._assign_b is not None:
raise AssertionError
if not isinstance(value, int):
raise AssertionError
if self.is_enabled():
pass
def _on_cf_assign_changed(self):
if self._track is not None and self._track != self.song().master_track and self._assign_a != None and self._assign_b != None:
if self._track.mixer_device.crossfade_assign == 2:
self._assign_a.turn_off()
self._assign_b.turn_on()
elif self._track.mixer_device.crossfade_assign == 1:
self._assign_b.turn_off()
self._assign_a.turn_off()
else:
self._assign_a.turn_on()
self._assign_b.turn_off()
elif self._assign_a is not None and self._assign_b is not None:
self._assign_b.turn_off()
self._assign_a.turn_off()
def disconnect(self):
if self._assign_a is not None:
self._assign_a.remove_value_listener(self._assign_a_value)
self._assign_a.reset()
self._assign_a = None
if self._assign_b is not None:
self._assign_b.remove_value_listener(self._assign_b_value)
self._assign_b.reset()
self._assign_b = None
super(CMDChannelStripComponent, self).update()