-
Notifications
You must be signed in to change notification settings - Fork 0
/
1_utility_functions.ino
39 lines (34 loc) · 1.09 KB
/
1_utility_functions.ino
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
// utility functions
// MIDI au Pair
// by Tom Hoffman
void changePreset(byte side, int value) {
if ((pad_buttons[side].preset == 0) && (value == -1)) {
pad_buttons[side].preset = (preset_count - 1);
}
else {
pad_buttons[side].preset = (pad_buttons[side].preset + value) % preset_count;
}
display_buffer[side * 2] = presets[pad_buttons[side].preset].id;
writeDisplay();
}
void changeOscillator(byte side, int value) {
if ((pad_buttons[side].oscillator == 0) && (value == -1)) {
pad_buttons[side].oscillator = (oscillator_count - 1);
}
else {
pad_buttons[side].oscillator = (pad_buttons[side].oscillator + value) % oscillator_count;
}
display_buffer[(side * 2) + 1] = oscillators[pad_buttons[side].oscillator];
writeDisplay();
}
bool isNotEmptyPatch(Patch p) {
return (p.controller != 0);
}
int scaleCC(byte value, byte toe_down, byte toe_up) {
// FIXME -> doesn't work right with reversed range 127 - 0 (only?)
int range = toe_up - toe_down;
float factor = range * TOETH;
float scaled ((factor * value) + toe_down);
int scaled_int = scaled;
return scaled_int;
}