wasm-audio-ferrite
v0.1.4
Published
High-performance real-time audio noise reduction powered by WebAssembly and Rust
Maintainers
Readme
WASM Audio Ferrite
High-performance, real-time audio noise reduction library powered by WebAssembly and Rust.
Overview
WASM Audio Ferrite is a cutting-edge noise reduction system that brings professional-grade audio processing to the web. Built with Rust and compiled to WebAssembly, it delivers near-native performance with sub-millisecond latency.
Key Features
- 🚀 Blazing Fast: Sub-millisecond processing latency (0.055ms for 256 samples @ 48kHz)
- 🔧 Zero-Copy API: Minimal memory overhead with direct WASM memory access
- 🎛️ Multi-Stage Processing: Combines spectral subtraction and noise gating
- 🎵 Musical Noise Reduction: Advanced Wiener filtering with comfort noise
- 📊 Adaptive Noise Profiling: Learn and remove background noise in real-time
- 🌐 Cross-Platform: Works in any modern web browser with WebAssembly support
Performance Benchmarks
| Buffer Size | Sample Rate | Processing Time | CPU Usage | Real-time Factor | |-------------|-------------|-----------------|-----------|------------------| | 256 samples | 48 kHz | 0.055ms | <2% | 96x | | 512 samples | 48 kHz | 0.065ms | <1.5% | 164x | | 2048 samples| 48 kHz | 0.175ms | <0.5% | 244x |
Quick Start
Installation
# Clone the repository
git clone https://github.com/macaque-suf/ferrite
cd wasm-audio-ferrite
# Install dependencies
npm install
# Build WASM module and TypeScript bindings
npm run build
# Run demos
npm run devBasic Usage
import { NoiseProcessor } from '@wasm-audio-ferrite/toolkit';
// Initialize the processor
const processor = await NoiseProcessor.create({
sampleRate: 48000,
useZeroCopy: true // Enable zero-copy API for best performance
});
// Configure noise reduction
processor.setReductionAmount(0.5); // 0.0 = minimal, 1.0 = maximum
processor.setGateThreshold(-40); // dB
processor.setWienerMode(true); // Enable Wiener filtering
// Process audio
const processedAudio = processor.processFrame(inputBuffer);Demos
The project includes several interactive demos:
- Main Demo - Complete noise reduction interface with file upload and real-time processing
- Live Passthrough - Real-time microphone processing with performance metrics
- Zero-Copy Benchmark - Compare regular vs zero-copy API performance
- Testing Suite - Advanced parameter tuning and stage-by-stage visualization
Architecture
┌─────────────────────────────────────────────┐
│ Web Audio API (JavaScript) │
├─────────────────────────────────────────────┤
│ TypeScript Wrapper (@toolkit) │
├─────────────────────────────────────────────┤
│ WebAssembly Module (wasm-bindgen) │
├─────────────────────────────────────────────┤
│ Rust Core (audio-processor) │
│ ┌─────────────┐ ┌──────────────┐ │
│ │ Spectral │ │ Noise │ │
│ │ Subtraction │ ───> │ Gate │ │
│ └─────────────┘ └──────────────┘ │
└─────────────────────────────────────────────┘Components
- audio-processor-core/ - Rust implementation of noise reduction algorithms
- packages/toolkit/ - TypeScript/JavaScript wrapper with Web Audio integration
- demo/ - Interactive demonstrations and performance tests
Building from Source
Prerequisites
- Rust 1.70+ with
wasm32-unknown-unknowntarget - Node.js 18+
- wasm-pack (
cargo install wasm-pack)
Build Commands
# Build WASM module
npm run build:wasm
# Build TypeScript toolkit
npm run build:toolkit
# Build everything
npm run build
# Run development server
npm run devAPI Documentation
NoiseProcessor Class
The main interface for audio processing:
class NoiseProcessor {
// Create a new processor instance
static async create(config: ProcessorConfig): Promise<NoiseProcessor>
// Process audio frame (regular API)
processFrame(input: Float32Array): Float32Array
// Process audio frame (zero-copy API)
processFrameZeroCopy(input: Float32Array): Float32Array
// Learn noise profile from background audio
learnNoise(samples: Float32Array): void
// Configuration methods
setReductionAmount(amount: number): void // 0.0 - 1.0
setGateThreshold(dbfs: number): void // Typically -60 to 0
setWienerMode(enabled: boolean): void
setBypass(enabled: boolean): void
}Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
License
MIT License - See LICENSE file for details
Acknowledgments
Built with:
- Rust - Systems programming language
- wasm-bindgen - WebAssembly bindings
- Web Audio API - Browser audio processing
- rustfft - Fast Fourier Transform implementation
Support
For issues, questions, or suggestions, please open an issue on GitHub.
WASM Audio Ferrite - Professional audio processing for the modern web 🎵
