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