#![deny(missing_docs)]
pub use gaborator_sys::{Coef, CoefMeta, Params as GaboratorParams};
pub struct Coefs(gaborator_sys::cxx::UniquePtr<gaborator_sys::Coefs>);
impl Coefs {
pub fn new(gab: &Gaborator) -> Self {
Coefs(
gaborator_sys::create_coefs(&*gab.0)
)
}
pub fn forget_before(&mut self, g:&Gaborator, limit: i64, clean_cut: bool)
{
gaborator_sys::forget_before(
&*g.0,
self.0.pin_mut(),
limit,
clean_cut,
)
}
pub fn process(
&mut self,
from_band: i32,
to_band: i32,
from_sample_time: i64,
to_sample_time: i64,
callback: impl FnMut(CoefMeta, &mut Coef),
) {
gaborator_sys::process(
self.0.pin_mut(),
from_band,
to_band,
from_sample_time,
to_sample_time,
&mut gaborator_sys::ProcessOrFillCallback(Box::new(callback)),
)
}
pub fn fill(
&mut self,
from_band: i32,
to_band: i32,
from_sample_time: i64,
to_sample_time: i64,
callback: impl FnMut(CoefMeta, &mut Coef),
) {
gaborator_sys::fill(
self.0.pin_mut(),
from_band,
to_band,
from_sample_time,
to_sample_time,
&mut gaborator_sys::ProcessOrFillCallback(Box::new(callback)),
)
}
}
pub struct Gaborator(gaborator_sys::cxx::UniquePtr<gaborator_sys::Analyzer>);
impl Gaborator {
pub fn new(params: &GaboratorParams) -> Self {
Gaborator(
gaborator_sys::new_analyzer(params)
)
}
pub fn analysis_support_len(&self) -> usize { gaborator_sys::get_analysis_support_len(&*self.0) }
pub fn synthesis_support_len(&self) -> usize { gaborator_sys::get_synthesis_support_len(&*self.0) }
pub fn bandpass_bands_begin(&self) -> i32 { gaborator_sys::bandpass_bands_begin(&*self.0) }
pub fn bandpass_bands_end(&self) -> i32 { gaborator_sys::bandpass_bands_end(&*self.0) }
pub fn band_lowpass(&self) -> i32 { gaborator_sys::band_lowpass(&*self.0) }
pub fn band_ref(&self) -> i32 { gaborator_sys::band_ref(&*self.0) }
pub fn band_ff(&self, band: i32) -> f64 { gaborator_sys::band_ff(&*self.0, band) }
pub fn analyze(
&self,
signal: &[f32],
signal_begin_sample_number: i64,
coefs: &mut Coefs,
) {
gaborator_sys::analyze(
&*self.0,
signal,
signal_begin_sample_number,
coefs.0.pin_mut(),
)
}
pub fn synthesize(
&self,
coefs: &Coefs,
signal_begin_sample_number: i64,
signal: &mut [f32],
) {
gaborator_sys::synthesize(
&*self.0,
&*coefs.0,
signal_begin_sample_number,
signal,
)
}
}