// setup beat object
beat.setup();
//beat.setup("default", 2 * bufferSize, bufferSize, samplerate);
+ // listen to beat event
+ ofAddListener(beat.gotBeat, this, &ofApp::beatEvent);
// setup mel bands object
bands.setup();
start += 250;
onsetGui.setup("ofxAubioOnset", "settings.xml", start + 10, 10);
- onsetGui.add(gotOnset.setup( "onset", 0, 0, 250));
onsetGui.add(onsetThreshold.setup( "threshold", 0, 0, 2));
onsetGui.add(onsetNovelty.setup( "onset novelty", 0, 0, 10000));
onsetGui.add(onsetThresholdedNovelty.setup( "thr. novelty", 0, -1000, 1000));
//--------------------------------------------------------------
void ofApp::draw(){
// update beat info
- if (beat.received()) {
+ if (gotBeat) {
ofSetColor(ofColor::green);
ofRect(90,150,50,50);
+ gotBeat = false;
}
// update onset info
if (gotOnset) {
ofSetColor(ofColor::red);
ofRect(250 + 90,150,50,50);
- gotOnset = 0;
+ gotOnset = false;
}
onsetNovelty = onset.novelty;
onsetThresholdedNovelty = onset.thresholdedNovelty;
//----
void ofApp::onsetEvent(float & time) {
ofLog() << "got onset at " << time << " s";
- gotOnset = 1;
+ gotOnset = true;
+}
+
+//----
+void ofApp::beatEvent(float & time) {
+ ofLog() << "got beat at " << time << " s";
+ gotBeat = true;
}
void audioOut();
void onsetEvent(float & time);
+ void beatEvent(float & time);
private:
ofxAubioOnset onset;
ofxFloatSlider pitchConfidence;
ofxPanel beatGui;
+ bool gotBeat;
ofxFloatSlider bpm;
ofxPanel onsetGui;
- ofxFloatSlider gotOnset;
+ bool gotOnset;
ofxFloatSlider onsetThreshold;
ofxFloatSlider onsetNovelty;
ofxFloatSlider onsetThresholdedNovelty;