1use core::ffi::c_int;
2
3use crate::HCDSPFIRFilter;
4
5macro_rules! opaque {
6 ($($name:ident),+ $(,)?) => {$(
7 #[repr(C)]
8 #[derive(Debug)]
9 pub struct $name { _unused: [u8; 0] }
10 )+};
11}
12
13opaque!(
14 HCDSPBlockConvolver,
15 HCDSPHBDownsampler,
16 HCDSPHBUpsampler,
17 HCDSPFracInterpolator,
18);
19
20unsafe extern "C" {
21 pub fn blockConvolver_create(
23 filter: *mut HCDSPFIRFilter,
24 UpFactor: c_int,
25 DownFactor: c_int,
26 PrevLatency: f64,
27 DoConsumeLatency: c_int,
28 ) -> *mut HCDSPBlockConvolver;
29
30 pub fn hbDownsampler_create(
31 ReqAtten: f64,
32 SteepIndex: c_int,
33 IsThird: c_int,
34 PrevLatency: f64,
35 ) -> *mut HCDSPHBDownsampler;
36
37 pub fn hbUpsampler_getHBFilter(
39 ReqAtten: f64,
40 SteepIndex: c_int,
41 filter: *mut *const f64,
42 FilterLen: *mut c_int,
43 ActualAtten: *mut f64,
44 );
45 pub fn hbUpsampler_getHBFilterThird(
47 ReqAtten: f64,
48 SteepIndex: c_int,
49 filter: *mut *const f64,
50 FilterLen: *mut c_int,
51 ActualAtten: *mut f64,
52 );
53 pub fn hbUpsampler_create(
54 ReqAtten: f64,
55 SteepIndex: c_int,
56 IsThird: c_int,
57 PrevLatency: f64,
58 DoConsumeLatency: c_int,
59 ) -> *mut HCDSPHBUpsampler;
60
61 pub fn fracInterpolator_create(
62 SrcSampleRate: f64,
63 DstSampleRate: f64,
64 ReqAtten: f64,
65 IsThird: c_int,
66 PrevLatency: f64,
67 ) -> *mut HCDSPFracInterpolator;
68}
69
70macro_rules! declare_processor_methods {
71 ($handle:ty; $destroy:ident, $before_pos:ident, $latency:ident,
72 $latency_frac:ident, $max_out:ident, $clear:ident, $process:ident) => {
73 unsafe extern "C" {
74 pub fn $destroy(processor: *mut $handle);
75 pub fn $before_pos(processor: *mut $handle, ReqOutPos: c_int) -> c_int;
76 pub fn $latency(processor: *mut $handle) -> c_int;
77 pub fn $latency_frac(processor: *mut $handle) -> f64;
78 pub fn $max_out(processor: *mut $handle, MaxInLen: c_int) -> c_int;
79 pub fn $clear(processor: *mut $handle);
80 pub fn $process(
81 processor: *mut $handle,
82 input: *mut f64,
83 InputLen: c_int,
84 output: *mut *mut f64,
85 ) -> c_int;
86 }
87 };
88}
89
90declare_processor_methods!(HCDSPBlockConvolver;
91 blockConvolver_destroy, blockConvolver_getInLenBeforeOutPos,
92 blockConvolver_getLatency, blockConvolver_getLatencyFrac,
93 blockConvolver_getMaxOutLen, blockConvolver_clear, blockConvolver_process);
94declare_processor_methods!(HCDSPHBDownsampler;
95 hbDownsampler_destroy, hbDownsampler_getInLenBeforeOutPos,
96 hbDownsampler_getLatency, hbDownsampler_getLatencyFrac,
97 hbDownsampler_getMaxOutLen, hbDownsampler_clear, hbDownsampler_process);
98declare_processor_methods!(HCDSPHBUpsampler;
99 hbUpsampler_destroy, hbUpsampler_getInLenBeforeOutPos,
100 hbUpsampler_getLatency, hbUpsampler_getLatencyFrac,
101 hbUpsampler_getMaxOutLen, hbUpsampler_clear, hbUpsampler_process);
102declare_processor_methods!(HCDSPFracInterpolator;
103 fracInterpolator_destroy, fracInterpolator_getInLenBeforeOutPos,
104 fracInterpolator_getLatency, fracInterpolator_getLatencyFrac,
105 fracInterpolator_getMaxOutLen, fracInterpolator_clear,
106 fracInterpolator_process);