Skip to main content

Crate flexaudio_denoise

Crate flexaudio_denoise 

Source
Expand description

flexaudio-denoise — An offline noise-suppression addon using RNNoise (nnnoiseless).

It does not depend on flexaudio-core; it accepts only normalized ±1.0, 48 kHz interleaved &[f32]. Model weights are embedded in the nnnoiseless crate (BSD-3-Clause), so no runtime model file or network access is needed. It targets steady noise in microphone recordings (fans, air conditioning, keyboard clicks, and similar sounds).

§Latency and carry-over semantics

RNNoise processes only fixed 480-sample frames (10 ms at 48 kHz), so Denoiser::process splits input into frames internally and carries any remainder into the next call. The fixed latency does not depend on call size. Output is always the input delayed by exactly FRAME_SIZE samples per channel:

  • process returns the same-length buffer in place. The first FRAME_SIZE samples per channel are latency padding (silence, 0.0).
  • Denoiser::flush returns the final FRAME_SIZE samples per channel and closes the stream. Total output = total input + FRAME_SIZE samples per channel.

The output is bit-identical regardless of how the input is chunked.

§Example

use flexaudio_denoise::{Denoiser, FRAME_SIZE};

let mut dn = Denoiser::new(1).unwrap();
let mut chunk = vec![0.0f32; 1000]; // normalized ±1.0, mono, 48 kHz
dn.process(&mut chunk).unwrap();    // In place (the first 480 samples are latency silence)
let tail = dn.flush();              // Remaining 480 samples per channel
assert_eq!(tail.len(), FRAME_SIZE);

Structs§

Denoiser
Streaming noise suppressor. Stereo uses two independent RNNoise states, one per channel (no crosstalk between channels).

Enums§

DenoiseError
Noise-suppression errors.

Constants§

FRAME_SIZE
Samples per RNNoise frame per channel (10 ms at 48 kHz). Processing latency is also this fixed value.