-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpecialMixerComponent.py
147 lines (121 loc) · 6.36 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
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Embedded file name: /Users/versonator/Jenkins/live/output/mac_64_static/Release/python-bundle/MIDI Remote Scripts/Launchpad_Pro/SpecialMixerComponent.py
# Compiled at: 2018-04-23 20:27:04
from __future__ import absolute_import, print_function, unicode_literals
from functools import partial
from itertools import izip_longest
from _Framework.Util import clamp
from _Framework.Dependency import depends
from _Framework.MixerComponent import MixerComponent
from _Framework.ChannelStripComponent import ChannelStripComponent
from _Framework.Control import RadioButtonControl, RadioButtonGroup, ControlList
from .consts import FADER_TYPE_STANDARD, FADER_TYPE_BIPOLAR, VOLUME_MAP_CHANNEL, PAN_MAP_CHANNEL, SENDS_MAP_CHANNEL, FADER_LAYOUT_SYSEX_BYTE
SEND_COLORS = (
(u'Sends.A', u'Sends.AAvail'),
(u'Sends.B', u'Sends.BAvail'),
(u'Sends.C', u'Sends.CAvail'),
(u'Sends.D', u'Sends.DAvail'),
(u'Sends.E', u'Sends.EAvail'),
(u'Sends.F', u'Sends.FAvail'),
(u'Sends.G', u'Sends.GAvail'),
(u'Sends.H', u'Sends.HAvail'))
class SpecialRadioButtonGroup(ControlList, RadioButtonControl):
class State(RadioButtonGroup.State):
def _make_control(self, index):
control = self._control_type(checked_color=SEND_COLORS[index][0], unchecked_color=SEND_COLORS[index][1])
control._event_listeners = self._event_listeners
control._get_state(self._manager).index = index
control_state = control._get_state(self._manager)
control_state._on_checked = partial(self._on_checked, control_state)
control_state.is_checked = index == self._checked_index
return control
def __init__(self, *a, **k):
super(SpecialRadioButtonGroup, self).__init__(RadioButtonControl, *a, **k)
class SpecialMixerComponent(MixerComponent):
send_select_buttons = SpecialRadioButtonGroup()
@depends(layout_setup=None)
def __init__(self, num_tracks=0, num_returns=0, auto_name=False, invert_mute_feedback=False, layout_setup=None, *a, **k):
self._layout_setup = layout_setup
super(SpecialMixerComponent, self).__init__(num_tracks, num_returns, auto_name, invert_mute_feedback, *a, **k)
self.on_num_sends_changed()
def _create_strip(self):
return SpecialChanStripComponent()
def set_volume_controls(self, controls):
for strip, control in izip_longest(self._channel_strips, controls or []):
if control:
control.set_channel(VOLUME_MAP_CHANNEL)
control.set_light_and_type('Mixer.Volume', FADER_TYPE_STANDARD)
strip.set_volume_control(control)
def set_pan_controls(self, controls):
for strip, control in izip_longest(self._channel_strips, controls or []):
if control:
control.set_channel(PAN_MAP_CHANNEL)
control.set_light_and_type('Mixer.Pan', FADER_TYPE_BIPOLAR)
strip.set_pan_control(control)
def set_send_controls(self, controls):
self._send_controls = controls
for strip, control in izip_longest(self._channel_strips, controls or []):
if self.send_index is None or self.send_index not in xrange(8):
strip.set_send_controls(None)
else:
if control:
control.set_channel(SENDS_MAP_CHANNEL)
control.set_light_and_type(SEND_COLORS[self.send_index][0], FADER_TYPE_STANDARD)
strip.set_send_controls((None, ) * self._send_index + (control,))
return
def set_arm_buttons(self, buttons):
for strip, button in izip_longest(self._channel_strips, buttons or []):
if button:
button.reset_state()
button.set_on_off_values('Mixer.ArmOn', 'Mixer.ArmOff')
strip.set_arm_button(button)
def set_solo_buttons(self, buttons):
for strip, button in izip_longest(self._channel_strips, buttons or []):
if button:
button.reset_state()
button.set_on_off_values('Mixer.SoloOn', 'Mixer.SoloOff')
strip.set_solo_button(button)
def set_mute_buttons(self, buttons):
for strip, button in izip_longest(self._channel_strips, buttons or []):
if button:
button.reset_state()
button.set_on_off_values('Mixer.MuteOff', 'Mixer.MuteOn')
strip.set_mute_button(button)
def set_track_select_buttons(self, buttons):
for strip, button in izip_longest(self._channel_strips, buttons or []):
if button:
button.reset_state()
button.set_on_off_values('Mixer.Selected', 'Mixer.Unselected')
strip.set_select_button(button)
@send_select_buttons.checked
def send_select_buttons(self, button):
self.send_index = button.index
def on_num_sends_changed(self):
self.send_select_buttons.control_count = clamp(self.num_sends, 0, 8)
def on_send_index_changed(self):
if self._layout_setup is not None and self._send_controls is not None:
self._layout_setup(FADER_LAYOUT_SYSEX_BYTE)
if self.send_index is None:
self.send_select_buttons.control_count = 0
else:
if self.send_index < self.send_select_buttons.control_count:
for slider in self._send_controls:
slider.set_light(SEND_COLORS[self.send_index][0])
self.send_select_buttons[self.send_index].is_checked = True
else:
for button in self.send_select_buttons:
button.is_checked = False
return
class SpecialChanStripComponent(ChannelStripComponent):
def __init__(self, *a, **k):
super(SpecialChanStripComponent, self).__init__(*a, **k)
self.empty_color = 'DefaultButton.Disabled'
def _arm_value(self, value):
super(SpecialChanStripComponent, self)._arm_value(value)
if self.is_enabled() and value and self._track and self._track.can_be_armed and self.song().view.selected_track != self._track:
self.song().view.selected_track = self._track
def _select_value(self, value):
super(SpecialChanStripComponent, self)._select_value(value)
if self.is_enabled() and value and self._track:
view = self.application().view
if view.is_view_visible('Detail') and not view.is_view_visible('Detail/DeviceChain'):
view.show_view('Detail/DeviceChain')