1 | //libroardsp.h: |
---|
2 | |
---|
3 | #ifndef _LIBROARDSP_H_ |
---|
4 | #define _LIBROARDSP_H_ |
---|
5 | |
---|
6 | #include <roaraudio.h> |
---|
7 | |
---|
8 | #include "midi.h" |
---|
9 | |
---|
10 | // defines |
---|
11 | #define ROARDSP_MAX_FILTERS_PER_CHAIN 8 |
---|
12 | |
---|
13 | #define ROARDSP_FILTER_NONE 0 |
---|
14 | #define ROARDSP_FILTER_AMP 1 |
---|
15 | #define ROARDSP_FILTER_LOWP 2 |
---|
16 | #define ROARDSP_FILTER_HIGHP 3 |
---|
17 | |
---|
18 | // filter CTLs: |
---|
19 | |
---|
20 | #define ROARDSP_FCTL_FREQ 1 |
---|
21 | #define ROARDSP_FCTL_TIME 2 |
---|
22 | #define ROARDSP_FCTL_MUL 3 |
---|
23 | #define ROARDSP_FCTL_DIV 4 |
---|
24 | |
---|
25 | // types: |
---|
26 | |
---|
27 | struct roardsp_filter { |
---|
28 | int channels; |
---|
29 | int bits; |
---|
30 | int rate; |
---|
31 | void * inst; |
---|
32 | int (*calc )(struct roardsp_filter * filter, void * data, size_t samples); |
---|
33 | int (*uninit)(struct roardsp_filter * filter); |
---|
34 | int (*ctl )(struct roardsp_filter * filter, int cmd, void * data); |
---|
35 | }; |
---|
36 | |
---|
37 | struct roardsp_filterchain { |
---|
38 | int filters; |
---|
39 | struct roardsp_filter * filter[ROARDSP_MAX_FILTERS_PER_CHAIN]; |
---|
40 | }; |
---|
41 | |
---|
42 | struct roardsp_lowp { |
---|
43 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
44 | uint16_t a, b; |
---|
45 | int32_t old[ROAR_MAX_CHANNELS]; |
---|
46 | }; |
---|
47 | |
---|
48 | struct roardsp_highp { |
---|
49 | uint32_t freq; // in mHz (0Hz..4MHz) |
---|
50 | int32_t a, b, c; |
---|
51 | int32_t oldout[ROAR_MAX_CHANNELS]; |
---|
52 | int32_t oldin[ROAR_MAX_CHANNELS]; |
---|
53 | }; |
---|
54 | |
---|
55 | // funcs: |
---|
56 | int roardsp_filter_str2id(char * str); |
---|
57 | char * roardsp_filter_id2str(int id); |
---|
58 | int roardsp_filter_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
59 | int roardsp_filter_uninit(struct roardsp_filter * filter); |
---|
60 | int roardsp_filter_calc (struct roardsp_filter * filter, void * data, size_t len); |
---|
61 | int roardsp_filter_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
62 | |
---|
63 | int roardsp_fchain_init (struct roardsp_filterchain * chain); |
---|
64 | int roardsp_fchain_uninit(struct roardsp_filterchain * chain); |
---|
65 | int roardsp_fchain_add (struct roardsp_filterchain * chain, struct roardsp_filter * filter); |
---|
66 | int roardsp_fchain_calc (struct roardsp_filterchain * chain, void * data, size_t len); |
---|
67 | int roardsp_fchain_num (struct roardsp_filterchain * chain); |
---|
68 | |
---|
69 | // filter: |
---|
70 | |
---|
71 | int roardsp_lowp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
72 | int roardsp_lowp_uninit(struct roardsp_filter * filter); |
---|
73 | int roardsp_lowp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
74 | int roardsp_lowp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
75 | |
---|
76 | int roardsp_highp_init (struct roardsp_filter * filter, struct roar_stream * stream, int id); |
---|
77 | int roardsp_highp_uninit(struct roardsp_filter * filter); |
---|
78 | int roardsp_highp_calc16(struct roardsp_filter * filter, void * data, size_t samples); |
---|
79 | int roardsp_highp_ctl (struct roardsp_filter * filter, int cmd, void * data); |
---|
80 | |
---|
81 | #endif |
---|
82 | |
---|
83 | //ll |
---|