--- /dev/null
+/*
+ Copyright (C) 2015 Paul Brossier <piem@aubio.org>
+
+ This file is part of ofxAubio.
+
+ ofxAubio is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ aubio is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with aubio. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "ofxAubioBeat.h"
+#include "ofLog.h"
+
+ofxAubioBeat::ofxAubioBeat()
+{
+}
+
+void ofxAubioBeat::setup()
+{
+ setup("default", 512, 256, 44100);
+}
+
+void ofxAubioBeat::setup(string method, int buf_s, int hop_s, int samplerate)
+{
+ ofxAubioBlock::setup(method, buf_s, hop_s, samplerate);
+ tempo = new_aubio_tempo((char_t*)method.c_str(),
+ buf_size, hop_size, samplerate);
+ if (tempo) {
+ ofLogNotice() << "created ofxAubioBeat(" << method
+ << ", " << buf_size
+ << ", " << hop_size
+ << ", " << samplerate
+ << ")";
+ }
+}
+
+ofxAubioBeat::~ofxAubioBeat()
+{
+ if (tempo) del_aubio_tempo(tempo);
+ cleanup();
+ ofLogNotice() << "deleted ofxAubioBeat";
+}
+
+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);
+ }
+}
--- /dev/null
+/*
+ Copyright (C) 2015 Paul Brossier <piem@aubio.org>
+
+ This file is part of ofxAubio.
+
+ ofxAubio is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ aubio is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with aubio. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#pragma once
+
+#include <iostream>
+#include <aubio/aubio.h>
+#include "ofxAubioBlock.h"
+
+using namespace std;
+
+class ofxAubioBeat : public ofxAubioBlock {
+
+ public:
+
+ ofxAubioBeat();
+ ~ofxAubioBeat();
+
+ void setup();
+ void setup(string method, int buf_s, int hop_s, int samplerate);
+
+ float bpm;
+
+ private:
+ void blockAudioIn();
+ bool beatFlag = false;
+ // aubio stuff
+ aubio_tempo_t * tempo;
+};