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