Skip to content

Commit 3736433

Browse files
committed
Adds util class
1 parent 7472168 commit 3736433

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

example/example.xcodeproj/project.pbxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
84A527331B12794700C8A56C /* ofxMidiOut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A527191B12794700C8A56C /* ofxMidiOut.cpp */; };
5555
84A527341B12794700C8A56C /* RtMidi.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A5272A1B12794700C8A56C /* RtMidi.cpp */; };
5656
84A527351B12794700C8A56C /* CoreMIDI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84A5272C1B12794700C8A56C /* CoreMIDI.framework */; };
57+
84D636A61B483A7B007FFF65 /* ofxAudioUnitManagerUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84D636A41B483A7B007FFF65 /* ofxAudioUnitManagerUtils.cpp */; };
5758
BBAB23CB13894F3D00AA2426 /* GLUT.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; };
5859
E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; };
5960
E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9710E8CC7DD009D7055 /* AGL.framework */; };
@@ -204,6 +205,8 @@
204205
84A5272A1B12794700C8A56C /* RtMidi.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RtMidi.cpp; sourceTree = "<group>"; };
205206
84A5272B1B12794700C8A56C /* RtMidi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RtMidi.h; sourceTree = "<group>"; };
206207
84A5272C1B12794700C8A56C /* CoreMIDI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMIDI.framework; path = ../../../../../../../../../../System/Library/Frameworks/CoreMIDI.framework; sourceTree = "<group>"; };
208+
84D636A41B483A7B007FFF65 /* ofxAudioUnitManagerUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ofxAudioUnitManagerUtils.cpp; sourceTree = "<group>"; };
209+
84D636A51B483A7B007FFF65 /* ofxAudioUnitManagerUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxAudioUnitManagerUtils.h; sourceTree = "<group>"; };
207210
BBAB23BE13894E4700AA2426 /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = ../../../libs/glut/lib/osx/GLUT.framework; sourceTree = "<group>"; };
208211
E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openFrameworksLib.xcodeproj; path = ../../../libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj; sourceTree = SOURCE_ROOT; };
209212
E45BE9710E8CC7DD009D7055 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
@@ -276,6 +279,8 @@
276279
8432144E1B1A2E000030CB9C /* Handlers */,
277280
843214551B1A2E000030CB9C /* ofxAudioUnitManager.cpp */,
278281
843214561B1A2E000030CB9C /* ofxAudioUnitManager.h */,
282+
84D636A41B483A7B007FFF65 /* ofxAudioUnitManagerUtils.cpp */,
283+
84D636A51B483A7B007FFF65 /* ofxAudioUnitManagerUtils.h */,
279284
);
280285
name = src;
281286
path = ../src;
@@ -683,6 +688,7 @@
683688
84A527341B12794700C8A56C /* RtMidi.cpp in Sources */,
684689
84A527301B12794700C8A56C /* ofxMidi.cpp in Sources */,
685690
84A5272F1B12794700C8A56C /* ofxBaseMidi.cpp in Sources */,
691+
84D636A61B483A7B007FFF65 /* ofxAudioUnitManagerUtils.cpp in Sources */,
686692
84A5272D1B12794700C8A56C /* ofxRtMidiIn.cpp in Sources */,
687693
843214AD1B1A3B2D0030CB9C /* ofxAudioUnitNetReceive.cpp in Sources */,
688694
84A527311B12794700C8A56C /* ofxMidiIn.cpp in Sources */,

src/ofxAudioUnitManagerUtils.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include "ofxAudioUnitManagerUtils.h"
2+
3+
void ofxAudioUnitManagerUtils::setup() {
4+
loadNotesMap();
5+
}
6+
7+
/* Format can be either: "60 ON", "60 OFF" etc, or
8+
"C#5 ON", "C#5 OFF" etc */
9+
int ofxAudioUnitManagerUtils::midiNote(string arg) {
10+
if(arg.length() > 1 && ofToInt(arg) == 0) {
11+
octave = ofToInt(arg.substr(arg.length() - 1, arg.length()));
12+
note = notes[arg.substr(0, arg.length() - 1)];
13+
return note + 12 * octave;
14+
}
15+
return ofToInt(arg);
16+
}
17+
18+
void ofxAudioUnitManagerUtils::loadNotesMap() {
19+
notes["C"] = 0;
20+
notes["C#"] = 1;
21+
notes["D"] = 2;
22+
notes["D#"] = 3;
23+
notes["E"] = 4;
24+
notes["F"] = 5;
25+
notes["F#"] = 6;
26+
notes["G"] = 7;
27+
notes["G#"] = 8;
28+
notes["A"] = 9;
29+
notes["A#"] = 10;
30+
notes["B"] = 11;
31+
}

src/ofxAudioUnitManagerUtils.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
#include "ofMain.h"
3+
4+
class ofxAudioUnitManagerUtils {
5+
6+
public:
7+
void setup();
8+
int midiNote(string arg);
9+
protected:
10+
void loadNotesMap();
11+
int octave, note;
12+
map<string, int> notes;
13+
};

0 commit comments

Comments
 (0)