source: roaraudio/include/libroardsp/libroardsp.h @ 2425:d20795efa322

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

added libroardsp/synth.[ch]

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