From a54502c646d42b0ff301bdbcce6618113dc0f796 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 29 Sep 2009 20:08:10 +0200 Subject: [PATCH] src/temporal/filter.{c,h}: indent, update copyright and license --- src/temporal/filter.c | 105 ++++++++++++++++++++++++------------------ src/temporal/filter.h | 44 +++++++++--------- 2 files changed, 84 insertions(+), 65 deletions(-) diff --git a/src/temporal/filter.c b/src/temporal/filter.c index 9368303a..6e3e3af3 100644 --- a/src/temporal/filter.c +++ b/src/temporal/filter.c @@ -1,19 +1,20 @@ /* - Copyright (C) 2003 Paul Brossier + Copyright (C) 2003-2009 Paul Brossier - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This file is part of aubio. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + aubio is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + aubio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with aubio. If not, see . */ @@ -27,22 +28,27 @@ #include "mathutils.h" #include "temporal/filter.h" -struct _aubio_filter_t { +struct _aubio_filter_t +{ uint_t order; uint_t samplerate; - lvec_t * a; - lvec_t * b; - lvec_t * y; - lvec_t * x; + lvec_t *a; + lvec_t *b; + lvec_t *y; + lvec_t *x; }; -void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) { - fvec_copy(in, out); +void +aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out) +{ + fvec_copy (in, out); aubio_filter_do (f, out); } -void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { - uint_t i,j,l, order = f->order; +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]; @@ -53,18 +59,18 @@ void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { y = f->y->data[i]; for (j = 0; j < in->length; j++) { /* new input */ - x[0] = KILL_DENORMAL(in->data[i][j]); + x[0] = KILL_DENORMAL (in->data[i][j]); y[0] = b[0] * x[0]; - for (l=1;ldata[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]; + for (l = order - 1; l > 0; l--) { + x[l] = x[l - 1]; + y[l] = y[l - 1]; } } /* store for next run */ @@ -107,41 +113,52 @@ void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp) { in->data[i][j] = tmp->data[i][length-j-1]; } -lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f ) { +lvec_t * +aubio_filter_get_feedback (aubio_filter_t * f) +{ return f->a; } -lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f ) { +lvec_t * +aubio_filter_get_feedforward (aubio_filter_t * f) +{ return f->b; } -uint_t aubio_filter_get_order ( aubio_filter_t *f ) { +uint_t +aubio_filter_get_order (aubio_filter_t * f) +{ return f->order; } -uint_t aubio_filter_get_samplerate ( aubio_filter_t *f ) { +uint_t +aubio_filter_get_samplerate (aubio_filter_t * f) +{ return f->samplerate; } -aubio_filter_t * new_aubio_filter(uint_t samplerate, - uint_t order, uint_t channels) { - 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->samplerate = samplerate; +aubio_filter_t * +new_aubio_filter (uint_t samplerate, uint_t order, uint_t channels) +{ + 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->samplerate = samplerate; f->order = order; /* set default to identity */ f->a->data[0][1] = 1.; return f; } -void del_aubio_filter(aubio_filter_t * f) { - del_lvec(f->a); - del_lvec(f->b); - del_lvec(f->x); - del_lvec(f->y); - AUBIO_FREE(f); +void +del_aubio_filter (aubio_filter_t * f) +{ + del_lvec (f->a); + del_lvec (f->b); + del_lvec (f->x); + del_lvec (f->y); + AUBIO_FREE (f); return; } diff --git a/src/temporal/filter.h b/src/temporal/filter.h index 2cdbd5ea..4d756788 100644 --- a/src/temporal/filter.h +++ b/src/temporal/filter.h @@ -1,19 +1,20 @@ /* - Copyright (C) 2003 Paul Brossier + Copyright (C) 2003-2009 Paul Brossier - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. + This file is part of aubio. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + aubio is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + aubio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with aubio. If not, see . */ @@ -72,7 +73,7 @@ typedef struct _aubio_filter_t aubio_filter_t; \param in input vector to filter */ -void aubio_filter_do(aubio_filter_t * f, fvec_t * in); +void aubio_filter_do (aubio_filter_t * f, fvec_t * in); /** filter input vector (out-of-place) @@ -81,7 +82,7 @@ void aubio_filter_do(aubio_filter_t * f, fvec_t * in); \param out output vector to store filtered input */ -void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out); +void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out); /** filter input vector forward and backward @@ -90,7 +91,7 @@ void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out); \param tmp memory space to use for computation */ -void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp); +void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp); /** returns a pointer to feedback coefficients \f$ a_i \f$ @@ -99,7 +100,7 @@ void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp); \return a pointer to the \f$ a_0 ... a_i ... a_P \f$ coefficients */ -lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f ); +lvec_t *aubio_filter_get_feedback (aubio_filter_t * f); /** returns a pointer to feedforward coefficients \f$ b_i \f$ @@ -108,7 +109,7 @@ lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f ); \return a pointer to the \f$ b_0 ... b_i ... b_P \f$ coefficients */ -lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f ); +lvec_t *aubio_filter_get_feedforward (aubio_filter_t * f); /** get order of the filter @@ -117,7 +118,7 @@ lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f ); \return the order of the filter */ -uint_t aubio_filter_get_order ( aubio_filter_t *f ); +uint_t aubio_filter_get_order (aubio_filter_t * f); /** get sampling rate of the filter @@ -126,7 +127,7 @@ uint_t aubio_filter_get_order ( aubio_filter_t *f ); \return the sampling rate of the filter, in Hz */ -uint_t aubio_filter_get_samplerate ( aubio_filter_t *f ); +uint_t aubio_filter_get_samplerate (aubio_filter_t * f); /** create new filter object @@ -140,14 +141,15 @@ uint_t aubio_filter_get_samplerate ( aubio_filter_t *f ); \return the newly created filter object */ -aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels); +aubio_filter_t *new_aubio_filter (uint_t samplerate, uint_t order, + uint_t channels); /** delete a filter object \param f filter object to delete */ -void del_aubio_filter(aubio_filter_t * f); +void del_aubio_filter (aubio_filter_t * f); #ifdef __cplusplus } -- 2.26.2