-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixer.py
71 lines (56 loc) · 2.38 KB
/
mixer.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
import typing
from itertools import zip_longest
from ableton.v3.base import depends
from ableton.v3.control_surface.components import MixerComponent as MixerComponentBase
from ableton.v3.control_surface.controls import ButtonControl
from .channel_strip import ChannelStripComponent
class MixerComponent(MixerComponentBase):
prev_send_button: typing.Any = ButtonControl(
color="DefaultButton.Off", pressed_color="DefaultButton.On"
)
next_send_button: typing.Any = ButtonControl(
color="DefaultButton.Off", pressed_color="DefaultButton.On"
)
@depends(show_message=None)
def __init__(
self,
*a,
channel_strip_component_type=ChannelStripComponent,
show_message: typing.Optional[typing.Callable[[str], typing.Any]] = None,
**k,
):
super().__init__(
*a, channel_strip_component_type=channel_strip_component_type, **k
)
assert show_message
self._show_message = show_message
self._clip_view_buttons = None
self._reset_send_buttons = None
def set_prev_send_button(self, button):
self.prev_send_button.set_control_element(button)
def set_next_send_button(self, button):
self.next_send_button.set_control_element(button)
def set_clip_view_buttons(self, buttons):
self._clip_view_buttons = buttons
for strip, button in zip_longest(self._channel_strips, buttons or []):
strip.clip_view_button.set_control_element(button)
strip.update()
def set_reset_send_buttons(self, buttons):
self._reset_send_buttons = buttons
for strip, button in zip_longest(self._channel_strips, buttons or []):
strip.reset_send_button.set_control_element(button)
strip.update()
@prev_send_button.pressed
def prev_send_button(self, _):
self._increment_send_index(-1)
@next_send_button.pressed
def next_send_button(self, _):
self._increment_send_index(1)
def _increment_send_index(self, amount: int):
if self._send_index_manager.num_sends > 0:
self._send_index_manager.send_index = (
self._send_index_manager.send_index + amount
) % self._send_index_manager.num_sends
def _on_send_index_changed(self):
self._show_message(f"Controlling Send {self.send_index+ 1}")
return super()._on_send_index_changed()