From d84d19ef7188d77eaa5dfd53e84b912c04fd0858 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 25 Sep 2009 04:20:27 +0200 Subject: [PATCH] src/mathutils.{c,h}: change prototype from aubio_window to new_aubio_window, allocating an fvec, use new function everywhere --- src/mathutils.c | 6 +++++- src/mathutils.h | 2 +- src/pitch/pitchfcomb.c | 3 +-- src/pitch/pitchyinfft.c | 3 +-- src/spectral/phasevoc.c | 9 ++++----- swig/aubio.i | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/mathutils.c b/src/mathutils.c index d39cd6f7..92e93ff8 100644 --- a/src/mathutils.c +++ b/src/mathutils.c @@ -24,7 +24,10 @@ #include "mathutils.h" #include "config.h" -void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype) { +fvec_t * new_aubio_window(uint_t size, aubio_window_type wintype) { + // create fvec of size x 1 channel + fvec_t * win = new_fvec( size, 1); + smpl_t * w = win->data[0]; uint_t i; switch(wintype) { case aubio_win_rectangle: @@ -71,6 +74,7 @@ void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype) { default: break; } + return win; } smpl_t aubio_unwrap2pi(smpl_t phase) { diff --git a/src/mathutils.h b/src/mathutils.h index 6e51586d..54c21b43 100644 --- a/src/mathutils.h +++ b/src/mathutils.h @@ -55,7 +55,7 @@ typedef enum { } aubio_window_type; /** create window */ -void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype); +fvec_t * new_aubio_window(uint_t size, aubio_window_type wintype); /** principal argument * diff --git a/src/pitch/pitchfcomb.c b/src/pitch/pitchfcomb.c index 92d60f23..45a5a1a4 100644 --- a/src/pitch/pitchfcomb.c +++ b/src/pitch/pitchfcomb.c @@ -53,8 +53,7 @@ aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize, uint_ p->fftOut = new_cvec(bufsize,1); p->fftLastPhase = new_fvec(bufsize,1); p->fft = new_aubio_fft(bufsize, 1); - p->win = new_fvec(bufsize,1); - aubio_window(p->win->data[0], bufsize, aubio_win_hanning); + p->win = new_aubio_window(bufsize, aubio_win_hanning); return p; } diff --git a/src/pitch/pitchyinfft.c b/src/pitch/pitchyinfft.c index b8c18e02..862a4837 100644 --- a/src/pitch/pitchyinfft.c +++ b/src/pitch/pitchyinfft.c @@ -54,8 +54,7 @@ aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t bufsize) p->sqrmag = new_fvec(bufsize,1); p->res = new_cvec(bufsize,1); p->yinfft = new_fvec(bufsize/2+1,1); - p->win = new_fvec(bufsize,1); - aubio_window(p->win->data[0], bufsize, aubio_win_hanningz); + p->win = new_aubio_window(bufsize, aubio_win_hanningz); p->weight = new_fvec(bufsize/2+1,1); { uint_t i = 0, j = 1; diff --git a/src/spectral/phasevoc.c b/src/spectral/phasevoc.c index 08019519..486ad679 100644 --- a/src/spectral/phasevoc.c +++ b/src/spectral/phasevoc.c @@ -34,7 +34,7 @@ struct _aubio_pvoc_t { fvec_t * synthold; /** last input frame [win_s-hop_s] */ fvec_t * data; /** current input grain [win_s] */ fvec_t * dataold; /** last input frame [win_s-hop_s] */ - smpl_t * w; /** grain window [win_s] */ + fvec_t * w; /** grain window [win_s] */ }; @@ -53,7 +53,7 @@ void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) { aubio_pvoc_swapbuffers(pv->data->data[i],pv->dataold->data[i], datanew->data[i],pv->win_s,pv->hop_s); /* windowing */ - for (j=0; jwin_s; j++) pv->data->data[i][j] *= pv->w[j]; + fvec_weight(pv->data, pv->w); } /* shift */ vec_shift(pv->data); @@ -95,8 +95,7 @@ aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) { /* new input output */ pv->dataold = new_fvec (win_s-hop_s, channels); pv->synthold = new_fvec (win_s-hop_s, channels); - pv->w = AUBIO_ARRAY(smpl_t,win_s); - aubio_window(pv->w,win_s,aubio_win_hanningz); + pv->w = new_aubio_window (win_s, aubio_win_hanningz); pv->channels = channels; pv->hop_s = hop_s; @@ -110,8 +109,8 @@ void del_aubio_pvoc(aubio_pvoc_t *pv) { del_fvec(pv->synth); del_fvec(pv->dataold); del_fvec(pv->synthold); + del_fvec(pv->w); del_aubio_fft(pv->fft); - AUBIO_FREE(pv->w); AUBIO_FREE(pv); } diff --git a/swig/aubio.i b/swig/aubio.i index 261c4afe..0234f080 100644 --- a/swig/aubio.i +++ b/swig/aubio.i @@ -127,7 +127,7 @@ typedef enum { aubio_win_parzen } aubio_window_type; -void aubio_window(smpl_t *w, uint_t size, aubio_window_type wintype); +fvec_t * new_aubio_window(uint_t size, aubio_window_type wintype); smpl_t aubio_unwrap2pi (smpl_t phase); smpl_t vec_mean(fvec_t *s); smpl_t vec_max(fvec_t *s); -- 2.26.2