-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patht_arpNote.cpp
More file actions
76 lines (60 loc) · 2.24 KB
/
Copy patht_arpNote.cpp
File metadata and controls
76 lines (60 loc) · 2.24 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
#include "t_arpNote.h"
void calculateArpNoteChords(byte note, byte velocity){
arpNoteRootNote = note;
//if the direction is ->
if (arpNoteDirection){
//if an on note is received while the app is set to major key
for(byte i = 0; i < 8; i++){
arpNoteMajorChordArray[i] = arpNoteRootNote + majorChordPattern[i];
arpNoteMinorChordArray[i] = arpNoteRootNote + minorChordPattern[i];
}
}
//if direction <-
if (!arpNoteDirection){
//if an on note is received while the app is set to major key
for(byte i = 0; i < 8; i++){
arpNoteMajorChordArray[i] = arpNoteRootNote - majorChordPattern[i];
arpNoteMinorChordArray[i] = arpNoteRootNote - minorChordPattern[i];
}
}
if(arpNoteKey){
memcpy(arpNotePlayingChordArray, arpNoteMajorChordArray, sizeof(arpNoteMajorChordArray));
}
if(!arpNoteKey){
memcpy(arpNotePlayingChordArray, arpNoteMinorChordArray, sizeof(arpNoteMinorChordArray));
}
}
void cancelArpNote(){
arpNoteStartTime =0;
memset(arpNoteMinorChordArray, 0, sizeof(arpNoteMinorChordArray));
memset(arpNoteMajorChordArray, 0, sizeof(arpNoteMajorChordArray));
firstArpNoteNotePlaying = false;
arpNoteRootNote = 0;
}
void arpNote(unsigned long currentTime, int status, byte note, byte velocity){
if (status == 0x90 && !firstArpNoteNotePlaying && arpNoteRootNote == 0){
firstArpNoteNotePlaying = true;
arpNoteNotePlaying = note;
calculateArpNoteChords(note, velocity);
arpNoteStartTime = currentTime + arpNoteTempo;
}
if (status == 0x80 && note == arpNoteRootNote && !arpNoteSequencePlaying){
cancelArpNote();
}
if (status == 0x90 && arpNoteSequencePlaying && note == arpNoteRootNote){
MIDI.sendNoteOff(arpNoteNotePlaying, 0, arpNoteOutChannel);
firstArpNoteNotePlaying = true;
arpNoteSequencePlaying = false;
arpNoteNotePlaying = note;
calculateArpNoteChords(note, velocity);
arpNoteStartTime = currentTime + arpNoteTempo;
}
if(status == 0x90 && arpNoteSequencePlaying && note != arpNoteRootNote ){
MIDI.sendNoteOff(arpNoteNotePlaying, 0, arpNoteOutChannel);
firstArpNoteNotePlaying = true;
arpNoteSequencePlaying = false;
arpNoteNotePlaying = note;
calculateArpNoteChords(note, velocity);
arpNoteStartTime = currentTime + arpNoteTempo;
}
}