From: Paul Brossier Date: Sat, 1 Dec 2007 20:53:24 +0000 (+0100) Subject: src/temporal: split aubio_adsgn_filter and aubio_cdsgn_filter to separate files X-Git-Tag: bzr2git~417 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4f4d8921ee806330834f5f24126f758b26817b9b;p=aubio.git src/temporal: split aubio_adsgn_filter and aubio_cdsgn_filter to separate files --- diff --git a/src/Makefile.am b/src/Makefile.am index f6461a65..a26495a9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,7 @@ -noinst_HEADERS = aubio_priv.h +noinst_HEADERS = \ + aubio_priv.h \ + temporal/filter_priv.h + pkginclude_HEADERS = aubio.h \ types.h \ fvec.h \ @@ -19,7 +22,9 @@ pkgincludeutils_HEADERS = \ pkgincludetemporal_HEADERS = \ temporal/resample.h \ temporal/biquad.h \ - temporal/filter.h + temporal/filter.h \ + temporal/adesign.h \ + temporal/cdesign.h pkgincludespectral_HEADERS = \ spectral/filterbank.h \ @@ -56,6 +61,8 @@ libaubio_la_SOURCES = \ temporal/resample.c \ temporal/biquad.c \ temporal/filter.c \ + temporal/adesign.c \ + temporal/cdesign.c \ spectral/filterbank.c \ spectral/mfcc.c \ spectral/phasevoc.c \ diff --git a/src/temporal/adesign.c b/src/temporal/adesign.c new file mode 100644 index 00000000..a06cddae --- /dev/null +++ b/src/temporal/adesign.c @@ -0,0 +1,58 @@ +/* + Copyright (C) 2003-2007 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 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. + + 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. + +*/ + + +#include "aubio_priv.h" +#include "types.h" +#include "fvec.h" +#include "temporal/filter.h" +#include "temporal/filter_priv.h" +#include "temporal/adesign.h" + +aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate) { + aubio_filter_t * f = new_aubio_filter(samplerate, 7); + lsmp_t * a = f->a; + lsmp_t * b = f->b; + /* uint_t l; */ + /* for now, 44100, adsgn */ + a[0] = 1.00000000000000000000000000000000000000000000000000000; + a[1] = -4.01957618111583236952810693765059113502502441406250000; + a[2] = 6.18940644292069386267485242569819092750549316406250000; + a[3] = -4.45319890354411640487342083360999822616577148437500000; + a[4] = 1.42084294962187751565352300531230866909027099609375000; + a[5] = -0.14182547383030480458998567883099894970655441284179688; + a[6] = 0.00435117723349511334451911181986361043527722358703613; + b[0] = 0.25574112520425740235907596797915175557136535644531250; + b[1] = -0.51148225040851391653973223583307117223739624023437500; + b[2] = -0.25574112520426162120656954357400536537170410156250000; + b[3] = 1.02296450081703405032840237254276871681213378906250000; + b[4] = -0.25574112520426051098354491841746494174003601074218750; + b[5] = -0.51148225040851369449512731080176308751106262207031250; + b[6] = 0.25574112520425729133677350546349771320819854736328125; + /* DBG: filter coeffs at creation time */ + /* + for (l=0; lorder; l++){ + AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); + } + */ + f->a = a; + f->b = b; + return f; +} + diff --git a/src/temporal/adesign.h b/src/temporal/adesign.h new file mode 100644 index 00000000..2d8150b8 --- /dev/null +++ b/src/temporal/adesign.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2003-2007 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 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. + + 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. + +*/ + +/** create a new A-design filter + + \param samplerate sampling-rate of the signal to filter + +*/ +aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate); + +#define aubio_adsgn_filter_do aubio_filter_do +#define del_aubio_adsgn_filter del_aubio_filter diff --git a/src/temporal/cdesign.c b/src/temporal/cdesign.c new file mode 100644 index 00000000..84d89edf --- /dev/null +++ b/src/temporal/cdesign.c @@ -0,0 +1,54 @@ +/* + Copyright (C) 2003-2007 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 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. + + 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. + +*/ + + +#include "aubio_priv.h" +#include "types.h" +#include "fvec.h" +#include "temporal/filter.h" +#include "temporal/filter_priv.h" +#include "temporal/adesign.h" + +aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate) { + aubio_filter_t * f = new_aubio_filter(samplerate, 5); + lsmp_t * a = f->a; + lsmp_t * b = f->b; + /* uint_t l; */ + /* for now, 44100, cdsgn */ + a[0] = 1.000000000000000000000000000000000000000000000000000000000000; + a[1] = -2.134674963687040794013682898366823792457580566406250000000000; + a[2] = 1.279333533236063358273781886964570730924606323242187500000000; + a[3] = -0.149559846089396208945743182994192466139793395996093750000000; + a[4] = 0.004908700174624848651394604104325480875559151172637939453125; + b[0] = 0.217008561949218803377448239189106971025466918945312500000000; + b[1] = -0.000000000000000222044604925031308084726333618164062500000000; + b[2] = -0.434017123898438272888711253472138196229934692382812500000000; + b[3] = 0.000000000000000402455846426619245903566479682922363281250000; + b[4] = 0.217008561949218969910901932962588034570217132568359375000000; + /* DBG: filter coeffs at creation time */ + /* + for (l=0; lorder; l++){ + AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); + } + */ + f->a = a; + f->b = b; + return f; +} + diff --git a/src/temporal/cdesign.h b/src/temporal/cdesign.h new file mode 100644 index 00000000..3e869132 --- /dev/null +++ b/src/temporal/cdesign.h @@ -0,0 +1,30 @@ +/* + Copyright (C) 2003-2007 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 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. + + 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. + +*/ + +#include "temporal/filter.h" + +/** create a new C-design filter + + \param samplerate sampling-rate of the signal to filter + +*/ +aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate); + +#define aubio_cdsgn_filter_do aubio_filter_do +#define del_aubio_cdsgn_filter del_aubio_filter diff --git a/src/temporal/filter.c b/src/temporal/filter.c index 7f2349bd..8e1726d2 100644 --- a/src/temporal/filter.c +++ b/src/temporal/filter.c @@ -25,14 +25,7 @@ #include "fvec.h" #include "mathutils.h" #include "temporal/filter.h" - -struct _aubio_filter_t { - uint_t order; - lsmp_t * a; - lsmp_t * b; - lsmp_t * y; - lsmp_t * x; -}; +#include "temporal/filter_priv.h" /* bug: mono only */ void aubio_filter_do(aubio_filter_t * f, fvec_t * in) { @@ -132,65 +125,6 @@ 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]; } - -aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate) { - aubio_filter_t * f = new_aubio_filter(samplerate, 7); - lsmp_t * a = f->a; - lsmp_t * b = f->b; - /* uint_t l; */ - /* for now, 44100, adsgn */ - a[0] = 1.00000000000000000000000000000000000000000000000000000; - a[1] = -4.01957618111583236952810693765059113502502441406250000; - a[2] = 6.18940644292069386267485242569819092750549316406250000; - a[3] = -4.45319890354411640487342083360999822616577148437500000; - a[4] = 1.42084294962187751565352300531230866909027099609375000; - a[5] = -0.14182547383030480458998567883099894970655441284179688; - a[6] = 0.00435117723349511334451911181986361043527722358703613; - b[0] = 0.25574112520425740235907596797915175557136535644531250; - b[1] = -0.51148225040851391653973223583307117223739624023437500; - b[2] = -0.25574112520426162120656954357400536537170410156250000; - b[3] = 1.02296450081703405032840237254276871681213378906250000; - b[4] = -0.25574112520426051098354491841746494174003601074218750; - b[5] = -0.51148225040851369449512731080176308751106262207031250; - b[6] = 0.25574112520425729133677350546349771320819854736328125; - /* DBG: filter coeffs at creation time */ - /* - for (l=0; lorder; l++){ - AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); - } - */ - f->a = a; - f->b = b; - return f; -} - -aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate) { - aubio_filter_t * f = new_aubio_filter(samplerate, 5); - lsmp_t * a = f->a; - lsmp_t * b = f->b; - /* uint_t l; */ - /* for now, 44100, cdsgn */ - a[0] = 1.000000000000000000000000000000000000000000000000000000000000; - a[1] = -2.134674963687040794013682898366823792457580566406250000000000; - a[2] = 1.279333533236063358273781886964570730924606323242187500000000; - a[3] = -0.149559846089396208945743182994192466139793395996093750000000; - a[4] = 0.004908700174624848651394604104325480875559151172637939453125; - b[0] = 0.217008561949218803377448239189106971025466918945312500000000; - b[1] = -0.000000000000000222044604925031308084726333618164062500000000; - b[2] = -0.434017123898438272888711253472138196229934692382812500000000; - b[3] = 0.000000000000000402455846426619245903566479682922363281250000; - b[4] = 0.217008561949218969910901932962588034570217132568359375000000; - /* DBG: filter coeffs at creation time */ - /* - for (l=0; lorder; l++){ - AUBIO_DBG("a[%d]=\t%1.16f\tb[%d]=\t%1.16f\n",l,a[l],l,b[l]); - } - */ - f->a = a; - f->b = b; - return f; -} - aubio_filter_t * new_aubio_filter(uint_t samplerate UNUSED, uint_t order) { aubio_filter_t * f = AUBIO_NEW(aubio_filter_t); lsmp_t * x = f->x; diff --git a/src/temporal/filter.h b/src/temporal/filter.h index 1b0adab4..7567d418 100644 --- a/src/temporal/filter.h +++ b/src/temporal/filter.h @@ -71,18 +71,6 @@ void aubio_filter_do_filtfilt(aubio_filter_t * b, fvec_t * in, fvec_t * tmp); */ aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order); -/** create a new A-design filter - - \param samplerate sampling-rate of the signal to filter - -*/ -aubio_filter_t * new_aubio_adsgn_filter(uint_t samplerate); -/** create a new C-design filter - - \param samplerate sampling-rate of the signal to filter - -*/ -aubio_filter_t * new_aubio_cdsgn_filter(uint_t samplerate); /** delete a filter object \param f filter object to delete diff --git a/src/temporal/filter_priv.h b/src/temporal/filter_priv.h new file mode 100644 index 00000000..816515c2 --- /dev/null +++ b/src/temporal/filter_priv.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2003-2008 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 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. + + 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. + +*/ + +struct _aubio_filter_t { + uint_t order; + lsmp_t * a; + lsmp_t * b; + lsmp_t * y; + lsmp_t * x; +}; + +