use core::ffi::c_int;
use crate::HCDSPFIRFilter;
macro_rules! opaque {
($($name:ident),+ $(,)?) => {$(
#[repr(C)]
#[derive(Debug)]
pub struct $name { _unused: [u8; 0] }
)+};
}
opaque!(
HCDSPBlockConvolver,
HCDSPHBDownsampler,
HCDSPHBUpsampler,
HCDSPFracInterpolator,
);
unsafe extern "C" {
pub fn blockConvolver_create(
filter: *mut HCDSPFIRFilter,
UpFactor: c_int,
DownFactor: c_int,
PrevLatency: f64,
DoConsumeLatency: c_int,
) -> *mut HCDSPBlockConvolver;
pub fn hbDownsampler_create(
ReqAtten: f64,
SteepIndex: c_int,
IsThird: c_int,
PrevLatency: f64,
) -> *mut HCDSPHBDownsampler;
pub fn hbUpsampler_getHBFilter(
ReqAtten: f64,
SteepIndex: c_int,
filter: *mut *const f64,
FilterLen: *mut c_int,
ActualAtten: *mut f64,
);
pub fn hbUpsampler_getHBFilterThird(
ReqAtten: f64,
SteepIndex: c_int,
filter: *mut *const f64,
FilterLen: *mut c_int,
ActualAtten: *mut f64,
);
pub fn hbUpsampler_create(
ReqAtten: f64,
SteepIndex: c_int,
IsThird: c_int,
PrevLatency: f64,
DoConsumeLatency: c_int,
) -> *mut HCDSPHBUpsampler;
pub fn fracInterpolator_create(
SrcSampleRate: f64,
DstSampleRate: f64,
ReqAtten: f64,
IsThird: c_int,
PrevLatency: f64,
) -> *mut HCDSPFracInterpolator;
}
macro_rules! declare_processor_methods {
($handle:ty; $destroy:ident, $before_pos:ident, $latency:ident,
$latency_frac:ident, $max_out:ident, $clear:ident, $process:ident) => {
unsafe extern "C" {
pub fn $destroy(processor: *mut $handle);
pub fn $before_pos(processor: *mut $handle, ReqOutPos: c_int) -> c_int;
pub fn $latency(processor: *mut $handle) -> c_int;
pub fn $latency_frac(processor: *mut $handle) -> f64;
pub fn $max_out(processor: *mut $handle, MaxInLen: c_int) -> c_int;
pub fn $clear(processor: *mut $handle);
pub fn $process(
processor: *mut $handle,
input: *mut f64,
InputLen: c_int,
output: *mut *mut f64,
) -> c_int;
}
};
}
declare_processor_methods!(HCDSPBlockConvolver;
blockConvolver_destroy, blockConvolver_getInLenBeforeOutPos,
blockConvolver_getLatency, blockConvolver_getLatencyFrac,
blockConvolver_getMaxOutLen, blockConvolver_clear, blockConvolver_process);
declare_processor_methods!(HCDSPHBDownsampler;
hbDownsampler_destroy, hbDownsampler_getInLenBeforeOutPos,
hbDownsampler_getLatency, hbDownsampler_getLatencyFrac,
hbDownsampler_getMaxOutLen, hbDownsampler_clear, hbDownsampler_process);
declare_processor_methods!(HCDSPHBUpsampler;
hbUpsampler_destroy, hbUpsampler_getInLenBeforeOutPos,
hbUpsampler_getLatency, hbUpsampler_getLatencyFrac,
hbUpsampler_getMaxOutLen, hbUpsampler_clear, hbUpsampler_process);
declare_processor_methods!(HCDSPFracInterpolator;
fracInterpolator_destroy, fracInterpolator_getInLenBeforeOutPos,
fracInterpolator_getLatency, fracInterpolator_getLatencyFrac,
fracInterpolator_getMaxOutLen, fracInterpolator_clear,
fracInterpolator_process);