-
Notifications
You must be signed in to change notification settings - Fork 0
/
track.ino
54 lines (48 loc) · 1.49 KB
/
track.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "track.h"
// Track constructors
Track::Track() : TouchSwitch(0, 0){};
Track::Track(int p, byte n) : TouchSwitch(p){
// TouchSwitch::setThreshold();
number = n;
level = 0;
state = false;
};
// Track destructor
Track::~Track(){};
int Track::send(){
int returnme = -1;
TouchSwitch::update();
if(TouchSwitch::risingEdge()){ // Arm or disarm tracks.
usbMIDI.sendControlChange(number,127,MIDIchannel);
usbMIDI.sendControlChange(number,0,MIDIchannel);
state = !state;
returnme = state == true ? level : 0; //Show level on arm
}
return returnme;
};
int Track::vol(int incdec){
int returnme = -1;
if(state == true && incdec != 0){ // If the track is armed
if((incdec == 1 && level < 127) || // and isn't already maxed or
(incdec == -1 && level > 0)){ // already at 0
level += incdec; // update track level.
usbMIDI.sendControlChange(number+3,level,MIDIchannel); // & send.
returnme = level;
}
}
return returnme;
};
byte record(byte rec, byte stp){
static int scene = 111;
if(rec){ // uses CC# 111~119 to trigger scenes
scene = scene == 119 ? 111 : scene + 1;
usbMIDI.sendControlChange(scene,127,MIDIchannel);
usbMIDI.sendControlChange(scene,0,MIDIchannel);
}
if(stp){ // uses CC#111 to stop rec and reset the cycle
usbMIDI.sendControlChange(111,127,MIDIchannel);
usbMIDI.sendControlChange(111,0,MIDIchannel);
scene = 111;
}
if(scene > 111){return true;}else{return false;}
};