source: roaraudio/include/libroardsp/libroardsp.h @ 2979:8bf2579d881c

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

added consts for new filters

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