source: roaraudio/include/libroardsp/libroardsp.h @ 2998:8b5eba2cfc0a

Last change on this file since 2998:8b5eba2cfc0a was 2998:8b5eba2cfc0a, checked in by phi, 15 years ago

added dummy roardsp_speex_prep_calc161()

File size: 9.2 KB
Line 
1//libroardsp.h:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008, 2009
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// enable Speex preprocessing and better type handling if speex > 1.1.8
33#ifdef ROAR_HAVE_LIBSPEEX
34#include <speex/speex.h>
35#ifdef _SPEEX_TYPES_H
36#include <speex/speex_preprocess.h>
37#endif
38#endif
39
40#include "midi.h"
41#include "synth.h"
42#include "poly.h"
43#include "fader.h"
44#include "mixer.h"
45#include "amp.h"
46#include "convert.h"
47#include "midside.h"
48#include "point.h"
49#include "remove.h"
50#include "rms.h"
51#include "transcode.h"
52#include "vio_transcode.h"
53
54#ifdef ROAR_HAVE_LIBCELT
55#include "transcode_celt.h"
56#endif
57#ifdef ROAR_HAVE_LIBSPEEX
58#include "transcode_speex.h"
59#endif
60
61#ifdef ROAR_HAVE_LIBSAMPLERATE
62#include <samplerate.h>
63#endif
64
65// defines
66#define ROARDSP_MAX_FILTERS_PER_CHAIN 8
67
68#define ROARDSP_FILTER_NONE           0
69#define ROARDSP_FILTER_AMP            1
70#define ROARDSP_FILTER_LOWP           2
71#define ROARDSP_FILTER_HIGHP          3
72#define ROARDSP_FILTER_MODULATE       4
73#define ROARDSP_FILTER_QUANTIFY       5
74#define ROARDSP_FILTER_CLIP           6
75#define ROARDSP_FILTER_ADD            7
76#define ROARDSP_FILTER_DOWNMIX        8
77#define ROARDSP_FILTER_DCBLOCK        9
78#define ROARDSP_FILTER_SWAP          10
79#define ROARDSP_FILTER_SPEEX_PREP    11
80#define ROARDSP_FILTER_AGC           12
81
82// filter CTLs:
83
84#define ROARDSP_FCTL_FREQ             1 /* float */
85#define ROARDSP_FCTL_TIME             2
86#define ROARDSP_FCTL_MUL              3
87#define ROARDSP_FCTL_DIV              4
88#define ROARDSP_FCTL_N                5
89#define ROARDSP_FCTL_LIMIT            6
90#define ROARDSP_FCTL_PHASE            7
91#define ROARDSP_FCTL_Q                8
92#define ROARDSP_FCTL_MODE             9
93#define ROARDSP_FCTL_PACKET_SIZE     10 /* size_t */
94
95// consts for filter flags:
96#define ROARDSP_FFLAG_NONE            0x0000
97#define ROARDSP_FFLAG_FREE            0x0001
98
99// consts for filter(chain) reset:
100#define ROARDSP_RESET_NONE            0
101#define ROARDSP_RESET_FULL            1
102#define ROARDSP_RESET_STATE           2
103
104// filter specific constants:
105#define ROARDSP_DOWNMIX_LEFT          1
106#define ROARDSP_DOWNMIX_RIGHT         2
107#define ROARDSP_DOWNMIX_ARITHMETIC    3
108#define ROARDSP_DOWNMIX_RMS           4
109
110#define ROARDSP_DCBLOCK_NUMBLOCKS     100
111
112// types:
113
114struct roardsp_filter {
115 int    channels;
116 int    bits;
117 int    rate;
118 void * inst;
119 uint_least16_t flags;
120 int (*calc  )(struct roardsp_filter * filter, void * data, size_t samples);
121 int (*uninit)(struct roardsp_filter * filter);
122 int (*ctl   )(struct roardsp_filter * filter, int cmd, void * data);
123 int (*reset )(struct roardsp_filter * filter, int what);
124};
125
126struct roardsp_filterchain {
127 int filters;
128 struct roardsp_filter * filter[ROARDSP_MAX_FILTERS_PER_CHAIN];
129};
130
131#ifdef ROAR_HAVE_LIBM
132struct roardsp_lowp {
133 uint32_t freq; // in mHz (0Hz..4MHz)
134 uint16_t a, b;
135 int32_t  old[ROAR_MAX_CHANNELS];
136};
137
138struct roardsp_highp {
139 uint32_t freq; // in mHz (0Hz..4MHz)
140 int32_t  a, b, c;
141 int32_t  oldout[ROAR_MAX_CHANNELS];
142 int32_t  oldin[ROAR_MAX_CHANNELS];
143};
144#endif
145
146struct roardsp_amp {
147 int32_t  mul;
148 int32_t  div;
149};
150
151struct roardsp_dcblock {
152 int cur;
153 int32_t dc[ROARDSP_DCBLOCK_NUMBLOCKS];
154};
155
156struct roardsp_swap {
157 int map[ROAR_MAX_CHANNELS];
158};
159
160struct roardsp_agc {
161 struct roardsp_filter * amp;
162};
163
164struct roardsp_speex_prep {
165#ifdef _SPEEX_TYPES_H
166 SpeexPreprocessState *preprocess;
167 int frame_size;
168#else
169 char dummy[8];
170#endif
171};
172
173// funcs:
174int    roardsp_filter_str2id(char * str);
175char * roardsp_filter_id2str(int id);
176int    roardsp_filter_new   (struct roardsp_filter ** filter, struct roar_stream * stream, int id);
177#define roardsp_filter_free(x) roar_dsp_filter_uninit((x))
178int    roardsp_filter_init  (struct roardsp_filter *  filter, struct roar_stream * stream, int id);
179int    roardsp_filter_uninit(struct roardsp_filter *  filter);
180int    roardsp_filter_calc  (struct roardsp_filter *  filter, void * data, size_t len);
181int    roardsp_filter_ctl   (struct roardsp_filter *  filter, int cmd, void * data);
182int    roardsp_filter_reset (struct roardsp_filter *  filter, int what);
183
184int roardsp_fchain_init  (struct roardsp_filterchain * chain);
185int roardsp_fchain_uninit(struct roardsp_filterchain * chain);
186int roardsp_fchain_add   (struct roardsp_filterchain * chain, struct roardsp_filter * filter);
187int roardsp_fchain_calc  (struct roardsp_filterchain * chain, void * data, size_t len);
188int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what);
189int roardsp_fchain_num   (struct roardsp_filterchain * chain);
190
191// filter:
192
193#ifdef ROAR_HAVE_LIBM
194int roardsp_lowp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
195int roardsp_lowp_uninit(struct roardsp_filter * filter);
196int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
197int roardsp_lowp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
198int roardsp_lowp_reset (struct roardsp_filter * filter, int what);
199
200int roardsp_highp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
201int roardsp_highp_uninit(struct roardsp_filter * filter);
202int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
203int roardsp_highp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
204int roardsp_highp_reset (struct roardsp_filter * filter, int what);
205#endif
206
207int roardsp_amp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
208int roardsp_amp_uninit(struct roardsp_filter * filter);
209int roardsp_amp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
210int roardsp_amp_calc8 (struct roardsp_filter * filter, void * data, size_t samples);
211int roardsp_amp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
212int roardsp_amp_reset (struct roardsp_filter * filter, int what);
213
214int roardsp_add_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
215int roardsp_add_calc16(struct roardsp_filter * filter, void * data, size_t samples);
216int roardsp_add_reset (struct roardsp_filter * filter, int what);
217
218int roardsp_quantify_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
219int roardsp_quantify_uninit(struct roardsp_filter * filter);
220int roardsp_quantify_calc16(struct roardsp_filter * filter, void * data, size_t samples);
221int roardsp_quantify_ctl   (struct roardsp_filter * filter, int cmd, void * data);
222int roardsp_quantify_reset (struct roardsp_filter * filter, int what);
223
224int roardsp_clip_calc16(struct roardsp_filter * filter, void * data, size_t samples);
225int roardsp_clip_ctl   (struct roardsp_filter * filter, int cmd, void * data);
226int roardsp_clip_reset (struct roardsp_filter * filter, int what);
227
228int roardsp_downmix_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
229int roardsp_downmix_calc162(struct roardsp_filter * filter, void * data, size_t samples);
230int roardsp_downmix_ctl    (struct roardsp_filter * filter, int cmd, void * data);
231int roardsp_downmix_reset  (struct roardsp_filter * filter, int what);
232
233int roardsp_dcblock_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
234int roardsp_dcblock_uninit (struct roardsp_filter * filter);
235int roardsp_dcblock_calc16 (struct roardsp_filter * filter, void * data, size_t samples);
236int roardsp_dcblock_reset  (struct roardsp_filter * filter, int what);
237
238int roardsp_swap_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
239int roardsp_swap_uninit (struct roardsp_filter * filter);
240int roardsp_swap_calc162(struct roardsp_filter * filter, void * data, size_t samples);
241int roardsp_swap_ctl    (struct roardsp_filter * filter, int cmd, void * data);
242int roardsp_swap_reset  (struct roardsp_filter * filter, int what);
243
244#ifdef _SPEEX_TYPES_H
245int roardsp_speex_prep_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
246int roardsp_speex_prep_uninit (struct roardsp_filter * filter);
247int roardsp_speex_prep_calc161(struct roardsp_filter * filter, void * data, size_t samples);
248int roardsp_speex_prep_ctl    (struct roardsp_filter * filter, int cmd, void * data);
249int roardsp_speex_prep_reset  (struct roardsp_filter * filter, int what);
250#endif
251
252// codecs:
253int roardsp_conv_alaw2pcm16 (int16_t * out, char * in, size_t len);
254int roardsp_conv_pcm162alaw (char * out, int16_t * in, size_t len);
255
256int roardsp_conv_mulaw2pcm16 (int16_t * out, char * in, size_t len);
257int roardsp_conv_pcm162mulaw (char * out, int16_t * in, size_t len);
258
259__END_DECLS
260
261#endif
262
263//ll
Note: See TracBrowser for help on using the repository browser.