source: roaraudio/include/libroardsp/libroardsp.h @ 1131:bca464362519

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

added support to reset a filter(chain) :), works only for dcblock at the moment :(

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