#![deny(missing_docs)]
pub extern crate cxx;
#[cxx::bridge(namespace = "gabbridge")]
mod ffi {
pub struct Params {
pub bands_per_octave: u32,
pub ff_min: f64,
pub ff_ref: f64,
pub overlap: f64,
}
#[derive(Copy,Clone,Debug,PartialEq,PartialOrd,Default)]
pub struct Coef {
pub re: f32,
pub im: f32,
}
#[derive(Copy,Clone,Debug,PartialEq,PartialOrd,Default,Eq,Ord,Hash)]
pub struct CoefMeta {
band: i32,
sample_time: i64,
}
extern "Rust" {
type ProcessOrFillCallback<'a>;
fn process_or_write_callback(cb: &mut ProcessOrFillCallback, meta: CoefMeta, coef: &mut Coef);
}
unsafe extern "C++" {
include!("gaborator-sys/src/gabbridge.h");
pub type Analyzer;
pub type Coefs;
pub fn new_analyzer(params: &Params) -> UniquePtr<Analyzer>;
pub fn get_analysis_support_len(b: &Analyzer) -> usize;
pub fn get_synthesis_support_len(b: &Analyzer) -> usize;
pub fn create_coefs(b: &Analyzer) -> UniquePtr<Coefs>;
pub fn forget_before(b: &Analyzer, c: Pin<&mut Coefs>, limit: i64, clean_cut: bool);
pub fn process(
coefs: Pin<&mut Coefs>,
from_band: i32,
to_band: i32,
from_sample_time: i64,
to_sample_time: i64,
callback: &mut ProcessOrFillCallback,
);
pub fn fill(
coefs: Pin<&mut Coefs>,
from_band: i32,
to_band: i32,
from_sample_time: i64,
to_sample_time: i64,
callback: &mut ProcessOrFillCallback,
);
pub fn analyze(
b : &Analyzer,
signal: &[f32],
signal_begin_sample_number: i64,
coefs: Pin<&mut Coefs>,
);
pub fn synthesize(
b : &Analyzer,
coefs: &Coefs,
signal_begin_sample_number: i64,
signal: &mut [f32],
);
pub fn bandpass_bands_begin(b : &Analyzer) -> i32;
pub fn bandpass_bands_end(b : &Analyzer) -> i32;
pub fn band_lowpass(b : &Analyzer) -> i32;
pub fn band_ref(b : &Analyzer) -> i32;
pub fn band_ff(b : &Analyzer, band: i32) -> f64;
}
}
pub use ffi::*;
pub struct ProcessOrFillCallback<'a>(pub Box<dyn FnMut(CoefMeta, &mut Coef) + 'a>);
fn process_or_write_callback(cb: &mut ProcessOrFillCallback, meta: CoefMeta, coef: &mut Coef) {
cb.0(meta, coef);
}