2 Copyright (C) 2007-2009 Paul Brossier <piem@aubio.org>
3 and Amaury Hazan <ahazan@iua.upf.edu>
5 This file is part of aubio.
7 aubio is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 aubio is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with aubio. If not, see <http://www.gnu.org/licenses/>.
22 #include "aubio_priv.h"
27 #include "spectral/filterbank.h"
28 #include "mathutils.h"
30 /** \brief A structure to store a set of n_filters filters of lenghts win_s */
31 struct _aubio_filterbank_t
41 new_aubio_filterbank (uint_t n_filters, uint_t win_s)
43 /* allocate space for filterbank object */
44 aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t);
46 fb->n_filters = n_filters;
48 /* allocate filter tables, a matrix of length win_s and of height n_filters */
49 fb->filters = new_fmat (n_filters, win_s / 2 + 1);
59 del_aubio_filterbank (aubio_filterbank_t * fb)
61 del_fmat (fb->filters);
66 aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out)
68 /* apply filter to all input channel, provided out has enough channels */
69 //uint_t max_filters = MIN (f->n_filters, out->length);
70 //uint_t max_length = MIN (in->length, f->filters->length);
72 // view cvec->norm as fvec->data
74 tmp.length = in->length;
77 if (f->power != 1.) fvec_pow(&tmp, f->power);
79 fmat_vecmul(f->filters, &tmp, out);
85 aubio_filterbank_get_coeffs (const aubio_filterbank_t * f)
91 aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filter_coeffs)
93 fmat_copy(filter_coeffs, f->filters);
98 aubio_filterbank_set_norm (aubio_filterbank_t *f, smpl_t norm)
100 if (norm != 0 && norm != 1) return AUBIO_FAIL;
106 aubio_filterbank_get_norm (aubio_filterbank_t *f)
112 aubio_filterbank_set_power (aubio_filterbank_t *f, smpl_t power)
119 aubio_filterbank_get_power (aubio_filterbank_t *f)