source: roaraudio/include/libroardsp/libroardsp.h @ 2316:f44a26194be9

Last change on this file since 2316:f44a26194be9 was 2316:f44a26194be9, checked in by phi, 15 years ago

added header files for RMS calcing

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