From: Paul Brossier Date: Fri, 4 Dec 2009 00:39:30 +0000 (+0100) Subject: src/temporal: switch to mono X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=741bdda6b26a37c6f58d02738d8b8221cb294542;p=aubio.git src/temporal: switch to mono --- diff --git a/src/temporal/a_weighting.c b/src/temporal/a_weighting.c index 96f5b51e..819d6f72 100644 --- a/src/temporal/a_weighting.c +++ b/src/temporal/a_weighting.c @@ -31,7 +31,7 @@ aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate) aubio_filter_set_samplerate (f, samplerate); lvec_t *bs = aubio_filter_get_feedforward (f); lvec_t *as = aubio_filter_get_feedback (f); - lsmp_t *b = bs->data[0], *a = as->data[0]; + lsmp_t *b = bs->data, *a = as->data; uint_t order = aubio_filter_get_order (f); if (order != 7) { @@ -240,9 +240,9 @@ aubio_filter_set_a_weighting (aubio_filter_t * f, uint_t samplerate) } aubio_filter_t * -new_aubio_filter_a_weighting (uint_t channels, uint_t samplerate) +new_aubio_filter_a_weighting (uint_t samplerate) { - aubio_filter_t *f = new_aubio_filter (7, channels); + aubio_filter_t *f = new_aubio_filter (7); aubio_filter_set_a_weighting (f, samplerate); return f; } diff --git a/src/temporal/a_weighting.h b/src/temporal/a_weighting.h index 9aa1f006..cf1a1cbf 100644 --- a/src/temporal/a_weighting.h +++ b/src/temporal/a_weighting.h @@ -60,7 +60,6 @@ extern "C" { /** create new A-design filter - \param channels number of channels to allocate \param samplerate sampling frequency of the signal to filter. Should be one of 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and 192000 Hz @@ -68,8 +67,7 @@ extern "C" { \return a new filter object */ -aubio_filter_t *new_aubio_filter_a_weighting (uint_t channels, - uint_t samplerate); +aubio_filter_t *new_aubio_filter_a_weighting (uint_t samplerate); /** set feedback and feedforward coefficients of a A-weighting filter diff --git a/src/temporal/biquad.c b/src/temporal/biquad.c index 97f41385..06001680 100644 --- a/src/temporal/biquad.c +++ b/src/temporal/biquad.c @@ -35,20 +35,19 @@ aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, lsmp_t b2, AUBIO_ERROR ("order of biquad filter must be 3, not %d\n", order); return AUBIO_FAIL; } - bs->data[0][0] = b0; - bs->data[0][1] = b1; - bs->data[0][2] = b2; - as->data[0][0] = 1.; - as->data[0][1] = a1; - as->data[0][1] = a2; + bs->data[0] = b0; + bs->data[1] = b1; + bs->data[2] = b2; + as->data[0] = 1.; + as->data[1] = a1; + as->data[1] = a2; return AUBIO_OK; } aubio_filter_t * -new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2, - uint_t channels) +new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2) { - aubio_filter_t *f = new_aubio_filter (3, channels); + aubio_filter_t *f = new_aubio_filter (3); aubio_filter_set_biquad (f, b0, b1, b2, a1, a2); return f; } diff --git a/src/temporal/biquad.h b/src/temporal/biquad.h index 5cf31fdd..b3004ac2 100644 --- a/src/temporal/biquad.h +++ b/src/temporal/biquad.h @@ -61,11 +61,10 @@ uint_t aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, \param b2 forward filter coefficient \param a1 feedback filter coefficient \param a2 feedback filter coefficient - \param channels number of channels to allocate */ aubio_filter_t *new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, - lsmp_t a1, lsmp_t a2, uint_t channels); + lsmp_t a1, lsmp_t a2); #ifdef __cplusplus } diff --git a/src/temporal/c_weighting.c b/src/temporal/c_weighting.c index 3ab36a4f..45c2894e 100644 --- a/src/temporal/c_weighting.c +++ b/src/temporal/c_weighting.c @@ -31,7 +31,7 @@ aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate) aubio_filter_set_samplerate (f, samplerate); lvec_t *bs = aubio_filter_get_feedforward (f); lvec_t *as = aubio_filter_get_feedback (f); - lsmp_t *b = bs->data[0], *a = as->data[0]; + lsmp_t *b = bs->data, *a = as->data; uint_t order = aubio_filter_get_order (f); if ( order != 5 ) { @@ -196,8 +196,8 @@ aubio_filter_set_c_weighting (aubio_filter_t * f, uint_t samplerate) return 0; } -aubio_filter_t * new_aubio_filter_c_weighting (uint_t channels, uint_t samplerate) { - aubio_filter_t * f = new_aubio_filter(5, channels); +aubio_filter_t * new_aubio_filter_c_weighting (uint_t samplerate) { + aubio_filter_t * f = new_aubio_filter(5); aubio_filter_set_c_weighting (f, samplerate); return f; } diff --git a/src/temporal/c_weighting.h b/src/temporal/c_weighting.h index 819fa0ad..c80cfc37 100644 --- a/src/temporal/c_weighting.h +++ b/src/temporal/c_weighting.h @@ -60,7 +60,6 @@ extern "C" { /** create new C-design filter - \param channels number of channels to allocate \param samplerate sampling frequency of the signal to filter. Should be one of 8000, 11025, 16000, 22050, 24000, 32000, 44100, 48000, 88200, 96000, and 192000 Hz @@ -68,8 +67,7 @@ extern "C" { \return a new filter object */ -aubio_filter_t *new_aubio_filter_c_weighting (uint_t channels, - uint_t samplerate); +aubio_filter_t *new_aubio_filter_c_weighting (uint_t samplerate); /** set feedback and feedforward coefficients of a C-weighting filter diff --git a/src/temporal/filter.c b/src/temporal/filter.c index 3c10f74b..0975e6f4 100644 --- a/src/temporal/filter.c +++ b/src/temporal/filter.c @@ -48,34 +48,27 @@ aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out) void aubio_filter_do (aubio_filter_t * f, fvec_t * in) { - uint_t i, j, l, order = f->order; - lsmp_t *x; - lsmp_t *y; - lsmp_t *a = f->a->data[0]; - lsmp_t *b = f->b->data[0]; - - for (i = 0; i < in->channels; i++) { - x = f->x->data[i]; - y = f->y->data[i]; - for (j = 0; j < in->length; j++) { - /* new input */ - x[0] = KILL_DENORMAL (in->data[i][j]); - y[0] = b[0] * x[0]; - for (l = 1; l < order; l++) { - y[0] += b[l] * x[l]; - y[0] -= a[l] * y[l]; - } - /* new output */ - in->data[i][j] = y[0]; - /* store for next sample */ - for (l = order - 1; l > 0; l--) { - x[l] = x[l - 1]; - y[l] = y[l - 1]; - } + uint_t j, l, order = f->order; + lsmp_t *x = f->x->data; + lsmp_t *y = f->y->data; + lsmp_t *a = f->a->data; + lsmp_t *b = f->b->data; + + for (j = 0; j < in->length; j++) { + /* new input */ + x[0] = KILL_DENORMAL (in->data[j]); + y[0] = b[0] * x[0]; + for (l = 1; l < order; l++) { + y[0] += b[l] * x[l]; + y[0] -= a[l] * y[l]; + } + /* new output */ + in->data[j] = y[0]; + /* store for next sample */ + for (l = order - 1; l > 0; l--) { + x[l] = x[l - 1]; + y[l] = y[l - 1]; } - /* store for next run */ - f->x->data[i] = x; - f->y->data[i] = y; } } @@ -83,20 +76,20 @@ aubio_filter_do (aubio_filter_t * f, fvec_t * in) void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp) { - uint_t j, i = 0; + uint_t j; uint_t length = in->length; /* apply filtering */ aubio_filter_do (f, in); aubio_filter_do_reset (f); /* mirror */ for (j = 0; j < length; j++) - tmp->data[i][length - j - 1] = in->data[i][j]; + tmp->data[length - j - 1] = in->data[j]; /* apply filtering on mirrored */ aubio_filter_do (f, tmp); aubio_filter_do_reset (f); /* invert back */ for (j = 0; j < length; j++) - in->data[i][j] = tmp->data[i][length - j - 1]; + in->data[j] = tmp->data[length - j - 1]; } lvec_t * @@ -138,18 +131,18 @@ aubio_filter_do_reset (aubio_filter_t * f) } aubio_filter_t * -new_aubio_filter (uint_t order, uint_t channels) +new_aubio_filter (uint_t order) { aubio_filter_t *f = AUBIO_NEW (aubio_filter_t); - f->x = new_lvec (order, channels); - f->y = new_lvec (order, channels); - f->a = new_lvec (order, 1); - f->b = new_lvec (order, 1); + f->x = new_lvec (order); + f->y = new_lvec (order); + f->a = new_lvec (order); + f->b = new_lvec (order); /* by default, samplerate is not set */ f->samplerate = 0; f->order = order; /* set default to identity */ - f->a->data[0][1] = 1.; + f->a->data[1] = 1.; return f; } diff --git a/src/temporal/filter.h b/src/temporal/filter.h index 396e9615..5d151fff 100644 --- a/src/temporal/filter.h +++ b/src/temporal/filter.h @@ -25,7 +25,7 @@ Digital filter - This object stores a digital filter of order \f$n\f$ for \f$c\f$ channels. + This object stores a digital filter of order \f$n\f$. It contains the following data: - \f$ n*1 b_i \f$ feedforward coefficients - \f$ n*1 a_i \f$ feedback coefficients @@ -150,16 +150,15 @@ void aubio_filter_do_reset (aubio_filter_t * f); /** create new filter object - This function creates a new ::aubio_filter_t object, given an order - and a specific number of channels. + This function creates a new ::aubio_filter_t object, given the order of the + filter. \param order order of the filter (number of coefficients) - \param channels number of channels to allocate \return the newly created filter object */ -aubio_filter_t *new_aubio_filter (uint_t order, uint_t channels); +aubio_filter_t *new_aubio_filter (uint_t order); /** delete a filter object diff --git a/src/temporal/resampler.c b/src/temporal/resampler.c index 35565189..21fe5af2 100644 --- a/src/temporal/resampler.c +++ b/src/temporal/resampler.c @@ -60,17 +60,14 @@ del_aubio_resampler (aubio_resampler_t * s) void aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output) { - uint_t i; s->proc->input_frames = input->length; s->proc->output_frames = output->length; s->proc->src_ratio = (double) s->ratio; - for (i = 0; i < input->channels; i++) { - /* make SRC_PROC data point to input outputs */ - s->proc->data_in = (float *) input->data[i]; - s->proc->data_out = (float *) output->data[i]; - /* do resampling */ - src_process (s->stat, s->proc); - } + /* make SRC_PROC data point to input outputs */ + s->proc->data_in = (float *) input->data; + s->proc->data_out = (float *) output->data; + /* do resampling */ + src_process (s->stat, s->proc); } #else @@ -86,12 +83,12 @@ new_aubio_resampler (smpl_t ratio UNUSED, uint_t type UNUSED) } void -del_aubio_resampler (aubio_resampler_t * s) +del_aubio_resampler (aubio_resampler_t * s UNUSED) { } void -aubio_resampler_do (aubio_resampler_t * s, fvec_t * input, fvec_t * output) +aubio_resampler_do (aubio_resampler_t * s UNUSED, fvec_t * input UNUSED, fvec_t * output UNUSED) { } #endif /* HAVE_SAMPLERATE */