1 | /* |
---|
2 | Copyright (C) 2003 Paul Brossier |
---|
3 | |
---|
4 | This program is free software; you can redistribute it and/or modify |
---|
5 | it under the terms of the GNU General Public License as published by |
---|
6 | the Free Software Foundation; either version 2 of the License, or |
---|
7 | (at your option) any later version. |
---|
8 | |
---|
9 | This program is distributed in the hope that it will be useful, |
---|
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 | GNU General Public License for more details. |
---|
13 | |
---|
14 | You should have received a copy of the GNU General Public License |
---|
15 | along with this program; if not, write to the Free Software |
---|
16 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
17 | |
---|
18 | */ |
---|
19 | |
---|
20 | #include "aubio_priv.h" |
---|
21 | #include "fvec.h" |
---|
22 | #include "lvec.h" |
---|
23 | #include "temporal/filter.h" |
---|
24 | |
---|
25 | uint_t |
---|
26 | aubio_filter_set_biquad (aubio_filter_t * f, lsmp_t b0, lsmp_t b1, lsmp_t b2, |
---|
27 | lsmp_t a1, lsmp_t a2) { |
---|
28 | uint_t order = aubio_filter_get_order (f); |
---|
29 | lvec_t *bs = aubio_filter_get_feedforward (f); |
---|
30 | lvec_t *as = aubio_filter_get_feedback (f); |
---|
31 | |
---|
32 | if (order != 3) { |
---|
33 | AUBIO_ERROR ("order of biquad filter must be 3, not %d\n", order); |
---|
34 | return AUBIO_FAIL; |
---|
35 | } |
---|
36 | bs->data[0][0] = b0; |
---|
37 | bs->data[0][1] = b1; |
---|
38 | bs->data[0][2] = b2; |
---|
39 | as->data[0][0] = 1.; |
---|
40 | as->data[0][1] = a1; |
---|
41 | as->data[0][1] = a2; |
---|
42 | return AUBIO_OK; |
---|
43 | } |
---|
44 | |
---|
45 | aubio_filter_t * |
---|
46 | new_aubio_filter_biquad (lsmp_t b0, lsmp_t b1, lsmp_t b2, lsmp_t a1, lsmp_t a2, |
---|
47 | uint_t channels) |
---|
48 | { |
---|
49 | aubio_filter_t *f = new_aubio_filter (3, channels); |
---|
50 | aubio_filter_set_biquad (f, b0, b1, b2, a1, a2); |
---|
51 | return f; |
---|
52 | } |
---|