br41ndmg
A Rust audio resampling library with a polyphase sinc engine, offline and streaming APIs, WAV/FLAC input, and a stereo SSE2 fast path.
Overview
br41ndmg resamples f32 audio with a precomputed polyphase sinc filter bank. The library exposes both offline and streaming APIs, reads WAV and FLAC files, writes WAV, and uses the same filter math in chunked and full-buffer processing — so streaming output is bit-for-bit identical to the offline path.
Current Features
f32sample buffers for offline and streaming resamplingf32andf64DSP helper APIs for sinc, window, and FIR kernel generation- Offline resampling for mono and interleaved multichannel buffers
- Streaming resampling for interleaved audio
- Polyphase sinc filtering with precomputed fractional phases
- Configurable polyphase filter phase count, tap count, and window
- WAV input: 8/16/24/32-bit PCM and 32-bit float
- FLAC input: 4–32-bit samples (default
flacfeature, pure-Rust decoder) - WAV output: 32-bit float
- SSE2 stereo fast path on
x86andx86_64 - Streaming output is bit-exact with the offline path regardless of input chunking
- DSP validation tests for impulse, sine, sweep, DC, and alias-suppression regressions
- Real-audio integration tests driven by
test_subjects/FLAC fixtures - Criterion benchmarks for mono and stereo 44.1 kHz → 48 kHz conversion
Quick Start
Installation
[]
= "0.1"
The default features include FLAC support. To build a leaner, WAV-only crate:
[]
= { = "0.1", = false }
Basic Usage
use Resampler;
let input_rate = 44_100.0f32;
let output_rate = 48_000.0f32;
let resampler = new?;
let input_samples: = /* your audio data */;
let output_samples = resampler.resample?;
Custom Filter Settings
use ;
let params = PolyphaseFilterParams ;
let resampler = with_filter_params?;
File I/O (WAV and FLAC)
use ;
// .wav or .flac — the decoder is selected from the extension
let input = read_audio?;
let output = input.resample_to?;
write_wav?;
Real-Time Streaming
use StreamingResampler;
let mut stream = new?;
let input_frames = 256;
let input_chunk = vec!;
let mut output = vec!;
let written_frames = stream.process_into?;
let ready = &output;
Command-Line Tool
The CLI lives in a separate package but installs a binary still named br41ndmg:
Run with no arguments (or a directory, or -i/--interactive) to open the
interactive file browser, or pass three positional arguments for the
non-interactive path:
# interactive browser, starts in the current directory
# interactive browser, starting in a given folder
# force interactive mode explicitly
# non-interactive: single file -> explicit output path
# non-interactive: single file -> directory (auto-named <stem>_<rate>Hz.wav)
# non-interactive: batch every .wav/.flac in a folder -> out_dir/
In the browser, navigate with arrow keys (or j/k), Enter/Space to open
or toggle files, a to select all, c to clear, and p to proceed. On the
settings screen pick a target rate from common presets (or type a custom one)
and choose the output directory by typing or browsing for it, then start.
From a source checkout, use cargo run --release --bin br41ndmg -- <args> in place of br41ndmg.
Roadmap
- Core math primitives (sinc, windows, FIR kernels)
- Polyphase sinc implementation
- File I/O integration (WAV + FLAC)
- Real-time streaming support
- SIMD optimization for stereo interleaved paths
-
f32DSP helper support - DSP quality validation suite expansion
- Configurable polyphase filter parameters
- Bit-exact streaming/offline equivalence
- Expanded performance baselines and profiling data
Documentation
- docs/USAGE.md - End-user guide and recipes
- docs/REQUIREMENTS.md - Scope and current capabilities
- docs/ARCHITECTURE.md - Module map and current data flow
- docs/DSP_NOTES.md - Sinc and polyphase theory notes
- docs/REALTIME.md - Real-time / callback guidance
- docs/TEST_PLAN.md - Testing strategy
- docs/BENCHMARK_PLAN.md - Benchmark coverage and next steps
- docs/PERFORMANCE.md - Current performance notes
API documentation is generated with cargo doc --open.
Long-Term Targets
These are project goals, not hard guarantees from the current default filter settings.
| Metric | Target |
|---|---|
| Aliasing suppression | < -100 dB |
| Passband ripple | < 0.1 dB |
| Stopband attenuation | > 100 dB |
License
MIT