ref: c23e59160fc0ad02ec2cb76fa5938f452887f468
parent: 90e25cc760d412b373a8830e3df8ce4ce6e59a2b
author: Paul Brossier <[email protected]>
date: Fri Mar 10 23:57:49 EST 2017
src/spectral/specdesc.c: add weighted phase deviation
--- a/src/spectral/specdesc.c
+++ b/src/spectral/specdesc.c
@@ -30,6 +30,7 @@
void aubio_specdesc_hfc(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
void aubio_specdesc_complex(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
void aubio_specdesc_phase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
+void aubio_specdesc_wphase(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
void aubio_specdesc_specdiff(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
void aubio_specdesc_kl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
void aubio_specdesc_mkl(aubio_specdesc_t *o, const cvec_t * fftgrain, fvec_t * onset);
@@ -57,6 +58,7 @@
aubio_onset_hfc, /**< high frequency content */
aubio_onset_complex, /**< complex domain */
aubio_onset_phase, /**< phase fast */
+ aubio_onset_wphase, /**< weighted phase */
aubio_onset_kl, /**< Kullback Liebler */
aubio_onset_mkl, /**< modified Kullback Liebler */
aubio_onset_specflux, /**< spectral flux */
@@ -159,6 +161,23 @@
//onset->data[0] = fvec_mean(o->dev1);
}
+/* weighted phase */
+void
+aubio_specdesc_wphase(aubio_specdesc_t *o,
+ const cvec_t *fftgrain, fvec_t *onset) {
+ uint_t i;
+ aubio_specdesc_phase(o, fftgrain, onset);
+ for (i = 0; i < fftgrain->length; i++) {
+ o->dev1->data[i] *= fftgrain->norm[i];
+ }
+ /* apply o->histogram */
+ aubio_hist_dyn_notnull(o->histog,o->dev1);
+ /* weight it */
+ aubio_hist_weight(o->histog);
+ /* its mean is the result */
+ onset->data[0] = aubio_hist_mean(o->histog);
+}
+
/* Spectral difference method onset detection function */
void aubio_specdesc_specdiff(aubio_specdesc_t *o,
const cvec_t * fftgrain, fvec_t * onset){
@@ -250,6 +269,8 @@
onset_type = aubio_onset_complex;
else if (strcmp (onset_mode, "phase") == 0)
onset_type = aubio_onset_phase;
+ else if (strcmp (onset_mode, "wphase") == 0)
+ onset_type = aubio_onset_wphase;
else if (strcmp (onset_mode, "mkl") == 0)
onset_type = aubio_onset_mkl;
else if (strcmp (onset_mode, "kl") == 0)
@@ -291,6 +312,7 @@
o->theta2 = new_fvec(rsize);
break;
case aubio_onset_phase:
+ case aubio_onset_wphase:
o->dev1 = new_fvec(rsize);
o->theta1 = new_fvec(rsize);
o->theta2 = new_fvec(rsize);
@@ -325,6 +347,9 @@
case aubio_onset_phase:
o->funcpointer = aubio_specdesc_phase;
break;
+ case aubio_onset_wphase:
+ o->funcpointer = aubio_specdesc_wphase;
+ break;
case aubio_onset_specdiff:
o->funcpointer = aubio_specdesc_specdiff;
break;
@@ -378,6 +403,7 @@
del_fvec(o->theta2);
break;
case aubio_onset_phase:
+ case aubio_onset_wphase:
del_fvec(o->dev1);
del_fvec(o->theta1);
del_fvec(o->theta2);
--- a/src/spectral/specdesc.h
+++ b/src/spectral/specdesc.h
@@ -59,6 +59,13 @@
Conference on Acoustics Speech and Signal Processing, pages 441444,
Hong-Kong, 2003.
+ \b \p wphase : Weighted Phase Deviation onset detection function
+
+ S. Dixon. Onset detection revisited. In Proceedings of the 9th International
+ Conference on Digital Audio Ef- fects (DAFx) , pages 133–137, 2006.
+
+ http://www.eecs.qmul.ac.uk/~simond/pub/2006/dafx.pdf
+
\b \p specdiff : Spectral difference method onset detection function
Jonhatan Foote and Shingo Uchihashi. The beat spectrum: a new approach to