1 | //filter.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2014 |
---|
5 | * |
---|
6 | * This file is part of libroar 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 | * libroar 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, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARDSP_FILTER_H_ |
---|
37 | #define _LIBROARDSP_FILTER_H_ |
---|
38 | |
---|
39 | #include "libroardsp.h" |
---|
40 | |
---|
41 | /* implemented? */ |
---|
42 | #define ROARDSP_FILTER_NONE 0 |
---|
43 | #define ROARDSP_FILTER_AMP 1 /* yes */ |
---|
44 | #define ROARDSP_FILTER_LOWP 2 /* yes */ |
---|
45 | #define ROARDSP_FILTER_HIGHP 3 /* yes */ |
---|
46 | #define ROARDSP_FILTER_MODULATE 4 |
---|
47 | #define ROARDSP_FILTER_QUANTIFY 5 /* yes */ |
---|
48 | #define ROARDSP_FILTER_CLIP 6 /* yes */ |
---|
49 | #define ROARDSP_FILTER_ADD 7 /* yes */ |
---|
50 | #define ROARDSP_FILTER_DOWNMIX 8 /* yes */ |
---|
51 | #define ROARDSP_FILTER_DCBLOCK 9 |
---|
52 | #define ROARDSP_FILTER_SWAP 10 /* yes */ |
---|
53 | #define ROARDSP_FILTER_SPEEX_PREP 11 /* yes */ |
---|
54 | #define ROARDSP_FILTER_AGC 12 |
---|
55 | #define ROARDSP_FILTER_NOISEGATE 13 |
---|
56 | #define ROARDSP_FILTER_RESPONSE_CURVE 14 |
---|
57 | #define ROARDSP_FILTER_GOERTZEL 15 |
---|
58 | |
---|
59 | // filter CTLs: |
---|
60 | |
---|
61 | #define ROARDSP_FCTL_FREQ 1 /* float */ |
---|
62 | #define ROARDSP_FCTL_TIME 2 |
---|
63 | #define ROARDSP_FCTL_MUL 3 /* int32_t */ |
---|
64 | #define ROARDSP_FCTL_DIV 4 /* int32_t */ |
---|
65 | #define ROARDSP_FCTL_N 5 /* int32_t */ |
---|
66 | #define ROARDSP_FCTL_LIMIT 6 /* int32_t */ |
---|
67 | #define ROARDSP_FCTL_PHASE 7 |
---|
68 | #define ROARDSP_FCTL_Q 8 /* int32_t */ |
---|
69 | #define ROARDSP_FCTL_MODE 9 /* int32_t */ |
---|
70 | #define ROARDSP_FCTL_PACKET_SIZE 10 /* size_t */ |
---|
71 | |
---|
72 | // consts for filter flags: |
---|
73 | #define ROARDSP_FFLAG_NONE 0x0000 |
---|
74 | #define ROARDSP_FFLAG_FREE 0x0001 |
---|
75 | |
---|
76 | // consts for filter(chain) reset: |
---|
77 | #define ROARDSP_RESET_NONE 0 |
---|
78 | #define ROARDSP_RESET_FULL 1 |
---|
79 | #define ROARDSP_RESET_STATE 2 |
---|
80 | |
---|
81 | // filter specific constants: |
---|
82 | #define ROARDSP_DOWNMIX_LEFT 1 |
---|
83 | #define ROARDSP_DOWNMIX_RIGHT 2 |
---|
84 | #define ROARDSP_DOWNMIX_ARITHMETIC 3 |
---|
85 | #define ROARDSP_DOWNMIX_RMS 4 |
---|
86 | #define ROARDSP_DOWNMIX_ARITHMETIC_INVERSE 5 |
---|
87 | |
---|
88 | #define ROARDSP_DCBLOCK_NUMBLOCKS 100 |
---|
89 | |
---|
90 | |
---|
91 | #define ROARDSP_SPEEX_PREP_ON 0x0001 |
---|
92 | #define ROARDSP_SPEEX_PREP_OFF 0x0002 |
---|
93 | #define ROARDSP_SPEEX_PREP_MASK (ROARDSP_SPEEX_PREP_ON|ROARDSP_SPEEX_PREP_OFF) |
---|
94 | |
---|
95 | // Config Bit Vector |
---|
96 | #define ROARDSP_SPEEX_PREP_CBV(opt,sw) ((sw)<<((opt)*2)) |
---|
97 | #define ROARDSP_SPEEX_PREP_CTB(opt,val) (((val) & ROARDSP_SPEEX_PREP_CBV((opt),ROARDSP_SPEEX_PREP_MASK)) >> ((opt)*2)) |
---|
98 | |
---|
99 | #define ROARDSP_SPEEX_PREP_DENOISE 0 |
---|
100 | #define ROARDSP_SPEEX_PREP_AGC 1 |
---|
101 | #define ROARDSP_SPEEX_PREP_VAD 2 |
---|
102 | |
---|
103 | #define ROARDSP_SPEEX_PREP_DENOISE_ON ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_DENOISE, ROARDSP_SPEEX_PREP_ON) |
---|
104 | #define ROARDSP_SPEEX_PREP_DENOISE_OFF ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_DENOISE, ROARDSP_SPEEX_PREP_OFF) |
---|
105 | #define ROARDSP_SPEEX_PREP_AGC_ON ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_AGC, ROARDSP_SPEEX_PREP_ON) |
---|
106 | #define ROARDSP_SPEEX_PREP_AGC_OFF ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_AGC, ROARDSP_SPEEX_PREP_OFF) |
---|
107 | #define ROARDSP_SPEEX_PREP_VAD_ON ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_VAD, ROARDSP_SPEEX_PREP_ON) |
---|
108 | #define ROARDSP_SPEEX_PREP_VAD_OFF ROARDSP_SPEEX_PREP_CBV(ROARDSP_SPEEX_PREP_VAD, ROARDSP_SPEEX_PREP_OFF) |
---|
109 | |
---|
110 | |
---|
111 | // types: |
---|
112 | |
---|
113 | struct roardsp_filter { |
---|
114 | int channels; |
---|
115 | int bits; |
---|
116 | int rate; |
---|
117 | void * inst; |
---|
118 | uint_least16_t flags; |
---|
119 | int (*calc )(struct roardsp_filter * filter, void * data, size_t samples); |
---|
120 | int (*uninit)(struct roardsp_filter * filter); |
---|
121 | int (*ctl )(struct roardsp_filter * filter, int cmd, void * data); |
---|
122 | int (*reset )(struct roardsp_filter * filter, int what); |
---|
123 | }; |
---|
124 | |
---|
125 | |
---|
126 | // funcs: |
---|
127 | int roardsp_filter_str2id(const char * str); |
---|
128 | const char * roardsp_filter_id2str(const int id); |
---|
129 | int roardsp_filter_new (struct roardsp_filter ** filter, struct roar_stream * stream, int id); |
---|
130 | #define roardsp_filter_free(x) roardsp_filter_uninit((x)) |
---|
131 | int roardsp_filter_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
132 | int roardsp_filter_uninit(struct roardsp_filter * filter); |
---|
133 | int roardsp_filter_calc (struct roardsp_filter * filter, void * data, size_t len); |
---|
134 | int roardsp_filter_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
135 | int roardsp_filter_reset (struct roardsp_filter * filter, int what); |
---|
136 | |
---|
137 | |
---|
138 | #endif |
---|
139 | |
---|
140 | //ll |
---|