-
Notifications
You must be signed in to change notification settings - Fork 0
/
mappings.py
155 lines (143 loc) · 5.42 KB
/
mappings.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
148
149
150
151
152
153
154
155
import typing
from ableton.v3.base import depends
from ableton.v3.control_surface import ControlSurface
from ableton.v3.control_surface.mode import CallFunctionMode
from .configuration import Configuration
from .elements import NUM_TRACKS
SHIFT_BUTTON = "stop_button"
ALT_BUTTON = "play_button"
CTRL_BUTTON = "record_button"
@depends(configuration=None)
def create_mappings(
control_surface: ControlSurface, configuration: typing.Optional[Configuration]
):
assert configuration
mappings = {}
# Session navigation is always active.
mappings["Session_Navigation"] = dict(
up_button="rewind_button",
down_button="fast_forward_button",
left_button="track_left_button",
right_button="track_right_button",
)
mappings["Mixer"] = dict(
# Sliders always control track volume.
volume_controls="sliders",
)
# The common setup shared by default, shift, and alt modes.
#
# The raw object gets modified during mode creation, so we need to
# recreate the object whenever it's needed.
def sends_mode():
return dict(
component="Mixer",
send_controls="knobs",
next_send_button="marker_right_button",
prev_send_button="marker_left_button",
)
# A mode that just selects another mode. We use this to get a
# different button color when selecting e.g. SHIFT mode from
# DEFAULT mode versus SHIFT mode from ALT mode. Specifically, in
# DEFAULT mode, all mode buttons are lit, but in the other modes,
# only the back-to-DEFAULT button is lit.
def set_selected_mode_mode(target_mode_name):
def on_enter():
control_surface.component_map["Modes"].selected_mode = target_mode_name
return CallFunctionMode(on_enter_fn=on_enter)
mappings["Modes"] = dict(
initial=set_selected_mode_mode(configuration.initial_mode),
# Use wrapper modes to get a different button color when DEFAULT is active.
shift_from_default_button=SHIFT_BUTTON,
alt_from_default_button=ALT_BUTTON,
ctrl_from_default_button=CTRL_BUTTON,
default=dict(
modes=[
dict(
component="Session",
clip_launch_buttons="mixer_buttons",
),
sends_mode(),
]
),
shift_from_default=set_selected_mode_mode("shift"),
alt_from_default=set_selected_mode_mode("alt"),
ctrl_from_default=set_selected_mode_mode("ctrl"),
shift=dict(
modes=[
dict(
component="Mixer",
solo_buttons="solo_buttons",
mute_buttons="mute_buttons",
arm_buttons="arm_buttons",
),
dict(
component="Modes",
default_button=SHIFT_BUTTON,
alt_button=ALT_BUTTON,
ctrl_button=CTRL_BUTTON,
),
sends_mode(),
]
),
alt=dict(
modes=[
dict(
component="Session",
stop_track_clip_buttons="arm_buttons",
),
dict(
component="Mixer",
reset_send_buttons="solo_buttons",
track_select_buttons="mute_buttons",
),
dict(
component="Modes",
shift_button=SHIFT_BUTTON,
default_button=ALT_BUTTON,
ctrl_button=CTRL_BUTTON,
),
sends_mode(),
]
),
ctrl=dict(
modes=[
dict(
component="Device",
parameter_controls="knobs",
device_lock_button="marker_set_button",
device_on_off_button="cycle_button",
),
dict(
component="Device_Navigation",
prev_button="marker_left_button",
next_button="marker_right_button",
),
dict(component="Mixer", clip_view_buttons="solo_buttons"),
dict(
component="Transport",
stop_button=f"mixer_buttons_raw[{2 * NUM_TRACKS}]",
play_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 1}]",
clip_trigger_quantization_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 3}]",
tempo_down_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 4}]",
tempo_up_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 5}]",
metronome_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 6}]",
),
dict(
component="Recording",
arrangement_record_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 2}]",
),
dict(
component="Session",
scene_launch_buttons="scene_launch_buttons",
stop_all_clips_button=f"mixer_buttons_raw[{2 * NUM_TRACKS + 7}]",
),
dict(
component="Modes",
shift_button=SHIFT_BUTTON,
alt_button=ALT_BUTTON,
default_button=CTRL_BUTTON,
),
]
),
)
return mappings