source: roaraudio/include/libroardsp/libroardsp.h @ 2434:3c90edfde81d

Last change on this file since 2434:3c90edfde81d was 2434:3c90edfde81d, checked in by phi, 15 years ago

added libroardsp/fader.[ch]

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