src/ofxAubio.h: add filter detect
authorPaul Brossier <piem@piem.org>
Thu, 21 Jan 2016 08:09:55 +0000 (09:09 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 21 Jan 2016 08:09:55 +0000 (09:09 +0100)
src/ofxAubio.h
src/ofxAubioAttackClass.cpp
src/ofxAubioBeat.cpp
src/ofxAubioMelBands.cpp
src/ofxAubioMelBands.h
src/ofxAubioOnset.cpp

index 061eb45..d2dcce8 100644 (file)
@@ -23,3 +23,4 @@
 #include "ofxAubioPitch.h"
 #include "ofxAubioMelBands.h"
 #include "ofxAubioAttackClass.h"
+#include "ofxAubioFilterDetect.h"
index 40a8201..866d30c 100644 (file)
@@ -31,7 +31,7 @@ ofxAubioAttackClass::ofxAubioAttackClass()
     : bands(NULL)
 {
     lag_onset = 3;
-    lag_beat = 3;
+    lag_beat = 10;
     min_band_onset = 3;
     min_band_beat = 3;
 }
index ce5ed36..da25220 100644 (file)
@@ -38,7 +38,7 @@ 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);
-    aubio_tempo_set_silence(tempo, -60);
+    aubio_tempo_set_silence(tempo, -1000);
     if (tempo) {
         ofLogNotice() << "created ofxAubioBeat(" << method
           << ", " << buf_size
index fecb455..fda5184 100644 (file)
@@ -36,11 +36,14 @@ void ofxAubioMelBands::setup(string method, int buf_s, int hop_s, int samplerate
     nBands = 40;
     pv = new_aubio_pvoc(buf_s, hop_s);
     spectrum = new_cvec(buf_s);
+    awhitening = new_aubio_spectral_whitening(buf_s, hop_s, samplerate);
     fb = new_aubio_filterbank(nBands, buf_s);
     aubio_filterbank_set_mel_coeffs_slaney(fb, samplerate);
     bands = new_fvec(nBands);
     energies = bands->data;
 
+    bDoWhitening = true;
+
     if (pv && fb) {
         ofLogNotice() << "created ofxAubioMelBands(" << method
           << ", " << buf_size
@@ -54,6 +57,7 @@ ofxAubioMelBands::~ofxAubioMelBands()
 {
     if (spectrum) del_cvec(spectrum);
     if (pv) del_aubio_pvoc(pv);
+    if (awhitening) del_aubio_spectral_whitening(awhitening);
     if (bands) del_fvec(bands);
     if (fb) del_aubio_filterbank(fb);
     cleanup();
@@ -63,5 +67,8 @@ ofxAubioMelBands::~ofxAubioMelBands()
 void ofxAubioMelBands::blockAudioIn()
 {
     aubio_pvoc_do(pv, aubio_input, spectrum);
+    if (bDoWhitening) {
+        //aubio_spectral_whitening_do(awhitening, spectrum);
+    }
     aubio_filterbank_do(fb, spectrum, bands);
 }
index c04f62f..a94701a 100644 (file)
@@ -39,11 +39,14 @@ class ofxAubioMelBands : public ofxAubioBlock {
        int nBands;
        float *energies;
 
+       bool bDoWhitening;
+
     private:
        void blockAudioIn();
        // aubio stuff
        aubio_pvoc_t *pv;
        cvec_t *spectrum;
+       aubio_spectral_whitening_t *awhitening;
        aubio_filterbank_t *fb;
        fvec_t *bands;
 };
index 06f32a6..086a3e1 100644 (file)
@@ -37,6 +37,7 @@ void ofxAubioOnset::setup(string method, int buf_s, int hop_s, int samplerate)
     ofxAubioBlock::setup(method, buf_s, hop_s, samplerate);
     onset = new_aubio_onset((char_t*)method.c_str(),
                             buf_size, hop_size, samplerate);
+    aubio_onset_set_adaptive_whitening(onset, 0);
     if (onset) {
         threshold = aubio_onset_get_threshold(onset);
         ofLogNotice() << "created ofxAubioOnset(" << method