1 /*(LGPL)
2 ---------------------------------------------------------------------------
3 	a_filters.h - Various Audio Signal Filters
4 ---------------------------------------------------------------------------
5  * Copyright (C) 2001, 2002, David Olofson
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  */
21 
22 #ifndef _A_FILTERS_H_
23 #define _A_FILTERS_H_
24 
25 /*--------------------------------------------------------------------
26 	f6_t - Simple mono 6 dB/oct state variable filter
27 --------------------------------------------------------------------*/
28 typedef struct f6_t
29 {
30 	int rate;
31 	int d;
32 	int f;
33 } f6_t;
34 
35 void f6_init(f6_t *fil, int fs);
36 void f6_set_f(f6_t *fil, int f);
37 void f6_process_lp(f6_t *fil, int *buf, unsigned frames);
38 void f6_process_hp(f6_t *fil, int *buf, unsigned frames);
39 
40 /*--------------------------------------------------------------------
41 	f6s_t - Simple stereo 6 dB/oct state variable filter
42 --------------------------------------------------------------------*/
43 typedef struct f6s_t
44 {
45 	int rate;
46 	int f;
47 	int dl, dr;
48 } f6s_t;
49 
50 void f6s_init(f6s_t *fil, int fs);
51 void f6s_set_f(f6s_t *fil, int f);
52 void f6s_process_lp(f6s_t *fil, int *buf, unsigned frames);
53 void f6s_process_hp(f6s_t *fil, int *buf, unsigned frames);
54 
55 /*--------------------------------------------------------------------
56 	dcf6s_t - Fast stereo 6 dB/oct HPF for DC suppression
57 --------------------------------------------------------------------*/
58 typedef struct dcf6s_t
59 {
60 	int rate;
61 	int f;
62 	int dl, dr;
63 } dcf6s_t;
64 
65 void dcf6s_init(dcf6s_t *fil, int fs);
66 void dcf6s_set_f(dcf6s_t *fil, int f);
67 void dcf6s_process(dcf6s_t *fil, int *buf, unsigned frames);
68 int dcf6s_silent(dcf6s_t *fil);
69 
70 /*--------------------------------------------------------------------
71 	resof12_t - Resonant mono 12 dB/oct state variable filter
72 --------------------------------------------------------------------*/
73 typedef struct resof12_t
74 {
75 	int rate;
76 	int d1, d2;
77 	int f;
78 	int q;
79 } resof12_t;
80 
81 void resof12_init(resof12_t *rf, int fs);
82 void resof12_set_f(resof12_t *rf, int f);
83 void resof12_set_q(resof12_t *rf, int q);
84 void resof12_process_lp(resof12_t *rf, int *buf, unsigned frames);	/*In-place LP*/
85 void resof12_process_hp(resof12_t *rf, int *buf, unsigned frames);	/*In-place HP*/
86 void resof12_process_bp(resof12_t *rf, int *buf, unsigned frames);	/*In-place BP*/
87 /*
88  * LP filter the 'buf' buffer, while separating off
89  * the HP part into buffer 'out'.
90  */
91 void resof12_process_split(resof12_t *rf, int *buf, int *out, unsigned frames);
92 
93 /*--------------------------------------------------------------------
94 	resof12s_t - Resonant stereo 12 dB/oct state variable filter
95 --------------------------------------------------------------------*/
96 typedef struct resof12s_t
97 {
98 	int rate;
99 	int d1l, d2l;
100 	int d1r, d2r;
101 	int f;
102 	int q;
103 } resof12s_t;
104 
105 void resof12s_init(resof12s_t *rf, int fs);
106 void resof12s_set_f(resof12s_t *rf, int f);
107 void resof12s_set_q(resof12s_t *rf, int q);
108 void resof12s_process_lp(resof12s_t *rf, int *buf, unsigned frames);	/*In-place LP*/
109 
110 #endif /*_A_FILTERS_H_*/
111