1 | //libroardsp.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - August 2008 |
---|
5 | * |
---|
6 | * This file is part of libroardsp 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 | * libroardsp 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, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _LIBROARDSP_H_ |
---|
26 | #define _LIBROARDSP_H_ |
---|
27 | |
---|
28 | #include <roaraudio.h> |
---|
29 | |
---|
30 | __BEGIN_DECLS |
---|
31 | |
---|
32 | #include "midi.h" |
---|
33 | #include "poly.h" |
---|
34 | #include "convert.h" |
---|
35 | #include "midside.h" |
---|
36 | #include "point.h" |
---|
37 | #include "remove.h" |
---|
38 | #include "transcode.h" |
---|
39 | |
---|
40 | #ifdef ROAR_HAVE_LIBCELT |
---|
41 | #include "transcode_celt.h" |
---|
42 | #endif |
---|
43 | |
---|
44 | // defines |
---|
45 | #define ROARDSP_MAX_FILTERS_PER_CHAIN 8 |
---|
46 | |
---|
47 | #define ROARDSP_FILTER_NONE 0 |
---|
48 | #define ROARDSP_FILTER_AMP 1 |
---|
49 | #define ROARDSP_FILTER_LOWP 2 |
---|
50 | #define ROARDSP_FILTER_HIGHP 3 |
---|
51 | #define ROARDSP_FILTER_MODULATE 4 |
---|
52 | #define ROARDSP_FILTER_QUANTIFY 5 |
---|
53 | #define ROARDSP_FILTER_CLIP 6 |
---|
54 | #define ROARDSP_FILTER_ADD 7 |
---|
55 | #define ROARDSP_FILTER_DOWNMIX 8 |
---|
56 | #define ROARDSP_FILTER_DCBLOCK 9 |
---|
57 | #define ROARDSP_FILTER_SWAP 10 |
---|
58 | |
---|
59 | // filter CTLs: |
---|
60 | |
---|
61 | #define ROARDSP_FCTL_FREQ 1 |
---|
62 | #define ROARDSP_FCTL_TIME 2 |
---|
63 | #define ROARDSP_FCTL_MUL 3 |
---|
64 | #define ROARDSP_FCTL_DIV 4 |
---|
65 | #define ROARDSP_FCTL_N 5 |
---|
66 | #define ROARDSP_FCTL_LIMIT 6 |
---|
67 | #define ROARDSP_FCTL_PHASE 7 |
---|
68 | #define ROARDSP_FCTL_Q 8 |
---|
69 | #define ROARDSP_FCTL_MODE 9 |
---|
70 | |
---|
71 | // consts for filter(chain) reset: |
---|
72 | #define ROARDSP_RESET_NONE 0 |
---|
73 | #define ROARDSP_RESET_FULL 1 |
---|
74 | #define ROARDSP_RESET_STATE 2 |
---|
75 | |
---|
76 | // filter specific constants: |
---|
77 | #define ROARDSP_DOWNMIX_LEFT 1 |
---|
78 | #define ROARDSP_DOWNMIX_RIGHT 2 |
---|
79 | #define ROARDSP_DOWNMIX_ARITHMETIC 3 |
---|
80 | #define ROARDSP_DOWNMIX_RMS 4 |
---|
81 | |
---|
82 | #define ROARDSP_DCBLOCK_NUMBLOCKS 100 |
---|
83 | |
---|
84 | // types: |
---|
85 | |
---|
86 | struct roardsp_filter { |
---|
87 | int channels; |
---|
88 | int bits; |
---|
89 | int rate; |
---|
90 | void * inst; |
---|
91 | int (*calc )(struct roardsp_filter * filter, void * data, size_t samples); |
---|
92 | int (*uninit)(struct roardsp_filter * filter); |
---|
93 | int (*ctl )(struct roardsp_filter * filter, int cmd, void * data); |
---|
94 | int (*reset )(struct roardsp_filter * filter, int what); |
---|
95 | }; |
---|
96 | |
---|
97 | struct roardsp_filterchain { |
---|
98 | int filters; |
---|
99 | struct roardsp_filter * filter[ROARDSP_MAX_FILTERS_PER_CHAIN]; |
---|
100 | }; |
---|
101 | |
---|
102 | #ifdef ROAR_HAVE_LIBM |
---|
103 | struct roardsp_lowp { |
---|
104 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
105 | uint16_t a, b; |
---|
106 | int32_t old[ROAR_MAX_CHANNELS]; |
---|
107 | }; |
---|
108 | |
---|
109 | struct roardsp_highp { |
---|
110 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
111 | int32_t a, b, c; |
---|
112 | int32_t oldout[ROAR_MAX_CHANNELS]; |
---|
113 | int32_t oldin[ROAR_MAX_CHANNELS]; |
---|
114 | }; |
---|
115 | #endif |
---|
116 | |
---|
117 | struct roardsp_amp { |
---|
118 | int32_t mul; |
---|
119 | int32_t div; |
---|
120 | }; |
---|
121 | |
---|
122 | struct roardsp_dcblock { |
---|
123 | int cur; |
---|
124 | int32_t dc[ROARDSP_DCBLOCK_NUMBLOCKS]; |
---|
125 | }; |
---|
126 | |
---|
127 | struct roardsp_swap { |
---|
128 | int map[ROAR_MAX_CHANNELS]; |
---|
129 | }; |
---|
130 | |
---|
131 | // funcs: |
---|
132 | int roardsp_filter_str2id(char * str); |
---|
133 | char * roardsp_filter_id2str(int id); |
---|
134 | int roardsp_filter_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
135 | int roardsp_filter_uninit(struct roardsp_filter * filter); |
---|
136 | int roardsp_filter_calc (struct roardsp_filter * filter, void * data, size_t len); |
---|
137 | int roardsp_filter_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
138 | int roardsp_filter_reset (struct roardsp_filter * filter, int what); |
---|
139 | |
---|
140 | int roardsp_fchain_init (struct roardsp_filterchain * chain); |
---|
141 | int roardsp_fchain_uninit(struct roardsp_filterchain * chain); |
---|
142 | int roardsp_fchain_add (struct roardsp_filterchain * chain, struct roardsp_filter * filter); |
---|
143 | int roardsp_fchain_calc (struct roardsp_filterchain * chain, void * data, size_t len); |
---|
144 | int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what); |
---|
145 | int roardsp_fchain_num (struct roardsp_filterchain * chain); |
---|
146 | |
---|
147 | // filter: |
---|
148 | |
---|
149 | #ifdef ROAR_HAVE_LIBM |
---|
150 | int roardsp_lowp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
151 | int roardsp_lowp_uninit(struct roardsp_filter * filter); |
---|
152 | int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
153 | int roardsp_lowp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
154 | int roardsp_lowp_reset (struct roardsp_filter * filter, int what); |
---|
155 | |
---|
156 | int roardsp_highp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
157 | int roardsp_highp_uninit(struct roardsp_filter * filter); |
---|
158 | int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
159 | int roardsp_highp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
160 | int roardsp_highp_reset (struct roardsp_filter * filter, int what); |
---|
161 | #endif |
---|
162 | |
---|
163 | int roardsp_amp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
164 | int roardsp_amp_uninit(struct roardsp_filter * filter); |
---|
165 | int roardsp_amp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
166 | int roardsp_amp_calc8 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
167 | int roardsp_amp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
168 | int roardsp_amp_reset (struct roardsp_filter * filter, int what); |
---|
169 | |
---|
170 | int roardsp_add_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
171 | int roardsp_add_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
172 | int roardsp_add_reset (struct roardsp_filter * filter, int what); |
---|
173 | |
---|
174 | int roardsp_quantify_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
175 | int roardsp_quantify_uninit(struct roardsp_filter * filter); |
---|
176 | int roardsp_quantify_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
177 | int roardsp_quantify_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
178 | int roardsp_quantify_reset (struct roardsp_filter * filter, int what); |
---|
179 | |
---|
180 | int roardsp_clip_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
181 | int roardsp_clip_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
182 | int roardsp_clip_reset (struct roardsp_filter * filter, int what); |
---|
183 | |
---|
184 | int roardsp_downmix_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
185 | int roardsp_downmix_calc162(struct roardsp_filter * filter, void * data, size_t samples); |
---|
186 | int roardsp_downmix_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
187 | int roardsp_downmix_reset (struct roardsp_filter * filter, int what); |
---|
188 | |
---|
189 | int roardsp_dcblock_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
190 | int roardsp_dcblock_uninit (struct roardsp_filter * filter); |
---|
191 | int roardsp_dcblock_calc16 (struct roardsp_filter * filter, void * data, size_t samples); |
---|
192 | int roardsp_dcblock_reset (struct roardsp_filter * filter, int what); |
---|
193 | |
---|
194 | int roardsp_swap_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
195 | int roardsp_swap_uninit (struct roardsp_filter * filter); |
---|
196 | int roardsp_swap_calc162(struct roardsp_filter * filter, void * data, size_t samples); |
---|
197 | int roardsp_swap_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
198 | int roardsp_swap_reset (struct roardsp_filter * filter, int what); |
---|
199 | |
---|
200 | // codecs: |
---|
201 | int roardsp_conv_alaw2pcm16 (int16_t * out, char * in, size_t len); |
---|
202 | int roardsp_conv_pcm162alaw (char * out, int16_t * in, size_t len); |
---|
203 | |
---|
204 | int roardsp_conv_mulaw2pcm16 (int16_t * out, char * in, size_t len); |
---|
205 | int roardsp_conv_pcm162mulaw (char * out, int16_t * in, size_t len); |
---|
206 | |
---|
207 | __END_DECLS |
---|
208 | |
---|
209 | #endif |
---|
210 | |
---|
211 | //ll |
---|