Expand description
sew-noise: microphone noise removal, a thin API over nnnoiseless (Joe Neeman’s
pure-Rust port of RNNoise, by Jean-Marc Valin and Mozilla; BSD-3-Clause, pinned exactly).
Stage: the native capture stage. OneFRAME(480 samples, 10 ms) block of 48 kHz monof32in place, a fixed latency of one block, aModethat any thread can change at any block without a click, and per-block timing counters (StageStats).Denoiser: one frame at a time,FRAMEsamples of 48 kHz monof32in the range[-1, 1], in and out. The output lags the input by one frame (Denoiser::LATENCY, 10 ms), RNNoise’s overlap-add.StreamDenoiser: any block size at any rate (8–192 kHz). It buffers to frames, resamples linearly to and from 48 kHz when the rate differs, and keeps a fixed latency (StreamDenoiser::latency_samples). This is what a Web Audio worklet calls.
No allocation after construction, no C, no unsafe. Non-finite input samples are read as silence (one NaN would otherwise poison the RNN state for good) and the output is always finite.
RNNoise’s model is compiled in from nnnoiseless; without feature dfn3 nothing is
loaded at run time.
Cargo features:
capture-stage: thecapture_stagemodule, the capture-hook trait an audio pipeline calls aStagethrough.dfn3:Mode::Strong, DeepFilterNet3’s low-latency model (by Hendrik Schröter and the DeepFilterNet authors; MIT OR Apache-2.0), run by inference code in this crate. Its weights are not in the crate: an app ships them beside itself and loads them withdfn3::Dfn3Model::load, which checks their pinned sha256 first (RustCrypto’ssha2). The feature addssha2(andrealfft, whichnnnoiselessalready brings), and no C, no unsafe code and no neural-network runtime.
Modules§
- capture_
stage - The capture-hook shape an audio pipeline calls a
Stagethrough (cargo featurecapture-stage). - dfn3
- DeepFilterNet3’s low-latency model (cargo feature
dfn3): the weights, loaded from a file beside the app, and the model run by hand-written inference in this crate. - probe
- A measuring stage (cargo feature
probe; for measurement builds only, never a release).
Structs§
- Denoiser
- One RNNoise state: 480-sample frames of 48 kHz mono
f32in[-1, 1]. - Dfn3
Layer - DeepFilterNet3’s layer for a running stage (cargo feature
dfn3): built and warmed up off the audio thread (Dfn3Layer::new), then handed to a stage built without the model withStageControl::attach_dfn3. - Linear
- A streaming converter from
fromHz totoHz. Each input sample emits zero or more output samples; the output lags by at most one input sample. - Mode
Unavailable - A mode this build cannot run was asked for. The stage’s mode is unchanged.
- Stage
- Noise removal for a native capture path: one 10 ms block at a time, in place.
- Stage
Control - A handle on a
Stagefor other threads: change the mode, read what runs, read the counters. Cheap to clone; every call is a few atomic loads or stores. - Stage
Stats - A snapshot of a stage’s timing counters (
StageControl::stats). - Stream
Denoiser - Noise removal for a stream of blocks at the context rate (what a Web Audio worklet runs).
Enums§
- Error
- A refused call. Nothing is processed when one is returned.
- Mode
- How much noise removal a
Stageapplies. - Step
Down Reason - Why the stage stepped down from Strong to Standard.
- Strong
State - Where Strong is.
Constants§
- DEFAULT_
GRACE - The grace window a stage opens by itself (
StageControl::set_auto_grace): at its first block, atStage::resetand when it takes a model layer handed over during a call. - FRAME
- Samples per frame (10 ms at 48 kHz).
- MAX_
RATE - The highest context rate
StreamDenoisertakes. - MIN_
RATE - The lowest context rate
StreamDenoisertakes. - SAMPLE_
RATE - RNNoise’s only rate.
Functions§
- warm_
up_ thread - Makes the calling thread ready to denoise without allocating.