1 /* libSoX Biquad filter common definitions (c) 2006-7 robs@users.sourceforge.net
2  *
3  * This library is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2.1 of the License, or (at
6  * your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
16  */
17 
18 #ifndef biquad_included
19 #define biquad_included
20 
21 #define LSX_EFF_ALIAS
22 #include "sox_i.h"
23 
24 typedef enum {
25   filter_LPF,
26   filter_HPF,
27   filter_BPF_CSG,
28   filter_BPF,
29   filter_notch,
30   filter_APF,
31   filter_peakingEQ,
32   filter_lowShelf,
33   filter_highShelf,
34   filter_LPF_1,
35   filter_HPF_1,
36   filter_BPF_SPK,
37   filter_BPF_SPK_N,
38   filter_AP1,
39   filter_AP2,
40   filter_deemph,
41   filter_riaa
42 } filter_t;
43 
44 typedef enum {
45   width_bw_Hz,
46   width_bw_kHz,
47   /* The old, non-RBJ, non-freq-warped band-pass/reject response;
48    * leaving here for now just in case anybody misses it: */
49   width_bw_old,
50   width_bw_oct,
51   width_Q,
52   width_slope
53 } width_t;
54 
55 /* Private data for the biquad filter effects */
56 typedef struct {
57   double gain;             /* For EQ filters */
58   double fc;               /* Centre/corner/cutoff frequency */
59   double width;            /* Filter width; interpreted as per width_type */
60   width_t width_type;
61 
62   filter_t filter_type;
63 
64   double b0, b1, b2;       /* Filter coefficients */
65   double a0, a1, a2;       /* Filter coefficients */
66 
67   sox_sample_t i1, i2;     /* Filter memory */
68   double      o1, o2;      /* Filter memory */
69 } biquad_t;
70 
71 int lsx_biquad_getopts(sox_effect_t * effp, int n, char **argv,
72     int min_args, int max_args, int fc_pos, int width_pos, int gain_pos,
73     char const * allowed_width_types, filter_t filter_type);
74 int lsx_biquad_start(sox_effect_t * effp);
75 int lsx_biquad_flow(sox_effect_t * effp, const sox_sample_t *ibuf, sox_sample_t *obuf,
76                         size_t *isamp, size_t *osamp);
77 
78 #endif
79