How xiph/rnnoise works
Purpose and public entry points
RNNoise is a C library for real-time 48 kHz mono speech noise suppression using hybrid DSP plus a recurrent neural-network model. The public API is include/rnnoise.h; runtime denoising state/model management is implemented in src/denoise.c and exposed through the example CLI examples/rnnoise_demo.c.
Build, packaging, and model acquisition
The project uses Autotools: autogen.sh prepares the build, configure.ac selects platform capabilities/options, and Makefile.am builds the library, tools, and example. download_model.sh obtains default model assets excluded from Git. Installed-library metadata is generated from rnnoise.pc.in; the build can instead omit embedded weights and require runtime model loading.
Real-time denoising pipeline
src/denoise.c owns the frame-by-frame processing flow: accept PCM samples, derive spectral/pitch features, run neural inference, derive suppression/filter controls, and synthesize denoised output. DSP primitives and shared internal definitions sit in src/denoise.h, src/common.h, and src/arch.h. The library boundary is intentionally sample/frame-oriented rather than file or network oriented.
Signal-analysis stages
Feature extraction depends on FFT and LPC/pitch analysis. src/kiss_fft.c provides spectral transforms; src/celt_lpc.c supports linear-prediction analysis; src/pitch.c estimates pitch-related features. These stages transform input audio into the fixed neural-network feature representation and support reconstruction/control decisions after inference.
Neural model execution and embedded weights
Inference is implemented by src/nnet.c and recurrent layers in src/rnn.c, with network shape/weight declarations in src/nnet_arch.h. The standard compiled-in model is represented by src/nnet_default.c and src/rnnoise_tables.c. A binary model can alternatively be supplied through the public model-loading API; model lifetime must outlive active denoise states.
CPU-specialized inference
The baseline C implementation is supplemented by vector abstractions in src/vec.h, src/vec_avx.h, and src/vec_neon.h. On x86, runtime CPU detection and dispatch support AVX2/SSE4.1 kernels through src/x86/x86cpu.c, src/x86/nnet_avx2.c, and src/x86/nnet_sse4_1.c. Configuration can select a fixed target architecture or enable x86 runtime dispatch.
Training-to-deployment pipeline
Offline feature generation is a native executable rooted in src/dump_features.c, which mixes clean speech, background/foreground noise, and optional RIR augmentation into float feature records. PyTorch training lives in torch/rnnoise/train_rnnoise.py with model definitions in torch/rnnoise/rnnoise.py; sparsity support is under torch/sparsification/. torch/rnnoise/dump_rnnoise_weights.py exports trained checkpoints into C weight sources that replace the embedded runtime model.
External data and operational boundaries
Training requires externally supplied raw 16-bit, 48 kHz PCM speech/noise data and optionally float RIR files; dataset references are in datasets.txt. The supplied CLI reads/writes raw machine-endian PCM only, while the library itself has no web service, database, or network runtime dependency. External network access is limited to model/data download and developer training workflows.
Main entry points: denoise.c Frame denoising · nnet.c Neural inference · configure.ac Autotools build · train_rnnoise.py PyTorch training
Components 19
Runtime denoising
Real-time C library processing path.
- Public C API
include/rnnoise.h - PCM demo CLI · Reads and writes raw machine-endian PCM.
examples/rnnoise_demo.c - Frame denoising · Owns feature extraction, inference controls, and synthesis.
src/denoise.c - DSP internals
src/denoise.h - Spectral transforms
src/kiss_fft.c - LPC and pitch analysis
src/pitch.c
Model inference
Neural execution and deployed weights.
- Neural inference
src/nnet.c - Recurrent layers
src/rnn.c - Network architecture
src/nnet_arch.h - Embedded default model · Can be replaced by runtime-loaded binary model.
src/nnet_default.c - x86 optimized dispatch · Selects AVX2 or SSE4.1 inference kernels at runtime.
src/x86/x86cpu.c
Training and export
Offline data, training, and model generation.
- Feature generation · Mixes speech, noise, and optional RIR into float feature records.
src/dump_features.c - Speech, noise, and RIR data · Externally supplied 48 kHz PCM and optional float RIR files.
datasets.txt - PyTorch training
torch/rnnoise/train_rnnoise.py - PyTorch model
torch/rnnoise/rnnoise.py - C weight export · Converts trained checkpoints into C weight sources.
torch/rnnoise/dump_rnnoise_weights.py
Build and distribution
Autotools build and optional model acquisition.
- Autotools build · Configures and builds the library, tools, and example.
configure.ac - Default model download · Obtains model assets excluded from Git.
download_model.sh - Package metadata
rnnoise.pc.in
Connections 20
- PCM demo CLI → Public C API: uses
- Public C API → Frame denoising: creates and processes frames
- Frame denoising → DSP internals: uses
- Frame denoising → Spectral transforms: extracts spectral features
- Frame denoising → LPC and pitch analysis: derives pitch features
- Frame denoising → Neural inference: runs feature inference
- Neural inference → Recurrent layers: executes recurrent layers
- Neural inference → Network architecture: uses network layout
- Neural inference → Embedded default model: uses weights
- x86 optimized dispatch → Neural inference: accelerates kernels
- Speech, noise, and RIR data → Feature generation: source material
- Feature generation → PyTorch training: feature records
- PyTorch model → PyTorch training: defines model
- PyTorch training → C weight export: trained checkpoint
- C weight export → Embedded default model: generates replacement weights
- Autotools build → PCM demo CLI: builds
- Autotools build → Frame denoising: builds library
- Autotools build → x86 optimized dispatch: configures target or dispatch
- Autotools build → Package metadata: generates installed metadata
- Default model download → Embedded default model: supplies default assets