source: roaraudio/include/libroardsp/libroardsp.h @ 922:0620585d146b

Last change on this file since 922:0620585d146b was 922:0620585d146b, checked in by phi, 15 years ago

added support for mulaw (libroardsp) and added a codec filter for roard

File size: 4.2 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
42// filter CTLs:
43
44#define ROARDSP_FCTL_FREQ             1
45#define ROARDSP_FCTL_TIME             2
46#define ROARDSP_FCTL_MUL              3
47#define ROARDSP_FCTL_DIV              4
48
49// types:
50
51struct roardsp_filter {
52 int    channels;
53 int    bits;
54 int    rate;
55 void * inst;
56 int (*calc  )(struct roardsp_filter * filter, void * data, size_t samples);
57 int (*uninit)(struct roardsp_filter * filter);
58 int (*ctl   )(struct roardsp_filter * filter, int cmd, void * data);
59};
60
61struct roardsp_filterchain {
62 int filters;
63 struct roardsp_filter * filter[ROARDSP_MAX_FILTERS_PER_CHAIN];
64};
65
66struct roardsp_lowp {
67 uint32_t freq; // in mHz (0Hz..4MHz)
68 uint16_t a, b;
69 int32_t  old[ROAR_MAX_CHANNELS];
70};
71
72struct roardsp_highp {
73 uint32_t freq; // in mHz (0Hz..4MHz)
74 int32_t  a, b, c;
75 int32_t  oldout[ROAR_MAX_CHANNELS];
76 int32_t  oldin[ROAR_MAX_CHANNELS];
77};
78
79struct roardsp_amp {
80 int32_t  mul;
81 int32_t  div;
82};
83
84// funcs:
85int    roardsp_filter_str2id(char * str);
86char * roardsp_filter_id2str(int id);
87int    roardsp_filter_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
88int    roardsp_filter_uninit(struct roardsp_filter * filter);
89int    roardsp_filter_calc  (struct roardsp_filter * filter, void * data, size_t len);
90int    roardsp_filter_ctl   (struct roardsp_filter * filter, int cmd, void * data);
91
92int roardsp_fchain_init  (struct roardsp_filterchain * chain);
93int roardsp_fchain_uninit(struct roardsp_filterchain * chain);
94int roardsp_fchain_add   (struct roardsp_filterchain * chain, struct roardsp_filter * filter);
95int roardsp_fchain_calc  (struct roardsp_filterchain * chain, void * data, size_t len);
96int roardsp_fchain_num   (struct roardsp_filterchain * chain);
97
98// filter:
99
100int roardsp_lowp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
101int roardsp_lowp_uninit(struct roardsp_filter * filter);
102int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
103int roardsp_lowp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
104
105int roardsp_highp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
106int roardsp_highp_uninit(struct roardsp_filter * filter);
107int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
108int roardsp_highp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
109
110int roardsp_amp_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id);
111int roardsp_amp_uninit(struct roardsp_filter * filter);
112int roardsp_amp_calc16(struct roardsp_filter * filter, void * data, size_t samples);
113int roardsp_amp_calc8 (struct roardsp_filter * filter, void * data, size_t samples);
114int roardsp_amp_ctl   (struct roardsp_filter * filter, int cmd, void * data);
115
116// codecs:
117int roardsp_conv_alaw2pcm16 (int16_t * out, char * in, size_t len);
118int roardsp_conv_pcm162alaw (char * out, int16_t * in, size_t len);
119
120int roardsp_conv_mulaw2pcm16 (int16_t * out, char * in, size_t len);
121int roardsp_conv_pcm162mulaw (char * out, int16_t * in, size_t len);
122
123__END_DECLS
124
125#endif
126
127//ll
Note: See TracBrowser for help on using the repository browser.