From fabb7cd7c6c58dd5a5b74c64198252d8ddcc3583 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 21 Nov 2007 12:01:22 +0100 Subject: [PATCH] onsetdection.{c,h}: add spectral flux (L2 norm, only energy increases) --- src/onsetdetection.c | 17 +++++++++++++++++ src/onsetdetection.h | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/onsetdetection.c b/src/onsetdetection.c index de3ab7bd..b6ca0355 100644 --- a/src/onsetdetection.c +++ b/src/onsetdetection.c @@ -195,6 +195,19 @@ void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec } } +/* Spectral flux */ +void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset){ + uint_t i, j; + for (i=0;ichannels;i++) { + onset->data[i][0] = 0.; + for (j=0;jlength;j++) { + if (fftgrain->norm[i][j] > o->oldmag->data[i][j]) + onset->data[i][0] += fftgrain->norm[i][j] - o->oldmag->data[i][j]; + o->oldmag->data[i][j] = fftgrain->norm[i][j]; + } + } +} + /* Generic function pointing to the choosen one */ void aubio_onsetdetection(aubio_onsetdetection_t *o, cvec_t * fftgrain, @@ -242,6 +255,7 @@ new_aubio_onsetdetection (aubio_onsetdetection_type type, break; case aubio_onset_kl: case aubio_onset_mkl: + case aubio_onset_specflux: o->oldmag = new_fvec(rsize,channels); break; default: @@ -274,6 +288,9 @@ new_aubio_onsetdetection (aubio_onsetdetection_type type, case aubio_onset_mkl: o->funcpointer = aubio_onsetdetection_mkl; break; + case aubio_onset_specflux: + o->funcpointer = aubio_onsetdetection_specflux; + break; default: break; } diff --git a/src/onsetdetection.h b/src/onsetdetection.h index 0034bfeb..ba1c1329 100644 --- a/src/onsetdetection.h +++ b/src/onsetdetection.h @@ -47,6 +47,7 @@ typedef enum { aubio_onset_phase, /**< phase fast */ aubio_onset_kl, /**< Kullback Liebler */ aubio_onset_mkl, /**< modified Kullback Liebler */ + aubio_onset_specflux, /**< spectral flux */ } aubio_onsetdetection_type; /** onsetdetection structure */ @@ -136,6 +137,18 @@ void aubio_onsetdetection_kl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_ */ void aubio_onsetdetection_mkl(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); +/** Spectral Flux + + Simon Dixon, Onset Detection Revisited, in ``Proceedings of the 9th + International Conference on Digital Audio Effects'' (DAFx-06), Montreal, + Canada, 2006. + + \param o onset detection object as returned by new_aubio_onsetdetection() + \param fftgrain input spectral frame + \param onset output onset detection function + +*/ +void aubio_onsetdetection_specflux(aubio_onsetdetection_t *o, cvec_t * fftgrain, fvec_t * onset); /** execute onset detection function on a spectral frame Generic function to compute onset detection. -- 2.26.2