From eccff040cfeffcce74d57cee36544d02de1b324c Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 19 Jan 2016 16:43:28 +0100 Subject: [PATCH] src/ofxAubioBeat.h: use custom event for beat --- src/ofxAubioBeat.cpp | 6 +++++- src/ofxAubioBeat.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ofxAubioBeat.cpp b/src/ofxAubioBeat.cpp index a2a44cf..719ff8c 100644 --- a/src/ofxAubioBeat.cpp +++ b/src/ofxAubioBeat.cpp @@ -21,6 +21,8 @@ #include "ofxAubioBeat.h" #include "ofLog.h" +ofEvent ofxAubioBeat::gotGlobalBeat = ofEvent(); + ofxAubioBeat::ofxAubioBeat() { } @@ -57,7 +59,9 @@ void ofxAubioBeat::blockAudioIn() aubio_tempo_do(tempo, aubio_input, aubio_output); if (aubio_output->data[0]) { //ofLogNotice() << "found beat: " << aubio_output->data[0]; - toSend = true; bpm = aubio_tempo_get_bpm(tempo); + float last_beat = aubio_tempo_get_last_s(tempo); + ofNotifyEvent(gotBeat, last_beat, this); + ofNotifyEvent(gotGlobalBeat, last_beat); } } diff --git a/src/ofxAubioBeat.h b/src/ofxAubioBeat.h index 8cc56c1..d2c0fb4 100644 --- a/src/ofxAubioBeat.h +++ b/src/ofxAubioBeat.h @@ -22,6 +22,7 @@ #include #include +#include "ofEvents.h" #include "ofxAubioBlock.h" using namespace std; @@ -33,6 +34,9 @@ class ofxAubioBeat : public ofxAubioBlock { ofxAubioBeat(); ~ofxAubioBeat(); + ofEvent gotBeat; + static ofEvent gotGlobalBeat; + void setup(); void setup(string method, int buf_s, int hop_s, int samplerate); -- 2.11.0