2 Copyright (C) 2003 Paul Brossier
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.
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.
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.
20 #include "aubio_priv.h"
22 #include "mathutils.h"
25 /** \note this file needs to be in double or more less precision would lead to large
26 * errors in the output
29 struct _aubio_biquad_t {
41 void aubio_biquad_do(aubio_biquad_t * b, fvec_t * in) {
53 i=0; // works in mono only !!!
54 //for (i=0;i<in->channels;i++) {
55 for (j = 0; j < in->length; j++) {
56 lsmp_t i0 = in->data[i][j];
57 lsmp_t o0 = b1 * i0 + b2 * i1 + b3 * i2
58 - a2 * o1 - a3 * o2;// + 1e-37;
72 void aubio_biquad_do_filtfilt(aubio_biquad_t * b, fvec_t * in, fvec_t * tmp) {
74 uint_t length = in->length;
77 mir = 2*in->data[i][0];
78 b->i1 = mir - in->data[i][2];
79 b->i2 = mir - in->data[i][1];
81 aubio_biquad_do(b,in);
83 for (j = 0; j < length; j++)
84 tmp->data[i][length-j-1] = in->data[i][j];
86 mir = 2*tmp->data[i][0];
87 b->i1 = mir - tmp->data[i][2];
88 b->i2 = mir - tmp->data[i][1];
90 aubio_biquad_do(b,tmp);
92 for (j = 0; j < length; j++)
93 in->data[i][j] = tmp->data[i][length-j-1];
96 aubio_biquad_t * new_aubio_biquad(
97 lsmp_t b1, lsmp_t b2, lsmp_t b3,
98 lsmp_t a2, lsmp_t a3) {
99 aubio_biquad_t * b = AUBIO_NEW(aubio_biquad_t);
112 void del_aubio_biquad(aubio_biquad_t * b) {