source: roaraudio/include/libroardsp/libroardsp.h @ 2989:32ec8c5a72be

Last change on this file since 2989:32ec8c5a72be was 2989:32ec8c5a72be, checked in by phi, 15 years ago

added flags to filter, prototypes for new functions roardsp_filter_{new,free}

File size: 8.4 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 flags:
88#define ROARDSP_FFLAG_NONE            0x0000
89#define ROARDSP_FFLAG_FREE            0x0001
90
91// consts for filter(chain) reset:
92#define ROARDSP_RESET_NONE            0
93#define ROARDSP_RESET_FULL            1
94#define ROARDSP_RESET_STATE           2
95
96// filter specific constants:
97#define ROARDSP_DOWNMIX_LEFT          1
98#define ROARDSP_DOWNMIX_RIGHT         2
99#define ROARDSP_DOWNMIX_ARITHMETIC    3
100#define ROARDSP_DOWNMIX_RMS           4
101
102#define ROARDSP_DCBLOCK_NUMBLOCKS     100
103
104// types:
105
106struct roardsp_filter {
107 int    channels;
108 int    bits;
109 int    rate;
110 void * inst;
111 uint_least16_t flags;
112 int (*calc  )(struct roardsp_filter * filter, void * data, size_t samples);
113 int (*uninit)(struct roardsp_filter * filter);
114 int (*ctl   )(struct roardsp_filter * filter, int cmd, void * data);
115 int (*reset )(struct roardsp_filter * filter, int what);
116};
117
118struct roardsp_filterchain {
119 int filters;
120 struct roardsp_filter * filter[ROARDSP_MAX_FILTERS_PER_CHAIN];
121};
122
123#ifdef ROAR_HAVE_LIBM
124struct roardsp_lowp {
125 uint32_t freq; // in mHz (0Hz..4MHz)
126 uint16_t a, b;
127 int32_t  old[ROAR_MAX_CHANNELS];
128};
129
130struct roardsp_highp {
131 uint32_t freq; // in mHz (0Hz..4MHz)
132 int32_t  a, b, c;
133 int32_t  oldout[ROAR_MAX_CHANNELS];
134 int32_t  oldin[ROAR_MAX_CHANNELS];
135};
136#endif
137
138struct roardsp_amp {
139 int32_t  mul;
140 int32_t  div;
141};
142
143struct roardsp_dcblock {
144 int cur;
145 int32_t dc[ROARDSP_DCBLOCK_NUMBLOCKS];
146};
147
148struct roardsp_swap {
149 int map[ROAR_MAX_CHANNELS];
150};
151
152struct roardsp_agc {
153 struct roardsp_filter * amp;
154};
155
156struct roardsp_speex_prep {
157 char dummy[8];
158};
159
160// funcs:
161int    roardsp_filter_str2id(char * str);
162char * roardsp_filter_id2str(int id);
163int    roardsp_filter_new   (struct roardsp_filter ** filter, struct roar_stream * stream, int id);
164#define roardsp_filter_free(x) roar_dsp_filter_uninit((x))
165int    roardsp_filter_init  (struct roardsp_filter *  filter, struct roar_stream * stream, int id);
166int    roardsp_filter_uninit(struct roardsp_filter *  filter);
167int    roardsp_filter_calc  (struct roardsp_filter *  filter, void * data, size_t len);
168int    roardsp_filter_ctl   (struct roardsp_filter *  filter, int cmd, void * data);
169int    roardsp_filter_reset (struct roardsp_filter *  filter, int what);
170
171int roardsp_fchain_init  (struct roardsp_filterchain * chain);
172int roardsp_fchain_uninit(struct roardsp_filterchain * chain);
173int roardsp_fchain_add   (struct roardsp_filterchain * chain, struct roardsp_filter * filter);
174int roardsp_fchain_calc  (struct roardsp_filterchain * chain, void * data, size_t len);
175int roardsp_fchain_reset (struct roardsp_filterchain * chain, int what);
176int roardsp_fchain_num   (struct roardsp_filterchain * chain);
177
178// filter:
179
180#ifdef ROAR_HAVE_LIBM
181int roardsp_lowp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
182int roardsp_lowp_uninit(struct roardsp_filter * filter);
183int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
184int roardsp_lowp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
185int roardsp_lowp_reset (struct roardsp_filter * filter, int what);
186
187int roardsp_highp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
188int roardsp_highp_uninit(struct roardsp_filter * filter);
189int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
190int roardsp_highp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
191int roardsp_highp_reset (struct roardsp_filter * filter, int what);
192#endif
193
194int roardsp_amp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
195int roardsp_amp_uninit(struct roardsp_filter * filter);
196int roardsp_amp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
197int roardsp_amp_calc8 (struct roardsp_filter * filter, void * data, size_t samples);
198int roardsp_amp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
199int roardsp_amp_reset (struct roardsp_filter * filter, int what);
200
201int roardsp_add_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
202int roardsp_add_calc16(struct roardsp_filter * filter, void * data, size_t samples);
203int roardsp_add_reset (struct roardsp_filter * filter, int what);
204
205int roardsp_quantify_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
206int roardsp_quantify_uninit(struct roardsp_filter * filter);
207int roardsp_quantify_calc16(struct roardsp_filter * filter, void * data, size_t samples);
208int roardsp_quantify_ctl   (struct roardsp_filter * filter, int cmd, void * data);
209int roardsp_quantify_reset (struct roardsp_filter * filter, int what);
210
211int roardsp_clip_calc16(struct roardsp_filter * filter, void * data, size_t samples);
212int roardsp_clip_ctl   (struct roardsp_filter * filter, int cmd, void * data);
213int roardsp_clip_reset (struct roardsp_filter * filter, int what);
214
215int roardsp_downmix_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
216int roardsp_downmix_calc162(struct roardsp_filter * filter, void * data, size_t samples);
217int roardsp_downmix_ctl    (struct roardsp_filter * filter, int cmd, void * data);
218int roardsp_downmix_reset  (struct roardsp_filter * filter, int what);
219
220int roardsp_dcblock_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
221int roardsp_dcblock_uninit (struct roardsp_filter * filter);
222int roardsp_dcblock_calc16 (struct roardsp_filter * filter, void * data, size_t samples);
223int roardsp_dcblock_reset  (struct roardsp_filter * filter, int what);
224
225int roardsp_swap_init   (struct roardsp_filter * filter, struct roar_stream * stream, int id);
226int roardsp_swap_uninit (struct roardsp_filter * filter);
227int roardsp_swap_calc162(struct roardsp_filter * filter, void * data, size_t samples);
228int roardsp_swap_ctl    (struct roardsp_filter * filter, int cmd, void * data);
229int roardsp_swap_reset  (struct roardsp_filter * filter, int what);
230
231// codecs:
232int roardsp_conv_alaw2pcm16 (int16_t * out, char * in, size_t len);
233int roardsp_conv_pcm162alaw (char * out, int16_t * in, size_t len);
234
235int roardsp_conv_mulaw2pcm16 (int16_t * out, char * in, size_t len);
236int roardsp_conv_pcm162mulaw (char * out, int16_t * in, size_t len);
237
238__END_DECLS
239
240#endif
241
242//ll
Note: See TracBrowser for help on using the repository browser.