ref: dd474317079df5628ff6f5a4d70dad61368720d1
parent: 0056314d0da7aaf92c62ba7b34c7d28ac3cde553
parent: ed80243aefbb12d789fde6fb1bb4312c3d92867b
author: Paul Brossier <piem@piem.org>
date: Thu Dec 6 08:49:25 EST 2018
Merge branch 'fix/awhitening'
--- a/src/spectral/awhitening.c
+++ b/src/spectral/awhitening.c
@@ -43,7 +43,8 @@
aubio_spectral_whitening_do (aubio_spectral_whitening_t * o, cvec_t * fftgrain)
{
uint_t i = 0;
- for (i = 0; i < o->peak_values->length; i++) {
+ uint_t length = MIN(fftgrain->length, o->peak_values->length);
+ for (i = 0; i < length; i++) {
smpl_t tmp = MAX(o->r_decay * o->peak_values->data[i], o->floor);
o->peak_values->data[i] = MAX(fftgrain->norm[i], tmp);
fftgrain->norm[i] /= o->peak_values->data[i];
--- a/tests/src/spectral/test-awhitening.c
+++ b/tests/src/spectral/test-awhitening.c
@@ -41,9 +41,11 @@
if (!o) { err = 1; goto beach_sink; }
aubio_pvoc_t *pv = new_aubio_pvoc(win_size, hop_size);
+ if (!pv) { err = 1; goto beach_pvoc; }
aubio_spectral_whitening_t *awhitening =
new_aubio_spectral_whitening (win_size, hop_size, samplerate);
+ if (!awhitening) { err = 1; goto beach_awhitening; }
aubio_spectral_whitening_set_relax_time(awhitening, 20.);
fvec_set_all(scale, 3.);
@@ -71,11 +73,18 @@
n_frames, samplerate, n_frames / hop_size,
source_path, sink_path);
+ del_aubio_spectral_whitening(awhitening);
+beach_awhitening:
+ del_aubio_pvoc(pv);
+beach_pvoc:
del_aubio_sink(o);
beach_sink:
del_aubio_source(i);
beach_source:
del_fvec(vec);
+ del_fvec(out);
+ del_fvec(scale);
+ del_cvec(fftgrain);
beach_fvec:
return err;
}