A fast C++ program with plugin architecture for processing audio files with echo cancellation and background noise reduction capabilities.
- Plugin Architecture: Extensible format support through plugin system
- Echo Cancellation: Uses adaptive filtering (LMS algorithm) to remove echoes
- Noise Reduction: Implements spectral subtraction for background noise removal
- Multi-format Support: WAV (full), MP3/OGG (framework ready)
- Real-time Processing: Optimized for performance with FFT-based processing
- Cross-format Processing: Convert between formats while processing
- 16-bit PCM Support: Works with standard audio formats
- Multi-channel Support: Handles mono and stereo audio
- WAV: 16-bit PCM, mono/stereo, any sample rate
- MP3: Decoding/encoding framework (integrate mpg123/LAME)
- OGG Vorbis: Decoding/encoding framework (integrate libvorbis)
The plugin architecture makes it easy to add support for additional formats like FLAC, AAC, etc. See PLUGIN_ARCHITECTURE.md for details.
- CMake 3.10 or higher
- C++17 compatible compiler (GCC, Clang, or MSVC)
# Create build directory
mkdir build
cd build
# Configure and build
cmake ..
cmake --build .
# On Windows with Visual Studio
cmake --build . --config ReleaseWindows (Visual Studio):
build.batLinux/macOS (GCC/Clang):
chmod +x build.sh
./build.shaudio_cleaner -faudio_cleaner -i noisy.wav -o clean.wav# MP3 to WAV
audio_cleaner -i noisy.mp3 -o clean.wav
# OGG to WAV
audio_cleaner -i noisy.ogg -o clean.wav
# WAV to MP3 (if MP3 writing implemented)
audio_cleaner -i input.wav -o output.mp3audio_cleaner -i input.wav -r reference.wav -o output.wavaudio_cleaner -i input.wav -r reference.wav -o output.wav -l 0.005-i <input_file>: Input audio file (required)-o <output_file>: Output audio file (required)-r <reference_file>: Reference signal for echo cancellation (optional)-l <learning_rate>: Learning rate for adaptive filter (0.001-0.1, default: 0.01)-f: List supported formats and extensions-h: Show help message
The program uses a modular plugin system that allows:
- Easy Extension: Add new audio formats without core changes
- Runtime Detection: Automatic format identification
- Flexible I/O: Read from one format, write to another
- Modular Testing: Test formats independently
- WAV (Priority: 10) - Full support
- MP3 (Priority: 8) - Framework ready
- OGG (Priority: 7) - Framework ready
The program uses an adaptive filter with the Least Mean Squares (LMS) algorithm to model and remove echo components. When a reference signal is provided, it estimates the echo path and subtracts the estimated echo from the input signal.
Noise reduction is performed using spectral subtraction:
- Estimate noise spectrum from the first few frames
- Transform audio to frequency domain using FFT
- Subtract estimated noise spectrum
- Apply spectral flooring to prevent musical noise
- Transform back to time domain
- FFT Size: 1024 samples
- Overlap: 75% (256-sample hop size)
- Window: Hann window
- Processing is optimized for real-time applications
- Voice Recording Cleanup: Remove background noise from voice recordings
- Conference Call Enhancement: Reduce echo and noise in audio conferences
- Audio Restoration: Clean up old or damaged audio recordings
- Podcast Production: Improve audio quality for podcast episodes
- Format Conversion: Convert between formats while cleaning audio
To enable full MP3 and OGG support, integrate these libraries:
# Ubuntu/Debian
sudo apt-get install libmpg123-dev liblame-dev
# macOS
brew install mpg123 lame# Ubuntu/Debian
sudo apt-get install libvorbis-dev libogg-dev
# macOS
brew install libvorbis liboggThen uncomment and configure the CMake options in CMakeLists.txt.
- Standard C++ library only for WAV support
- Optional external libraries for MP3/OGG
- Math library for FFT operations
- Approximately 4x the input audio size during processing
- FFT buffers and filter coefficients add minimal overhead
- Optimized for single-threaded performance
- FFT operations are the most computationally intensive
- Suitable for real-time processing on modern CPUs
- WAV files: 16-bit PCM encoding, any sample rate, mono/stereo
- MP3 files: Framework ready (requires mpg123/LAME)
- OGG files: Framework ready (requires libvorbis)
- Any duration: Limited only by available memory
- MP3/OGG support requires external library integration
- Echo cancellation requires a reference signal
- Noise reduction works best for stationary noise
- Processing delay due to FFT-based approach
- Extensible: Easy to add new audio formats
- Modular: Each format is self-contained
- Testable: Individual formats can be tested independently
- Flexible: Runtime format detection and selection
- Maintainable: Clear separation of concerns
This project is provided as-is for educational and practical use.
When adding new format support:
- Create format classes implementing
IAudioReaderandIAudioWriter - Create a factory class implementing
IAudioFormat - Register the format in the initialization function
- Update build system with new source files
- Add tests for the new format
See PLUGIN_ARCHITECTURE.md for detailed implementation guidance.