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