source: roaraudio/include/libroardsp/libroardsp.h @ 2424:ebf8be51199e

Last change on this file since 2424:ebf8be51199e was 2386:0ff0440ba500, checked in by phi, 15 years ago

added SRC (libsamplerate) based resampler

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