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