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_getFilterBank(
66 FilterFracs: c_int,
67 ElementSize: c_int,
68 InterpPoints: c_int,
69 ReqAtten: f64,
70 IsThird: c_int,
71 IsStatic: c_int,
72 ) -> *mut HCDSPFracDelayFilterBank;
73
74 pub fn realFFTKeeper_create() -> *mut HCDSPRealFFTKeeper;
75 pub fn realFFTKeeper_createWithLen(LenBits: c_int) -> *mut HCDSPRealFFTKeeper;
78 pub fn realFFTKeeper_destroy(keeper: *mut HCDSPRealFFTKeeper);
79 pub fn realFFTKeeper_init(keeper: *mut HCDSPRealFFTKeeper, LenBits: c_int);
80 pub fn realFFTKeeper_reset(keeper: *mut HCDSPRealFFTKeeper);
81 pub fn realFFTKeeper_getInvMulConst(keeper: *const HCDSPRealFFTKeeper) -> f64;
82 pub fn realFFTKeeper_getLenBits(keeper: *const HCDSPRealFFTKeeper) -> c_int;
83 pub fn realFFTKeeper_getLen(keeper: *const HCDSPRealFFTKeeper) -> c_int;
84 pub fn realFFTKeeper_forward(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
87 pub fn realFFTKeeper_inverse(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
90 pub fn realFFTKeeper_multiplyBlocks(
91 keeper: *const HCDSPRealFFTKeeper,
92 input1: *const f64,
93 input2: *const f64,
94 output: *mut f64,
95 );
96 pub fn realFFTKeeper_multiplyBlocksInplace(
97 keeper: *const HCDSPRealFFTKeeper,
98 input: *const f64,
99 input_output: *mut f64,
100 );
101 pub fn realFFTKeeper_multiplyBlocksZP(
102 keeper: *const HCDSPRealFFTKeeper,
103 zero_phase_input: *const f64,
104 input_output: *mut f64,
105 );
106 pub fn realFFTKeeper_convertToZP(keeper: *const HCDSPRealFFTKeeper, block: *mut f64);
107
108 pub fn sincFilterGen_create() -> *mut HCDSPSincFilterGen;
109 pub fn sincFilterGen_destroy(generator: *mut HCDSPSincFilterGen);
110 pub fn sincFilterGen_setLen2(generator: *mut HCDSPSincFilterGen, Len2: f64);
111 pub fn sincFilterGen_getLen2(generator: *const HCDSPSincFilterGen) -> f64;
112 pub fn sincFilterGen_getKernelLen(generator: *const HCDSPSincFilterGen) -> c_int;
113 pub fn sincFilterGen_getHalfKernelLen(generator: *const HCDSPSincFilterGen) -> c_int;
114 pub fn sincFilterGen_setFreq1(generator: *mut HCDSPSincFilterGen, Freq1: f64);
115 pub fn sincFilterGen_getFreq1(generator: *const HCDSPSincFilterGen) -> f64;
116 pub fn sincFilterGen_setFreq2(generator: *mut HCDSPSincFilterGen, Freq2: f64);
117 pub fn sincFilterGen_getFreq2(generator: *const HCDSPSincFilterGen) -> f64;
118 pub fn sincFilterGen_setFracDelay(generator: *mut HCDSPSincFilterGen, FracDelay: f64);
119 pub fn sincFilterGen_getFracDelay(generator: *const HCDSPSincFilterGen) -> f64;
120 pub fn sincFilterGen_initWindow(
121 generator: *mut HCDSPSincFilterGen,
122 WinType: EWindowFunctionType,
123 Params: *const f64,
124 UsePower: c_int,
125 );
126 pub fn sincFilterGen_initBand(
127 generator: *mut HCDSPSincFilterGen,
128 WinType: EWindowFunctionType,
129 Params: *const f64,
130 UsePower: c_int,
131 );
132 pub fn sincFilterGen_initHilbert(
133 generator: *mut HCDSPSincFilterGen,
134 WinType: EWindowFunctionType,
135 Params: *const f64,
136 UsePower: c_int,
137 );
138 pub fn sincFilterGen_initFrac(
139 generator: *mut HCDSPSincFilterGen,
140 WinType: EWindowFunctionType,
141 Params: *const f64,
142 UsePower: c_int,
143 );
144 pub fn sincFilterGen_calcWindow(
145 generator: *mut HCDSPSincFilterGen,
146 calculator: EWindowCalculator,
147 ) -> f64;
148 pub fn sincFilterGen_calcWindowHann(generator: *mut HCDSPSincFilterGen) -> f64;
149 pub fn sincFilterGen_calcWindowHamming(generator: *mut HCDSPSincFilterGen) -> f64;
150 pub fn sincFilterGen_calcWindowBlackman(generator: *mut HCDSPSincFilterGen) -> f64;
151 pub fn sincFilterGen_calcWindowNuttall(generator: *mut HCDSPSincFilterGen) -> f64;
152 pub fn sincFilterGen_calcWindowBlackmanNuttall(generator: *mut HCDSPSincFilterGen) -> f64;
153 pub fn sincFilterGen_calcWindowKaiser(generator: *mut HCDSPSincFilterGen) -> f64;
154 pub fn sincFilterGen_calcWindowGaussian(generator: *mut HCDSPSincFilterGen) -> f64;
155 pub fn sincFilterGen_generateWindow(
156 generator: *mut HCDSPSincFilterGen,
157 output: *mut f64,
158 calculator: EWindowCalculator,
159 );
160 pub fn sincFilterGen_generateBand(
161 generator: *mut HCDSPSincFilterGen,
162 output: *mut f64,
163 calculator: EWindowCalculator,
164 );
165 pub fn sincFilterGen_generateHilbert(
166 generator: *mut HCDSPSincFilterGen,
167 output: *mut f64,
168 calculator: EWindowCalculator,
169 );
170 pub fn sincFilterGen_generateFrac(
171 generator: *mut HCDSPSincFilterGen,
172 output: *mut f64,
173 calculator: EWindowCalculator,
174 OutputIncrement: c_int,
175 );
176
177 pub fn sineGen_create() -> *mut HCSineGen;
178 pub fn sineGen_createUnity(increment: f64, phase: f64) -> *mut HCSineGen;
179 pub fn sineGen_createWithGain(increment: f64, phase: f64, gain: f64) -> *mut HCSineGen;
180 pub fn sineGen_destroy(generator: *mut HCSineGen);
181 pub fn sineGen_init(generator: *mut HCSineGen, increment: f64, phase: f64);
182 pub fn sineGen_initWithGain(generator: *mut HCSineGen, increment: f64, phase: f64, gain: f64);
183 pub fn sineGen_generate(generator: *mut HCSineGen) -> f64;
184
185 pub fn calcFIRFilterResponse(
186 filter: *const f64,
187 FilterLen: c_int,
188 CircularFrequency: f64,
189 real: *mut f64,
190 imaginary: *mut f64,
191 FilterLatency: c_int,
192 );
193 pub fn calcFIRFilterGroupDelay(
194 filter: *const f64,
195 FilterLen: c_int,
196 CircularFrequency: f64,
197 ) -> f64;
198 pub fn normalizeFIRFilter(filter: *mut f64, FilterLen: c_int, DCGain: f64, ElementStep: c_int);
199 pub fn calcSpline3p8Coeffs(
200 coefficients: *mut f64,
201 xm3: f64,
202 xm2: f64,
203 xm1: f64,
204 x0: f64,
205 x1: f64,
206 x2: f64,
207 x3: f64,
208 x4: f64,
209 );
210 pub fn calcSpline2p8Coeffs(
211 coefficients: *mut f64,
212 xm3: f64,
213 xm2: f64,
214 xm1: f64,
215 x0: f64,
216 x1: f64,
217 x2: f64,
218 x3: f64,
219 x4: f64,
220 );
221 pub fn calcSpline3p4Coeffs(coefficients: *mut f64, points: *const f64);
222 pub fn calcSpline3p6Coeffs(coefficients: *mut f64, points: *const f64);
223 pub fn calcMinPhaseTransform(
224 kernel: *mut f64,
225 KernelLen: c_int,
226 LenMultiplier: c_int,
227 DoFinalMultiply: c_int,
228 DCGroupDelay: *mut f64,
229 );
230 pub fn findGCD(larger: f64, smaller: f64, gcd: *mut f64) -> c_int;
231 pub fn getWholeStepping(
232 SrcSampleRate: f64,
233 DstSampleRate: f64,
234 InputStep: *mut c_int,
235 OutputStep: *mut c_int,
236 ) -> c_int;
237 pub fn clampr(value: f64, minimum: f64, maximum: f64) -> f64;
238 pub fn sqr(value: f64) -> f64;
239 pub fn pow_a(value: f64, power: f64) -> f64;
240 pub fn gauss(value: f64) -> f64;
241 pub fn getBitOccupancy(value: c_int) -> c_int;
242 pub fn r8b_asinh(value: f64) -> f64;
244 pub fn besselI0(value: f64) -> f64;
245 pub fn convertResponseToLog(real: f64, imaginary: f64) -> f64;
246 pub fn updateScanStep(
247 step: *mut f64,
248 CurrentGainSquared: f64,
249 PreviousGainLog: *mut f64,
250 Precision: f64,
251 MaximumStep: f64,
252 MinimumStep: f64,
253 );
254 pub fn findFIRFilterResponseMinLtoR(
255 filter: *const f64,
256 FilterLen: c_int,
257 MinimumGainSquared: *mut f64,
258 NormalizedFrequency: *mut f64,
259 EndingFrequency: f64,
260 );
261 pub fn findFIRFilterResponseMaxLtoR(
262 filter: *const f64,
263 FilterLen: c_int,
264 MaximumGainSquared: *mut f64,
265 NormalizedFrequency: *mut f64,
266 EndingFrequency: f64,
267 );
268 pub fn findFIRFilterResponseLevelRtoL(
269 filter: *const f64,
270 FilterLen: c_int,
271 MaximumGainSquared: f64,
272 NormalizedFrequency: *mut f64,
273 EndingFrequency: f64,
274 );
275}