-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexfunctions.cpp
429 lines (377 loc) · 12.9 KB
/
exfunctions.cpp
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#include "exfunctions.h"
/// @defgroup ex EX Button Functions
/// These are the various functions that the EX buttons can be configured to run when pressed.
/// @note One EX button use isn't listed here: bringing up the pause screen.
/// @{
/// @brief Cycles through muting the melody strings.
/// @details
/// * Applies immediately if playing.
/// * Cycles through one or the other or no melody strings.
/// * Does not include an option to mute all melody strings (why have that?).
void cycle_mel_mute() {
if (mel_mode == 0) {
mel_mode = 1; // 1 == high on, low off
mystring->setMute(false);
mylowstring->setMute(true);
if (mylowstring->isPlaying()) {
mylowstring->soundOff();
mylowstring->soundOn();
};
} else if (mel_mode == 1) {
mel_mode = 2; // 2 == high off, low on
mystring->setMute(true);
mylowstring->setMute(false);
if (mystring->isPlaying()) {
mystring->soundOff();
mystring->soundOn();
mylowstring->soundOff();
mylowstring->soundOn();
};
} else if (mel_mode == 2) {
mel_mode = 3; // 3 == high off, low off
mystring->setMute(true);
mylowstring->setMute(true);
if (mystring->isPlaying()) {
mylowstring->soundOff();
mylowstring->soundOn();
};
} else if (mel_mode == 3) {
mel_mode = 0; // 0 == high on, low on
mystring->setMute(false);
mylowstring->setMute(false);
if (mystring->isPlaying()) {
mystring->soundOff();
mystring->soundOn();
mylowstring->soundOff();
mylowstring->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Cycles through muting the drone and trompette strings.
/// @details
/// * Applies immediately if playing.
/// * Cycles through all 4 mute/unmute possibilities between the two strings.
void cycle_drone_tromp_mute() {
if (drone_mode == 0) {
drone_mode = 1; // 1 == both off
mydrone->setMute(true);
mytromp->setMute(true);
mybuzz->setMute(true);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
mytromp->soundOff();
mytromp->soundOn();
};
} else if (drone_mode == 1) {
drone_mode = 2; // 2 == drone on, tromp off
mydrone->setMute(false);
mytromp->setMute(true);
mybuzz->setMute(true);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
};
} else if (drone_mode == 2) {
drone_mode = 3; // 3 == drone off, tromp on
mydrone->setMute(true);
mytromp->setMute(false);
mybuzz->setMute(false);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
mytromp->soundOff();
mytromp->soundOn();
};
} else if (drone_mode == 3) {
drone_mode = 0; // 0 == both on
mydrone->setMute(false);
mytromp->setMute(false);
mybuzz->setMute(false);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Toggles muting the drone string.
/// @details * Applies immediately if playing.
void cycle_drone_mute() {
if (drone_mode == 0 || drone_mode == 2) {
if (drone_mode == 0) {
drone_mode = 3;
} else {
drone_mode = 1;
};
mydrone->setMute(true);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
};
} else if (drone_mode == 1 || drone_mode == 3) {
if (drone_mode == 1) {
drone_mode = 2;
} else {
drone_mode = 0; // 0 = On
};
mydrone->setMute(false);
if (mydrone->isPlaying()) {
mydrone->soundOff();
mydrone->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Toggles muting the trompette string.
/// @details * Applies immediately if playing.
void cycle_tromp_mute() {
if (t_mode == 0) {
t_mode = 1;
mytromp->setMute(true);
mybuzz->setMute(true);
if (mytromp->isPlaying()) {
mytromp->soundOff();
mytromp->soundOn();
};
} else if (t_mode == 1) {
t_mode = 0;
mytromp->setMute(false);
mybuzz->setMute(false);
if (mytromp->isPlaying()) {
mytromp->soundOff();
mytromp->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Turns the volume down by 10 if possible on all strings.
/// @version *New in 2.3.3*
void turn_volume_down() {
vol_down();
};
/// @brief Turns the volume up by 10 if possible on all strings.
/// @version *New in 2.3.3*
void turn_volume_up() {
vol_up();
};
/// @brief Cycles the capo, and adjusts any playing notes.
/// @version *New in 2.3.7*
void ex_cycle_capo(bool playing) {
cycle_capo(playing);
};
/// @brief Increases the transpose by 1 semitone, and adjusts any playing notes.
/// @version *New in 2.3.7*
void ex_tpose_up(bool playing) {
tpose_up_1(playing);
};
/// @brief Decreases the transpose by 1 semitone, and adjusts any playing notes.
/// @version *New in 2.3.7*
void ex_tpose_down(bool playing) {
tpose_down_1(playing);
};
/// @brief Toggles the transpose up or down a number of steps
/// @param playing
/// @param toggled
/// @version *New in 2.5.7*
void ex_tpose_toggle(bool playing, int steps) {
if (tpose_offset != steps) {
tpose_up_x(playing, steps);
} else {
tpose_up_x(playing, 0);
};
};
/// @brief Cycles through the secondary audio output options
/// @version *New in 2.9.2*
void ex_sec_out_toggle() {
autocrank_toggle_on = false;
all_soundOff();
delay(5);
all_clearVolArray();
int cur_mode = EEPROM.read(EEPROM_SEC_OUT);
if (cur_mode == 0) {
#ifndef ALLOW_COMBO_MODE
print_message_2("Secondary Output", "Un-plug any MIDI adapters!", "Press X to Continue");
bool done2= false;
while (!done2) {
delay(150);
myXButton->update();
if (myXButton->wasPressed()) {
done2 = true;
};
};
#endif
draw_xbm(progress[0]);
delay(100);
draw_xbm(progress[1]);
EEPROM.write(EEPROM_SEC_OUT, 1);
usb_power_on();
trigger_obj.start();
delay(100);
draw_xbm(progress[2]);
all_clearVolArray();
mystring->setOutputMode(1);
mylowstring->setOutputMode(1);
mytromp->setOutputMode(1);
mydrone->setOutputMode(1);
mykeyclick->setOutputMode(1);
mybuzz->setOutputMode(1);
draw_xbm(progress[3]);
mystring->setTrackLoops();
draw_xbm(progress[4]);
mylowstring->setTrackLoops();
draw_xbm(progress[5]);
mytromp->setTrackLoops();
draw_xbm(progress[6]);
mydrone->setTrackLoops();
draw_xbm(progress[7]);
mybuzz->setTrackLoops();
draw_xbm(progress[8]);
mykeyclick->setTrackLoops();
draw_xbm(progress[9]);
delay(400);
print_message_2("Secondary Output", "Completed! Audio Socket", "Saved to EEPROM!");
delay(1500);
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, 0, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
} else if (cur_mode == 1) {
#ifdef ALLOW_COMBO_MODE
draw_xbm(progress[0]);
delay(100);
draw_xbm(progress[1]);
EEPROM.write(EEPROM_SEC_OUT, 2);
usb_power_on();
MIDI.begin(MIDI_CHANNEL_OMNI);
trigger_obj.start();
delay(100);
draw_xbm(progress[2]);
all_clearVolArray();
mystring->setOutputMode(2);
mylowstring->setOutputMode(2);
mytromp->setOutputMode(2);
mydrone->setOutputMode(2);
mykeyclick->setOutputMode(2);
mybuzz->setOutputMode(2);
draw_xbm(progress[3]);
mystring->setTrackLoops();
draw_xbm(progress[4]);
mylowstring->setTrackLoops();
draw_xbm(progress[5]);
mytromp->setTrackLoops();
draw_xbm(progress[6]);
mydrone->setTrackLoops();
draw_xbm(progress[7]);
mybuzz->setTrackLoops();
draw_xbm(progress[8]);
mykeyclick->setTrackLoops();
draw_xbm(progress[9]);
delay(400);
print_message_2("Secondary Output", "MIDI-OUT + Audio", "Saved to EEPROM!");
delay(1500);
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, 0, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
} else if (cur_mode == 2) {
#endif
EEPROM.write(EEPROM_SEC_OUT, 0);
usb_power_off();
MIDI.begin(MIDI_CHANNEL_OMNI);
delay(100);
mystring->setOutputMode(0);
mylowstring->setOutputMode(0);
mytromp->setOutputMode(0);
mydrone->setOutputMode(0);
mykeyclick->setOutputMode(0);
mybuzz->setOutputMode(0);
print_message_2("Secondary Output", "MIDI-OUT", "Saved to EEPROM!");
delay(1500);
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, 0, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Toggles mute on the high melody string
/// @version *New in 2.9.8*
void ex_cycle_hi_mel_mute() {
if (h_mode == 0) {
h_mode = 1;
mystring->setMute(true);
if (mystring->isPlaying()) {
mystring->soundOff();
mystring->soundOn();
};
} else if (h_mode == 1) {
h_mode = 0;
mystring->setMute(false);
if (mystring->isPlaying()) {
mystring->soundOff();
mystring->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Toggles mute on the low melody string
/// @version *New in 2.9.8*
void ex_cycle_lo_mel_mute() {
if (l_mode == 0) {
l_mode = 1;
mylowstring->setMute(true);
if (mylowstring->isPlaying()) {
mylowstring->soundOff();
mylowstring->soundOn();
};
} else if (l_mode == 1) {
l_mode = 0;
mylowstring->setMute(false);
if (mylowstring->isPlaying()) {
mylowstring->soundOff();
mylowstring->soundOn();
};
};
if (mystring->isPlaying()) {
draw_play_screen(mystring->getOpenNote() + tpose_offset + myoffset, play_screen_type, false);
} else {
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, myoffset, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
};
/// @brief Loads the given preset slot
/// @param preset_slot 1-4, the slot to load
/// @version *New in 2.9.8*
void ex_load_preset(int preset_slot) {
autocrank_toggle_on = false;
all_soundOff();
delay(5);
load_preset_tunings(preset_slot);
print_message_2("Load Preset Tuning", String("Preset ") + preset_slot, "Loaded!");
delay(750);
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, 0, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
/// @brief Loads the given save slot
/// @param save_slot 1-4, the slot to load
/// @version *New in 2.9.8*
void ex_load_save_slot(int save_slot) {
autocrank_toggle_on = false;
all_soundOff();
delay(5);
load_saved_tunings(save_slot);
print_message_2("Load Saved Tuning", String("Save slot ") + save_slot, "Loaded!");
delay(750);
print_display(mystring->getOpenNote(), mylowstring->getOpenNote(), mydrone->getOpenNote(), mytromp->getOpenNote(), tpose_offset, capo_offset, 0, mystring->getMute(), mylowstring->getMute(), mydrone->getMute(), mytromp->getMute());
};
/// @}