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