forked from corbanbrook/spectrotune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmidi.pde
39 lines (36 loc) · 1.07 KB
/
midi.pde
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
Note[] notesOpen = new Note[128];
void outputMIDINotes() {
if ( MIDI_TOGGLE ) {
// send NoteOns
for ( int i = 0; i < notes[frameNumber].length; i++ ) {
Note note = notes[frameNumber][i];
if ( OCTAVE_TOGGLE[note.octave] && notesOpen[note.pitch] == null) {
midiOut.sendNoteOn(note.channel, note.pitch, note.velocity);
notesOpen[note.pitch] = note;
}
}
// send NoteOffs
for ( int i = 0; i < notesOpen.length; i++ ) {
boolean isOpen = false;
if ( notesOpen[i] != null ) {
for ( int j = 0; j < notes[frameNumber].length; j++ ) {
if ( notes[frameNumber][j].pitch == i ) {
isOpen = true;
}
}
if ( !isOpen ) {
midiOut.sendNoteOff(notesOpen[i].channel, i, notesOpen[i].velocity);
notesOpen[i] = null;
}
}
}
}
}
void closeMIDINotes() {
for ( int i = 0; i < notesOpen.length; i++ ) {
if ( notesOpen[i] != null ) {
midiOut.sendNoteOff(notesOpen[i].channel, i, notesOpen[i].velocity);
notesOpen[i] = null;
}
}
}