source: roaraudio/include/libroardsp/libroardsp.h @ 2929:0604dc93150d

Last change on this file since 2929:0604dc93150d was 2929:0604dc93150d, checked in by phi, 15 years ago

added mixer.h

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