From: Paul Brossier Date: Thu, 21 Jan 2016 08:09:55 +0000 (+0100) Subject: src/ofxAubio.h: add filter detect X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=8056c01ec96fe35c8896033e74890aa8baa64d2a;p=ofxAubio.git src/ofxAubio.h: add filter detect --- diff --git a/src/ofxAubio.h b/src/ofxAubio.h index 061eb45..d2dcce8 100644 --- a/src/ofxAubio.h +++ b/src/ofxAubio.h @@ -23,3 +23,4 @@ #include "ofxAubioPitch.h" #include "ofxAubioMelBands.h" #include "ofxAubioAttackClass.h" +#include "ofxAubioFilterDetect.h" diff --git a/src/ofxAubioAttackClass.cpp b/src/ofxAubioAttackClass.cpp index 40a8201..866d30c 100644 --- a/src/ofxAubioAttackClass.cpp +++ b/src/ofxAubioAttackClass.cpp @@ -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; } diff --git a/src/ofxAubioBeat.cpp b/src/ofxAubioBeat.cpp index ce5ed36..da25220 100644 --- a/src/ofxAubioBeat.cpp +++ b/src/ofxAubioBeat.cpp @@ -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 diff --git a/src/ofxAubioMelBands.cpp b/src/ofxAubioMelBands.cpp index fecb455..fda5184 100644 --- a/src/ofxAubioMelBands.cpp +++ b/src/ofxAubioMelBands.cpp @@ -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); } diff --git a/src/ofxAubioMelBands.h b/src/ofxAubioMelBands.h index c04f62f..a94701a 100644 --- a/src/ofxAubioMelBands.h +++ b/src/ofxAubioMelBands.h @@ -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; }; diff --git a/src/ofxAubioOnset.cpp b/src/ofxAubioOnset.cpp index 06f32a6..086a3e1 100644 --- a/src/ofxAubioOnset.cpp +++ b/src/ofxAubioOnset.cpp @@ -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