Rust API reference
Public in-memory engine types, native pipeline functions, and Cargo feature behavior.
Engine functions
Rustpub fn analyze_interleaved( input: &[f32], sample_rate: u32, options: &ProcessOptions,) -> anyhow::Result<EngineReport>;pub fn process_interleaved( input: &[f32], sample_rate: u32, options: &ProcessOptions,) -> anyhow::Result<ProcessResult>;pub fn process_interleaved_with_progress( input: &[f32], sample_rate: u32, options: &ProcessOptions, on_progress: impl FnMut(ProcessProgress),) -> anyhow::Result<ProcessResult>;
Both functions validate the sample rate, stereo interleaving, option ranges, and sample finiteness.
The progress variant emits Prepare, Analyze, MissingBand, Bandwidth, Artifacts, Finalize,
and Complete at real pipeline boundaries. ProcessProgress::progress is an overall value from 0
to 1.
Long repair stages use bounded 8-second chunks with 250 ms of surrounding signal context. This keeps STFT memory bounded while preserving enough neighboring audio for stable chunk boundaries.
ProcessResult
Rustpub struct ProcessResult { pub audio: Vec<f32>, pub report: EngineReport,}
When report.processed is false, audio is bit-for-bit equal to the input.
ProcessOptions
ProcessOptions::default() matches the native process defaults and enables every non-neural stage.
Fields use Rust snake_case equivalents of the JavaScript options:
Rustpub struct ProcessOptions { pub fc: usize, pub scan_start_hz: usize, pub dsp_strength: f32, pub bandwidth_extension: bool, pub repair_smearing: bool, pub repair_bleeding: bool, pub stabilize_phase: bool, pub n_fft: usize, pub hop: usize, // Additional detector, strength, and segmentation controls.}
See the npm option table for defaults and accepted ranges. Names map directly from camelCase to snake_case.
EngineReport
The report includes input metadata, needs_processing, processed, missing-band routing,
shared-bandwidth evidence, artifact safety-gate retention, headroom changes, and per-segment metrics.
Important fields:
| Field | Meaning |
|---|---|
needs_processing | Detection or configured artifact work requested processing |
processed | At least one stage was retained in the output |
output_gain_db | Final gain used to maintain headroom |
synthesis_mix | Retained share of the synthesized M/S delta |
segments | Window metrics and DSP routes |
Native pipeline
These APIs are present with the default native feature:
Rustpub fn process<P: AsRef<Path>, Q: AsRef<Path>>( input: P, output: Q, config: &Config, report_path: Option<&Path>,) -> anyhow::Result<()>;pub fn detect<P: AsRef<Path>>( input: P, config: &Config, report_path: Option<&Path>,) -> anyhow::Result<()>;
Config::from_process() enables calibrated artifact repair. Config::from_detect() keeps those
stages disabled and reports analysis only.
Cargo features
| Feature | Included behavior |
|---|---|
native (default) | CLI, WAV I/O, ONNX Runtime, model downloads, terminal UI, Rayon |
wasm | wasm-bindgen exports and JavaScript serialization |
| No features | Portable Rust analysis and non-neural engine |
Build the browser target with:
Bashcargo build \ --target wasm32-unknown-unknown \ --no-default-features \ --features wasm