1 | //filters.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2011-2012 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARDSP_FILTERS_H_ |
---|
37 | #define _LIBROARDSP_FILTERS_H_ |
---|
38 | |
---|
39 | #include "libroardsp.h" |
---|
40 | |
---|
41 | #ifdef ROAR_HAVE_LIBM |
---|
42 | struct roardsp_lowp { |
---|
43 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
44 | uint16_t a, b; |
---|
45 | int32_t old[ROAR_MAX_CHANNELS]; |
---|
46 | }; |
---|
47 | |
---|
48 | struct roardsp_highp { |
---|
49 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
50 | int32_t a, b, c; |
---|
51 | int32_t oldout[ROAR_MAX_CHANNELS]; |
---|
52 | int32_t oldin[ROAR_MAX_CHANNELS]; |
---|
53 | }; |
---|
54 | #endif |
---|
55 | |
---|
56 | struct roardsp_amp { |
---|
57 | int32_t mul; |
---|
58 | int32_t div; |
---|
59 | }; |
---|
60 | |
---|
61 | struct roardsp_dcblock { |
---|
62 | int cur; |
---|
63 | int32_t dc[ROARDSP_DCBLOCK_NUMBLOCKS]; |
---|
64 | }; |
---|
65 | |
---|
66 | enum roardsp_clip_mode { |
---|
67 | ROARDSP_CLIP_MODE_LIMIT = 0, |
---|
68 | ROARDSP_CLIP_MODE_ZERO = 1, |
---|
69 | ROARDSP_CLIP_MODE_WARP = 2, |
---|
70 | ROARDSP_CLIP_MODE_NOISE = 3 |
---|
71 | }; |
---|
72 | |
---|
73 | struct roardsp_clip { |
---|
74 | enum roardsp_clip_mode mode; |
---|
75 | int32_t limit; |
---|
76 | }; |
---|
77 | |
---|
78 | struct roardsp_swap { |
---|
79 | int map[ROAR_MAX_CHANNELS]; |
---|
80 | }; |
---|
81 | |
---|
82 | struct roardsp_agc { |
---|
83 | struct roardsp_filter * amp; |
---|
84 | uint32_t target_amp; |
---|
85 | }; |
---|
86 | |
---|
87 | struct roardsp_speex_prep { |
---|
88 | #ifdef _SPEEX_TYPES_H |
---|
89 | SpeexPreprocessState *preprocess; |
---|
90 | int frame_size; |
---|
91 | #else |
---|
92 | char dummy[8]; |
---|
93 | #endif |
---|
94 | }; |
---|
95 | |
---|
96 | enum roardsp_responsecurve_mode { |
---|
97 | ROARDSP_RESPONSECURVE_MODE_PASS = 0, /* pass: o = i */ |
---|
98 | ROARDSP_RESPONSECURVE_MODE_LIN = 1, /* linear: o = -(1-i)^(N+1) + 1 */ |
---|
99 | ROARDSP_RESPONSECURVE_MODE_ILIN = 2, /* inverse linear: o = i**(N+1) */ |
---|
100 | ROARDSP_RESPONSECURVE_MODE_SIN = 3, /* sin: o = sin(pi/2 * i)^N */ |
---|
101 | ROARDSP_RESPONSECURVE_MODE_ISIN = 4, /* inverse sin: o = 1-sin((1-i)*pi/2)^N */ |
---|
102 | ROARDSP_RESPONSECURVE_MODE_COS = 5, /* cos: o = 0.5-cos(i*pi)/2 */ |
---|
103 | ROARDSP_RESPONSECURVE_MODE_ICOS = 6, /* inverse cos: o = 2*i-0.5+cos(i*pi)/2 */ |
---|
104 | }; |
---|
105 | |
---|
106 | struct roardsp_responsecurve { |
---|
107 | enum roardsp_responsecurve_mode mode_pos, mode_neg; |
---|
108 | int32_t N; |
---|
109 | }; |
---|
110 | |
---|
111 | // filter: |
---|
112 | |
---|
113 | #ifdef ROAR_HAVE_LIBM |
---|
114 | int roardsp_lowp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
115 | int roardsp_lowp_uninit(struct roardsp_filter * filter); |
---|
116 | int roardsp_lowp_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
117 | int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
118 | int roardsp_lowp_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
119 | int roardsp_lowp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
120 | int roardsp_lowp_reset (struct roardsp_filter * filter, int what); |
---|
121 | |
---|
122 | int roardsp_highp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
123 | int roardsp_highp_uninit(struct roardsp_filter * filter); |
---|
124 | int roardsp_highp_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
125 | int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
126 | int roardsp_highp_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
127 | int roardsp_highp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
128 | int roardsp_highp_reset (struct roardsp_filter * filter, int what); |
---|
129 | #endif |
---|
130 | |
---|
131 | int roardsp_amp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
132 | int roardsp_amp_uninit(struct roardsp_filter * filter); |
---|
133 | int roardsp_amp_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
134 | int roardsp_amp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
135 | int roardsp_amp_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
136 | int roardsp_amp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
137 | int roardsp_amp_reset (struct roardsp_filter * filter, int what); |
---|
138 | |
---|
139 | int roardsp_add_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
140 | int roardsp_add_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
141 | int roardsp_add_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
142 | int roardsp_add_reset (struct roardsp_filter * filter, int what); |
---|
143 | |
---|
144 | int roardsp_quantify_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
145 | int roardsp_quantify_uninit(struct roardsp_filter * filter); |
---|
146 | int roardsp_quantify_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
147 | int roardsp_quantify_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
148 | int roardsp_quantify_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
149 | int roardsp_quantify_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
150 | int roardsp_quantify_reset (struct roardsp_filter * filter, int what); |
---|
151 | |
---|
152 | int roardsp_clip_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
153 | int roardsp_clip_uninit(struct roardsp_filter * filter); |
---|
154 | int roardsp_clip_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
155 | int roardsp_clip_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
156 | int roardsp_clip_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
157 | int roardsp_clip_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
158 | int roardsp_clip_reset (struct roardsp_filter * filter, int what); |
---|
159 | |
---|
160 | int roardsp_downmix_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
161 | int roardsp_downmix_calc162(struct roardsp_filter * filter, void * data, size_t samples); |
---|
162 | int roardsp_downmix_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
163 | int roardsp_downmix_reset (struct roardsp_filter * filter, int what); |
---|
164 | |
---|
165 | int roardsp_dcblock_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
166 | int roardsp_dcblock_uninit (struct roardsp_filter * filter); |
---|
167 | int roardsp_dcblock_calc16 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
168 | int roardsp_dcblock_reset (struct roardsp_filter * filter, int what); |
---|
169 | |
---|
170 | int roardsp_swap_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
171 | int roardsp_swap_uninit (struct roardsp_filter * filter); |
---|
172 | int roardsp_swap_calc322(struct roardsp_filter * filter, void * data, size_t samples); |
---|
173 | int roardsp_swap_calc162(struct roardsp_filter * filter, void * data, size_t samples); |
---|
174 | int roardsp_swap_calc82 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
175 | int roardsp_swap_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
176 | int roardsp_swap_reset (struct roardsp_filter * filter, int what); |
---|
177 | |
---|
178 | int roardsp_agc_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
179 | int roardsp_agc_uninit (struct roardsp_filter * filter); |
---|
180 | int roardsp_agc_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
181 | int roardsp_agc_reset (struct roardsp_filter * filter, int what); |
---|
182 | |
---|
183 | #ifdef _SPEEX_TYPES_H |
---|
184 | #define ROAR_HAVE_SPEEX_FILTER |
---|
185 | int roardsp_speex_prep_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
186 | int roardsp_speex_prep_uninit (struct roardsp_filter * filter); |
---|
187 | int roardsp_speex_prep_calc161(struct roardsp_filter * filter, void * data, size_t samples); |
---|
188 | int roardsp_speex_prep_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
189 | int roardsp_speex_prep_reset (struct roardsp_filter * filter, int what); |
---|
190 | #endif |
---|
191 | |
---|
192 | #ifdef ROAR_HAVE_LIBM |
---|
193 | int roardsp_responsecurve_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
194 | int roardsp_responsecurve_uninit(struct roardsp_filter * filter); |
---|
195 | int roardsp_responsecurve_calc32(struct roardsp_filter * filter, void * data, size_t samples); |
---|
196 | int roardsp_responsecurve_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
197 | int roardsp_responsecurve_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
198 | int roardsp_responsecurve_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
199 | int roardsp_responsecurve_reset (struct roardsp_filter * filter, int what); |
---|
200 | #endif |
---|
201 | |
---|
202 | #endif |
---|
203 | |
---|
204 | //ll |
---|