source: src/spectral/filterbank.c @ 7e9c67d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 7e9c67d was feb694b, checked in by Paul Brossier <piem@piem.org>, 9 years ago

src/spectral/: add const qualifiers

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2  Copyright (C) 2007-2009 Paul Brossier <piem@aubio.org>
3                      and Amaury Hazan <ahazan@iua.upf.edu>
4
5  This file is part of aubio.
6
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.
11
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.
16
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/>.
19
20*/
21
22#include "aubio_priv.h"
23#include "fvec.h"
24#include "fmat.h"
25#include "cvec.h"
26#include "spectral/filterbank.h"
27#include "mathutils.h"
28
29/** \brief A structure to store a set of n_filters filters of lenghts win_s */
30struct _aubio_filterbank_t
31{
32  uint_t win_s;
33  uint_t n_filters;
34  fmat_t *filters;
35};
36
37aubio_filterbank_t *
38new_aubio_filterbank (uint_t n_filters, uint_t win_s)
39{
40  /* allocate space for filterbank object */
41  aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t);
42  fb->win_s = win_s;
43  fb->n_filters = n_filters;
44
45  /* allocate filter tables, a matrix of length win_s and of height n_filters */
46  fb->filters = new_fmat (n_filters, win_s / 2 + 1);
47
48  return fb;
49}
50
51void
52del_aubio_filterbank (aubio_filterbank_t * fb)
53{
54  del_fmat (fb->filters);
55  AUBIO_FREE (fb);
56}
57
58void
59aubio_filterbank_do (aubio_filterbank_t * f, const cvec_t * in, fvec_t * out)
60{
61  /* apply filter to all input channel, provided out has enough channels */
62  //uint_t max_filters = MIN (f->n_filters, out->length);
63  //uint_t max_length = MIN (in->length, f->filters->length);
64
65  // view cvec->norm as fvec->data
66  fvec_t tmp;
67  tmp.length = in->length;
68  tmp.data = in->norm;
69
70  fmat_vecmul(f->filters, &tmp, out);
71
72  return;
73}
74
75fmat_t *
76aubio_filterbank_get_coeffs (const aubio_filterbank_t * f)
77{
78  return f->filters;
79}
80
81uint_t
82aubio_filterbank_set_coeffs (aubio_filterbank_t * f, const fmat_t * filter_coeffs)
83{
84  fmat_copy(filter_coeffs, f->filters);
85  return 0;
86}
Note: See TracBrowser for help on using the repository browser.