1use core::ffi::c_int;
2
3use crate::{EDSPFilterPhaseResponse, EWindowCalculator, EWindowFunctionType};
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 HCDSPFIRFilter,
15 HCDSPFracDelayFilterBank,
16 HCDSPRealFFTKeeper,
17 HCDSPSincFilterGen,
18 HCSineGen,
19);
20
21unsafe extern "C" {
22 pub fn firFilter_getLPMinTransBand() -> f64;
23 pub fn firFilter_getLPMaxTransBand() -> f64;
24 pub fn firFilter_getLPMinAtten() -> f64;
25 pub fn firFilter_getLPMaxAtten() -> f64;
26 pub fn firFilter_isZeroPhase(filter: *const HCDSPFIRFilter) -> c_int;
27 pub fn firFilter_getLatency(filter: *const HCDSPFIRFilter) -> c_int;
28 pub fn firFilter_getLatencyFrac(filter: *const HCDSPFIRFilter) -> f64;
29 pub fn firFilter_getKernelLen(filter: *const HCDSPFIRFilter) -> c_int;
30 pub fn firFilter_getBlockLenBits(filter: *const HCDSPFIRFilter) -> c_int;
31 pub fn firFilter_getKernelBlock(filter: *const HCDSPFIRFilter) -> *const f64;
33 pub fn firFilter_unref(filter: *mut HCDSPFIRFilter);
35 pub fn firFilterCache_getObjCount() -> c_int;
36 pub fn firFilterCache_getLPFilter(
38 ReqNormFreq: f64,
39 ReqTransBand: f64,
40 ReqAtten: f64,
41 ReqPhase: EDSPFilterPhaseResponse,
42 ReqGain: f64,
43 AttenCorrs: *const f64,
44 ) -> *mut HCDSPFIRFilter;
45
46 pub fn fracDelayFilterBank_create(
47 FilterFracs: c_int,
48 ElementSize: c_int,
49 InterpPoints: c_int,
50 ReqAtten: f64,
51 IsThird: c_int,
52 ) -> *mut HCDSPFracDelayFilterBank;
53 pub fn fracDelayFilterBank_destroy(bank: *mut HCDSPFracDelayFilterBank);
55 pub fn fracDelayFilterBank_roundReqAtten(attenuation: *mut f64, IsThird: c_int);
56 pub fn fracDelayFilterBank_getFilterLen(bank: *const HCDSPFracDelayFilterBank) -> c_int;
57 pub fn fracDelayFilterBank_getFilterFracs(bank: *const HCDSPFracDelayFilterBank) -> c_int;
58 pub fn fracDelayFilterBank_getFilter(
60 bank: *const HCDSPFracDelayFilterBank,
61 index: c_int,
62 ) -> *const f64;
63 pub fn fracDelayFilterBank_unref(bank: *mut HCDSPFracDelayFilterBank);
65 pub fn fracDelayFilterBankCache_getObjCount() -> c_int;
66 pub fn fracDelayFilterBankCache_getFilterBank(
67 FilterFracs: c_int,
68 ElementSize: c_int,
69 InterpPoints: c_int,
70 ReqAtten: f64,
71 IsThird: c_int,
72 IsStatic: c_int,
73 ) -> *mut HCDSPFracDelayFilterBank;
74
75 pub fn realFFTKeeper_create() -> *mut HCDSPRealFFTKeeper;
76 pub fn realFFTKeeper_createWithLen(LenBits: c_int) -> *mut HCDSPRealFFTKeeper;
79 pub fn realFFTKeeper_destroy(keeper: *mut HCDSPRealFFTKeeper);
80 pub fn realFFTKeeper_init(keeper: *mut HCDSPRealFFTKeeper, LenBits: c_int);
81 pub fn realFFTKeeper_reset(keeper: *mut HCDSPRealFFTKeeper);
82 pub fn realFFTKeeper_getInvMulConst(keeper: *const HCDSPRealFFTKeeper) -> f64;
83 pub fn realFFTKeeper_getLenBits(keeper: *const HCDSPRealFFTKeeper) -> c_int;
84 pub fn realFFTKeeper_getLen(keeper: *const HCDSPRealFFTKeeper) -> c_int;
85 pub fn realFFTKeeper_forward(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
88 pub fn realFFTKeeper_inverse(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
91 pub fn realFFTKeeper_multiplyBlocks(
92 keeper: *const HCDSPRealFFTKeeper,
93 input1: *const f64,
94 input2: *const f64,
95 output: *mut f64,
96 );
97 pub fn realFFTKeeper_multiplyBlocksInplace(
98 keeper: *const HCDSPRealFFTKeeper,
99 input: *const f64,
100 input_output: *mut f64,
101 );
102 pub fn realFFTKeeper_multiplyBlocksZP(
103 keeper: *const HCDSPRealFFTKeeper,
104 zero_phase_input: *const f64,
105 input_output: *mut f64,
106 );
107 pub fn realFFTKeeper_convertToZP(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
108
109 pub fn sincFilterGen_create() -> *mut HCDSPSincFilterGen;
110 pub fn sincFilterGen_destroy(generator: *mut HCDSPSincFilterGen);
111 pub fn sincFilterGen_setLen2(generator: *mut HCDSPSincFilterGen, Len2: f64);
112 pub fn sincFilterGen_getLen2(generator: *const HCDSPSincFilterGen) -> f64;
113 pub fn sincFilterGen_getKernelLen(generator: *const HCDSPSincFilterGen) -> c_int;
114 pub fn sincFilterGen_getHalfKernelLen(generator: *const HCDSPSincFilterGen) -> c_int;
115 pub fn sincFilterGen_setFreq1(generator: *mut HCDSPSincFilterGen, Freq1: f64);
116 pub fn sincFilterGen_getFreq1(generator: *const HCDSPSincFilterGen) -> f64;
117 pub fn sincFilterGen_setFreq2(generator: *mut HCDSPSincFilterGen, Freq2: f64);
118 pub fn sincFilterGen_getFreq2(generator: *const HCDSPSincFilterGen) -> f64;
119 pub fn sincFilterGen_setFracDelay(generator: *mut HCDSPSincFilterGen, FracDelay: f64);
120 pub fn sincFilterGen_getFracDelay(generator: *const HCDSPSincFilterGen) -> f64;
121 pub fn sincFilterGen_initWindow(
122 generator: *mut HCDSPSincFilterGen,
123 WinType: EWindowFunctionType,
124 Params: *const f64,
125 UsePower: c_int,
126 );
127 pub fn sincFilterGen_initBand(
128 generator: *mut HCDSPSincFilterGen,
129 WinType: EWindowFunctionType,
130 Params: *const f64,
131 UsePower: c_int,
132 );
133 pub fn sincFilterGen_initHilbert(
134 generator: *mut HCDSPSincFilterGen,
135 WinType: EWindowFunctionType,
136 Params: *const f64,
137 UsePower: c_int,
138 );
139 pub fn sincFilterGen_initFrac(
140 generator: *mut HCDSPSincFilterGen,
141 WinType: EWindowFunctionType,
142 Params: *const f64,
143 UsePower: c_int,
144 );
145 pub fn sincFilterGen_calcWindow(
146 generator: *mut HCDSPSincFilterGen,
147 calculator: EWindowCalculator,
148 ) -> f64;
149 pub fn sincFilterGen_calcWindowHann(generator: *mut HCDSPSincFilterGen) -> f64;
150 pub fn sincFilterGen_calcWindowHamming(generator: *mut HCDSPSincFilterGen) -> f64;
151 pub fn sincFilterGen_calcWindowBlackman(generator: *mut HCDSPSincFilterGen) -> f64;
152 pub fn sincFilterGen_calcWindowNuttall(generator: *mut HCDSPSincFilterGen) -> f64;
153 pub fn sincFilterGen_calcWindowBlackmanNuttall(generator: *mut HCDSPSincFilterGen) -> f64;
154 pub fn sincFilterGen_calcWindowKaiser(generator: *mut HCDSPSincFilterGen) -> f64;
155 pub fn sincFilterGen_calcWindowGaussian(generator: *mut HCDSPSincFilterGen) -> f64;
156 pub fn sincFilterGen_generateWindow(
157 generator: *mut HCDSPSincFilterGen,
158 output: *mut f64,
159 calculator: EWindowCalculator,
160 );
161 pub fn sincFilterGen_generateBand(
162 generator: *mut HCDSPSincFilterGen,
163 output: *mut f64,
164 calculator: EWindowCalculator,
165 );
166 pub fn sincFilterGen_generateHilbert(
167 generator: *mut HCDSPSincFilterGen,
168 output: *mut f64,
169 calculator: EWindowCalculator,
170 );
171 pub fn sincFilterGen_generateFrac(
172 generator: *mut HCDSPSincFilterGen,
173 output: *mut f64,
174 calculator: EWindowCalculator,
175 OutputIncrement: c_int,
176 );
177
178 pub fn sineGen_create() -> *mut HCSineGen;
179 pub fn sineGen_createUnity(increment: f64, phase: f64) -> *mut HCSineGen;
180 pub fn sineGen_createWithGain(increment: f64, phase: f64, gain: f64) -> *mut HCSineGen;
181 pub fn sineGen_destroy(generator: *mut HCSineGen);
182 pub fn sineGen_init(generator: *mut HCSineGen, increment: f64, phase: f64);
183 pub fn sineGen_initWithGain(generator: *mut HCSineGen, increment: f64, phase: f64, gain: f64);
184 pub fn sineGen_generate(generator: *mut HCSineGen) -> f64;
185
186 pub fn calcFIRFilterResponse(
187 filter: *const f64,
188 FilterLen: c_int,
189 CircularFrequency: f64,
190 real: *mut f64,
191 imaginary: *mut f64,
192 FilterLatency: c_int,
193 );
194 pub fn calcFIRFilterGroupDelay(
195 filter: *const f64,
196 FilterLen: c_int,
197 CircularFrequency: f64,
198 ) -> f64;
199 pub fn normalizeFIRFilter(filter: *mut f64, FilterLen: c_int, DCGain: f64, ElementStep: c_int);
200 pub fn calcSpline3p8Coeffs(
201 coefficients: *mut f64,
202 xm3: f64,
203 xm2: f64,
204 xm1: f64,
205 x0: f64,
206 x1: f64,
207 x2: f64,
208 x3: f64,
209 x4: f64,
210 );
211 pub fn calcSpline2p8Coeffs(
212 coefficients: *mut f64,
213 xm3: f64,
214 xm2: f64,
215 xm1: f64,
216 x0: f64,
217 x1: f64,
218 x2: f64,
219 x3: f64,
220 x4: f64,
221 );
222 pub fn calcSpline3p4Coeffs(coefficients: *mut f64, points: *const f64);
223 pub fn calcSpline3p6Coeffs(coefficients: *mut f64, points: *const f64);
224 pub fn calcMinPhaseTransform(
225 kernel: *mut f64,
226 KernelLen: c_int,
227 LenMultiplier: c_int,
228 DoFinalMultiply: c_int,
229 DCGroupDelay: *mut f64,
230 );
231 pub fn findGCD(larger: f64, smaller: f64, gcd: *mut f64) -> c_int;
232 pub fn getWholeStepping(
233 SrcSampleRate: f64,
234 DstSampleRate: f64,
235 InputStep: *mut c_int,
236 OutputStep: *mut c_int,
237 ) -> c_int;
238 pub fn clampr(value: f64, minimum: f64, maximum: f64) -> f64;
239 pub fn sqr(value: f64) -> f64;
240 pub fn pow_a(value: f64, power: f64) -> f64;
241 pub fn gauss(value: f64) -> f64;
242 pub fn getBitOccupancy(value: c_int) -> c_int;
243 pub fn r8b_asinh(value: f64) -> f64;
245 pub fn besselI0(value: f64) -> f64;
246 pub fn convertResponseToLog(real: f64, imaginary: f64) -> f64;
247 pub fn updateScanStep(
248 step: *mut f64,
249 CurrentGainSquared: f64,
250 PreviousGainLog: *mut f64,
251 Precision: f64,
252 MaximumStep: f64,
253 MinimumStep: f64,
254 );
255 pub fn findFIRFilterResponseMinLtoR(
256 filter: *const f64,
257 FilterLen: c_int,
258 MinimumGainSquared: *mut f64,
259 NormalizedFrequency: *mut f64,
260 EndingFrequency: f64,
261 );
262 pub fn findFIRFilterResponseMaxLtoR(
263 filter: *const f64,
264 FilterLen: c_int,
265 MaximumGainSquared: *mut f64,
266 NormalizedFrequency: *mut f64,
267 EndingFrequency: f64,
268 );
269 pub fn findFIRFilterResponseLevelRtoL(
270 filter: *const f64,
271 FilterLen: c_int,
272 MaximumGainSquared: f64,
273 NormalizedFrequency: *mut f64,
274 EndingFrequency: f64,
275 );
276}