src/ofxAubioBeat.h: use custom event for beat
authorPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:43:28 +0000 (16:43 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:43:28 +0000 (16:43 +0100)
src/ofxAubioBeat.cpp
src/ofxAubioBeat.h

index a2a44cf..719ff8c 100644 (file)
@@ -21,6 +21,8 @@
 #include "ofxAubioBeat.h"
 #include "ofLog.h"
 
+ofEvent<float> ofxAubioBeat::gotGlobalBeat = ofEvent<float>();
+
 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);
     }
 }
index 8cc56c1..d2c0fb4 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <iostream>
 #include <aubio/aubio.h>
+#include "ofEvents.h"
 #include "ofxAubioBlock.h"
 
 using namespace std;
@@ -33,6 +34,9 @@ class ofxAubioBeat : public ofxAubioBlock {
        ofxAubioBeat();
        ~ofxAubioBeat();
 
+       ofEvent<float> gotBeat;
+       static ofEvent<float> gotGlobalBeat;
+
        void setup();
        void setup(string method, int buf_s, int hop_s, int samplerate);