src/ofxAubioOnset.h: add onset event
authorPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:16:13 +0000 (16:16 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:16:13 +0000 (16:16 +0100)
src/ofxAubioOnset.cpp
src/ofxAubioOnset.h

index 51cb843..3e1b1d6 100644 (file)
@@ -21,6 +21,8 @@
 #include "ofxAubioOnset.h"
 #include "ofLog.h"
 
+ofEvent<float> ofxAubioOnset::gotGlobalOnset = ofEvent<float>();
+
 ofxAubioOnset::ofxAubioOnset()
 {
 }
@@ -58,6 +60,9 @@ void ofxAubioOnset::blockAudioIn()
     if (aubio_output->data[0]) {
         toSend = true;
         //ofLogNotice() << "found onset";
+        float last_onset = aubio_onset_get_last_s(onset);
+        ofNotifyEvent(gotOnset, last_onset, this);
+        ofNotifyEvent(gotGlobalOnset, last_onset);
     }
     novelty = aubio_onset_get_descriptor(onset);
     thresholdedNovelty = aubio_onset_get_thresholded_descriptor(onset);
index ce32dfb..be12f35 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <iostream>
 #include <aubio/aubio.h>
+#include "ofEvents.h"
 #include "ofxAubioBlock.h"
 
 class ofxAubioOnset : public ofxAubioBlock {
@@ -31,6 +32,9 @@ class ofxAubioOnset : public ofxAubioBlock {
        ofxAubioOnset();
        ~ofxAubioOnset();
 
+       ofEvent<float> gotOnset;
+       static ofEvent<float> gotGlobalOnset;
+
        void setup();
        void setup(std::string method, int buf_s, int hop_s, int samplerate);