--- /dev/null
+#include "ofApp.h"
+
+//--------------------------------------------------------------
+void ofApp::setup(){
+ // set the size of the window
+ ofSetWindowShape(750, 250);
+
+ int nOutputs = 2;
+ int nInputs = 2;
+ //int sampleRate = 44100;
+ //int bufferSize = 256;
+ //int nBuffers = 4;
+
+ // setup onset object
+ onset.setup();
+ //onset.setup("mkl", 2 * bufferSize, bufferSize, sampleRate);
+
+ // setup pitch object
+ pitch.setup();
+ //pitch.setup("yinfft", 8 * bufferSize, bufferSize, sampleRate);
+
+ // setup beat object
+ beat.setup();
+ //beat.setup("default", 2 * bufferSize, bufferSize, samplerate);
+
+ ofSoundStreamSetup(nOutputs, nInputs, this);
+ //ofSoundStreamSetup(nOutputs, nInputs, sampleRate, bufferSize, nBuffers);
+ //ofSoundStreamListDevices();
+
+ // setup the gui
+ int start = 0;
+ beatGui.setup("", "settings.xml", start + 10, 10);
+ beatGui.add(bpm.setup( "bpm", 0, 0, 250));
+
+ start += 250;
+ onsetGui.setup("", "settings.xml", start + 10, 10);
+ onsetGui.add(gotOnset.setup( "onset", 0, 0, 250));
+
+ start += 250;
+ pitchGui.setup("", "settings.xml", start + 10, 10);
+ pitchGui.add(midiPitch.setup( "midi pitch", 0, 0, 128));
+ pitchGui.add(pitchConfidence.setup( "pitch confidence", 0, 0, 1));
+
+}
+
+void ofApp::audioIn(float * input, int bufferSize, int nChannels){
+ // compute onset detection
+ onset.audioIn(input, bufferSize, nChannels);
+ // compute pitch detection
+ pitch.audioIn(input, bufferSize, nChannels);
+ // compute beat location
+ beat.audioIn(input, bufferSize, nChannels);
+}
+
+void audioOut(){
+}
+
+//--------------------------------------------------------------
+void ofApp::update(){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::draw(){
+ // get the latest onset
+ if (beat.received()) {
+ ofSetHexColor(0x00FF00);
+ ofRect(90,100,50,50);
+ }
+ if (onset.received()) {
+ ofSetHexColor(0xFF0000);
+ ofRect(250 + 90,100,50,50);
+ gotOnset = 1;
+ } else {
+ gotOnset = 0;
+ }
+
+ ofSetHexColor(0x000000);
+ pitchConfidence = pitch.pitchConfidence;
+ if (pitchConfidence > 0.7) midiPitch = pitch.latestPitch;
+ bpm = beat.bpm;
+
+ pitchGui.draw();
+ beatGui.draw();
+ onsetGui.draw();
+}
+
+//--------------------------------------------------------------
+void ofApp::keyPressed(int key){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::keyReleased(int key){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseMoved(int x, int y ){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseDragged(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mousePressed(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::mouseReleased(int x, int y, int button){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::windowResized(int w, int h){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::gotMessage(ofMessage msg){
+
+}
+
+//--------------------------------------------------------------
+void ofApp::dragEvent(ofDragInfo dragInfo){
+
+}
--- /dev/null
+#pragma once
+
+#include "ofMain.h"
+#include "ofxAubio.h"
+#include "ofxGui.h"
+
+class ofApp : public ofBaseApp{
+
+ public:
+ void setup();
+ void update();
+ void draw();
+
+ void keyPressed(int key);
+ void keyReleased(int key);
+ void mouseMoved(int x, int y );
+ void mouseDragged(int x, int y, int button);
+ void mousePressed(int x, int y, int button);
+ void mouseReleased(int x, int y, int button);
+ void windowResized(int w, int h);
+ void dragEvent(ofDragInfo dragInfo);
+ void gotMessage(ofMessage msg);
+
+ void audioIn(float * input, int bufferSize, int nChannels);
+ void audioOut();
+
+ private:
+ ofxAubioOnset onset;
+ ofxAubioPitch pitch;
+ ofxAubioBeat beat;
+
+ ofxPanel pitchGui;
+ ofxFloatSlider midiPitch;
+ ofxFloatSlider pitchConfidence;
+
+ ofxPanel beatGui;
+ ofxFloatSlider bpm;
+
+ ofxPanel onsetGui;
+ ofxFloatSlider gotOnset;
+};