Skip to content

Commit ac6108a

Browse files
committed
Adds midi command executor to utils
1 parent 3736433 commit ac6108a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ofxAudioUnitManagerUtils.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ void ofxAudioUnitManagerUtils::setup() {
66

77
/* Format can be either: "60 ON", "60 OFF" etc, or
88
"C#5 ON", "C#5 OFF" etc */
9+
void ofxAudioUnitManagerUtils::executeMidiCommand(string command, ofxMidiOut *midi) {
10+
vector<string> args = ofSplitString(command, " ");
11+
int parsedNote = midiNote(args.at(0));
12+
if(args.at(1) == "ON") {
13+
cout << "Sending MIDI ON: " << parsedNote << endl;
14+
midi->sendNoteOn(1, parsedNote);
15+
} else {
16+
cout << "Sending MIDI OFF: " << parsedNote << endl;
17+
midi->sendNoteOff(1, parsedNote);
18+
}
19+
}
20+
921
int ofxAudioUnitManagerUtils::midiNote(string arg) {
1022
if(arg.length() > 1 && ofToInt(arg) == 0) {
1123
octave = ofToInt(arg.substr(arg.length() - 1, arg.length()));

src/ofxAudioUnitManagerUtils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#pragma once
22
#include "ofMain.h"
3+
#include "MidiHandler.h"
34

45
class ofxAudioUnitManagerUtils {
56

67
public:
78
void setup();
9+
void executeMidiCommand(string command, ofxMidiOut *midi);
810
int midiNote(string arg);
911
protected:
1012
void loadNotesMap();

0 commit comments

Comments
 (0)