-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobodesk_3.0.ino
More file actions
242 lines (202 loc) · 9.86 KB
/
Robodesk_3.0.ino
File metadata and controls
242 lines (202 loc) · 9.86 KB
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
#include <Encoder.h>
#include <MIDI_Controller.h>
//Midi controller library
#include <ResponsiveAnalogRead.h>
// analog smoothing
#include <Bounce.h>
// include the Bounce library for 'de-bouncing' switches -- removing electrical chatter as contacts settle
// usbMIDI.h library is added automatically when code is compiled as a MIDI device
using namespace ExtIO;
// use standard arduino digital write pin mode etc.
AnalogMultiplex buttonsmux1(1, { 10, 11, 12 } );
AnalogMultiplex buttonsmux2(0, { 10, 11, 12 } );
AnalogMultiplex Ledbuttonsmux1(2, { 10, 11, 12 } );
AnalogMultiplex Ledbuttonsmux2(3, { 10, 11, 12 } );
AnalogMultiplex Ledbuttonsmux3(4, { 10, 11, 12 } );
AnalogMultiplex Ledbuttonsmux4(5, { 10, 11, 12 } );
AnalogMultiplex fadersmux1(A0, { 10, 11, 12 } );
AnalogMultiplex faderspotsmux (A1, { 10, 11, 12 } );
AnalogMultiplex potsmux1 (A2, { 10, 11, 12 } );
AnalogMultiplex potsmux2 (A3, { 10, 11, 12 } );
// creating muxers
//AnalogMultiplex(pin_t analogPin, { pin_t addressPin1, addressPin2, ... addressPinN } )
//analogPin: the analog input pin connected to the output of the multiplexer
//addressPin#: the digital output pins connected to the address lines of the multiplexer
DigitalLatch Arcadebuttons[] = {
{buttonsmux1.pin(0), 0, 14, 127, 10},
{buttonsmux1.pin(1), 1, 14, 127, 10},
{buttonsmux1.pin(2), 2, 14, 127, 10},
{buttonsmux1.pin(3), 3, 14, 127, 10},
{buttonsmux1.pin(4), 4, 14, 127, 10},
{buttonsmux1.pin(5), 5, 14, 127, 10},
{buttonsmux1.pin(6), 6, 14, 127, 10},
{buttonsmux1.pin(7), 7, 14, 127, 10},
// Create 8 new instances of the class 'DigitalLatch', on the 8 pins of the buttonsmux1
// that send MIDI notes 0-7 on channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
DigitalLatch Arcadebuttonextras[] = {
{buttonsmux2.pin(3), 8, 14, 127, 10},
{buttonsmux2.pin(4), 9, 14, 127, 10},
//extra two arcade buttons
// that send MIDI notes 8 & 9 on channel 14
};
Digital Navigation[] = {
{buttonsmux2.pin(5), 10, 14, 127},
{buttonsmux2.pin(6), 11, 14, 127},
{buttonsmux2.pin(7), 12 , 14, 127},
// Create 3 new instances of the class 'Digital' for navigation buttons, on the 3 pins of the buttonsmux2
// that send MIDI notes 10-12 on channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
Analog MasterFader (A9, 19, 14);
Analog Faders1[] = {
{fadersmux1.pin(0), 20, 14},
{fadersmux1.pin(1), 21, 14},
{fadersmux1.pin(2), 22, 14},
{fadersmux1.pin(3), 23, 14},
{fadersmux1.pin(4), 24, 14},
{fadersmux1.pin(5), 25 , 14},
{fadersmux1.pin(6), 26, 14},
{fadersmux1.pin(7), 27, 14},
//create 8 new instances of the class "Analog" for the first 8 channel faders, on the 3 pins of fadersmux1
// that send CC commands 20-27 on MIDI channel 14
// Analog(pin_t analogPin, uint8_t controllerNumber, uint8_t channel)
};
Analog FadersPots[] = {
{faderspotsmux.pin(0), 28, 14},
{faderspotsmux.pin(1), 29, 14},
{faderspotsmux.pin(2), 30, 14},
{faderspotsmux.pin(3), 31, 14},
{faderspotsmux.pin(4), 32, 14},
{faderspotsmux.pin(5), 33, 14},
{faderspotsmux.pin(6), 34, 14},
{faderspotsmux.pin(7), 35, 14},
//create 8 new instances of the class "Analog" for faders 8&9 and six leftmost pots, on the 3 pins of faderspotmux
// that send CC commands 28-35 on MIDI channel 14
// Analog(pin_t analogPin, uint8_t controllerNumber, uint8_t channel)
};
Analog Pots1[] = {
{potsmux1.pin(0), 36, 14},
{potsmux1.pin(1), 37, 14},
{potsmux1.pin(2), 38, 14},
{potsmux1.pin(3), 39, 14},
{potsmux1.pin(4), 40, 14},
{potsmux1.pin(5), 41, 14},
{potsmux1.pin(6), 42, 14},
{potsmux1.pin(7), 43, 14},
//create 8 new instances of the class "Analog" for the middle section of pots, on the 3 pins of faderspotmux
// that send CC commands 36-43 on MIDI channel 14
// Analog(pin_t analogPin, uint8_t controllerNumber, uint8_t channel)
};
Analog Pots2[] = {
{potsmux2.pin(0), 44, 14},
{potsmux2.pin(1), 45, 14},
{potsmux2.pin(2), 46, 14},
{potsmux2.pin(3), 47, 14},
{potsmux2.pin(4), 48, 14},
{potsmux2.pin(5), 49, 14},
{potsmux2.pin(6), 50, 14},
{potsmux2.pin(7), 51, 14},
//create 8 new instances of the class "Analog" for the middle section of pots, on the 3 pins of faderspotmux
// that send CC commands 36-43 on MIDI channel 14
// Analog(pin_t analogPin, uint8_t controllerNumber, uint8_t channel)
};
DigitalLatch Ledbuttons1 [] = {
{Ledbuttonsmux1.pin(0), 13, 14, 127, 10},
{Ledbuttonsmux1.pin(1), 14, 14, 127, 10},
{Ledbuttonsmux1.pin(2), 15, 14, 127, 10},
{Ledbuttonsmux1.pin(3), 16, 14, 127, 10},
{Ledbuttonsmux1.pin(4), 17, 14, 127, 10},
{Ledbuttonsmux1.pin(5), 18, 14, 127, 10},
{Ledbuttonsmux1.pin(6), 19, 14, 127, 10},
{Ledbuttonsmux1.pin(7), 20, 14, 127, 10},
// create 8 new instance of the class "Digital" for the right hand 8 LED buttons on the pins of Ledbuttonsmux1
// They send notes 13-20 on MIDI channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
DigitalLatch Ledbuttons2 [] = {
{Ledbuttonsmux2.pin(0), 21, 14, 127, 10},
{Ledbuttonsmux2.pin(1), 22, 14, 127, 10},
{Ledbuttonsmux2.pin(2), 23, 14, 127, 10},
{Ledbuttonsmux2.pin(3), 24, 14, 127, 10},
{Ledbuttonsmux2.pin(4), 25, 14, 127, 10},
{Ledbuttonsmux2.pin(5), 26, 14, 127, 10},
{Ledbuttonsmux2.pin(6), 27, 14, 127, 10},
{Ledbuttonsmux2.pin(7), 28, 14, 127, 10},
// create 8 new instance of the class "Digital" for the right hand 8 LED buttons on the pins of Ledbuttonsmux1
// They send notes 21-28 on MIDI channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
DigitalLatch Ledbuttons3 [] = {
{Ledbuttonsmux3.pin(0), 29, 14, 127, 10},
{Ledbuttonsmux3.pin(1), 30, 14, 127, 10},
{Ledbuttonsmux3.pin(2), 31, 14, 127, 10},
{Ledbuttonsmux3.pin(3), 32, 14, 127, 10},
{Ledbuttonsmux3.pin(4), 33, 14, 127, 10},
{Ledbuttonsmux3.pin(5), 34, 14, 127, 10},
{Ledbuttonsmux3.pin(6), 35, 14, 127, 10},
{Ledbuttonsmux3.pin(7), 36, 14, 127, 10},
// create 8 new instance of the class "Digital" for the right hand 8 LED buttons on the pins of Ledbuttonsmux1
// They send notes 29-36 on MIDI channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
DigitalLatch Ledbuttons4 [] = {
{Ledbuttonsmux4.pin(2), 37, 14, 127, 10},
{Ledbuttonsmux4.pin(3), 38, 14, 127, 10},
{Ledbuttonsmux4.pin(4), 39, 14, 127, 10},
{Ledbuttonsmux4.pin(5), 40, 14, 127, 10},
{Ledbuttonsmux4.pin(6), 41, 14, 127, 10},
{Ledbuttonsmux4.pin(7), 42, 14, 127, 10},
// create 6 new instance of the class "Digital" for the right hand 8 LED buttons on the pins of Ledbuttonsmux1
// They send notes 37-42 on MIDI channel 14
//Digital(pin_t pin, uint8_t note, uint8_t channel, uint8_t velocity = 127, latch time)
//pin: the digital input pin to read the state from, the internal pull-up resistor will be enabled
//note: the MIDI note number [0, 127]
//channel: the MIDI channel [1, 16]
//velocity: the MIDI velocity of the Note events [1, 127], how hard the key/button is struck
};
//CONSTANT VALUES
const static byte Channel_Volume = 0x7;
// controller number 7 is defined as Channel Volume in the MIDI implementation.
const static size_t analogAverage = 8;
// Use the average of 8 samples to get smooth transitions and prevent noise
const static byte velocity = 127;
// the maximum velocity, since MIDI uses a 7-bit number for velocity.
const static int latchTime = 3000;
// the amount of time (in ms) the note is held on. Read documentation or see source code for more information.
const static byte C4 = 60;
// note number 60 is defined as middle C in the MIDI implementation.
const static byte E0 = 16;
// note number 60 is defined as middle C in the MIDI implementation, so 16 is E0
const byte Channel = 14;
// MIDI channel 14
const byte Controller = 0x14;
// MIDI controller number
const int speedMultiply = 1;
// no change in speed of the encoder
void setup() {
}
void loop() {
MIDI_Controller.refresh();
}