From: Paul Brossier Date: Tue, 19 Jan 2016 15:16:13 +0000 (+0100) Subject: src/ofxAubioOnset.h: add onset event X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=5733381b0e068bafd0d58a8c8d2a25d9b26d2797;p=ofxAubio.git src/ofxAubioOnset.h: add onset event --- diff --git a/src/ofxAubioOnset.cpp b/src/ofxAubioOnset.cpp index 51cb843..3e1b1d6 100644 --- a/src/ofxAubioOnset.cpp +++ b/src/ofxAubioOnset.cpp @@ -21,6 +21,8 @@ #include "ofxAubioOnset.h" #include "ofLog.h" +ofEvent ofxAubioOnset::gotGlobalOnset = ofEvent(); + 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); diff --git a/src/ofxAubioOnset.h b/src/ofxAubioOnset.h index ce32dfb..be12f35 100644 --- a/src/ofxAubioOnset.h +++ b/src/ofxAubioOnset.h @@ -22,6 +22,7 @@ #include #include +#include "ofEvents.h" #include "ofxAubioBlock.h" class ofxAubioOnset : public ofxAubioBlock { @@ -31,6 +32,9 @@ class ofxAubioOnset : public ofxAubioBlock { ofxAubioOnset(); ~ofxAubioOnset(); + ofEvent gotOnset; + static ofEvent gotGlobalOnset; + void setup(); void setup(std::string method, int buf_s, int hop_s, int samplerate);