Command-line audio processor written in Rust to apply various noise effects to WAV audio files.
Please note that this project is currently in early development and various improvements and optimizations will be added as I go through the Rust book. The current implementation is a proof of concept to demonstrate the core functionality.
Racket applies a chain of audio effects to transform your audio:
- White Noise - Adds subtle background noise
- Pink Noise - Adds warm, filtered noise using a pink noise generator
- Distortion - Applies harsh distortion with gain control
- Tremolo - Creates amplitude modulation for a wobbling effect
- Telephone Effect - High-pass filter to simulate old telephone quality
- Ring Modulation - Adds metallic, inharmonic overtones
- Bitcrushing - Reduces bit depth for a robot voice effect
# Clone or navigate to the repository
cd racket
# Build a development version (faster compile times but less optimized)
cargo build
# Build the release version
cargo build --release
# The binary will be available at ./target/debug/racket or ./target/release/racketPre-built binaries for common platforms will be available in the Releases section.
- To handle
mp3files, you need to haveffmpeginstalled on your system. - To process files in parallel, you need to have
GNU parallelinstalled.
racket <input.wav> <output.wav>But lets say your data is in mp3 format. And you have a LOT of mp3 files
to process. You can use the utility script racket.sh to convert them to wav,
process them, and convert them back to mp3 again.
./racket.sh <path/to/mp3/dir>The provided shell script will:
- Receive as input a path to a directory containing
mp3files. - Recursively find all
mp3files in that directory. - Convert each
mp3file towavusingffmpeg. - Process each
wavfile withracketto apply the effects. - Convert the processed
wavfiles back tomp3usingffmpeg. - Save the processed
mp3files near the original files with a_processedsuffix.
./target/release/racket data/input/original.wav data/output/noisy.wav./racket.sh data/input/mp3_filesracket --helpThe current effect chain uses the following parameters:
- White noise: 1% mix
- Pink noise: 5% mix
- Distortion: 2.0x gain
- Tremolo: 6 Hz rate, 20% depth
- Telephone: 0.9 high-pass filter coefficient
- Ring modulation: 20 Hz frequency
- Bitcrush: 8-bit depth
Note: Parameters are currently hardcoded but can be modified in main.rs.
- Input/Output: WAV files only
- Sample Format: 16-bit PCM
- Processing: All effects are applied sequentially in-memory
- Pink Noise: Uses Paul Kellet's refined pink noise algorithm
See here for license details.
Some ideas for enhancements:
- Use a randomizer to randomly apply effects and parameters
- Make effect parameters configurable via CLI flags
- Add ability to enable/disable individual effects
- Support additional audio formats (especially MP3)
- Parallelize processing of multiple files using Rust itself instead of relying on GNU parallel
- Paul Kellet's Pink Noise Algorithm: http://www.firstpr.com.au/dsp/pink-noise/
- Sample code for generating White, Pink, and Brown noises: https://github.com/joaocarvalhoopen/Audio_noise_WAV_generator_in_Rust
- Julius O. Smith III's Digital Audio Signal Processing: https://ccrma.stanford.edu/~jos/pasp/
- Distortion by soft clipping using
tanh: http://gdsp.hf.ntnu.no/lessons/3/17/ - https://en.wikipedia.org/wiki/Tremolo
- https://en.wikipedia.org/wiki/High-pass_filter
- https://en.wikipedia.org/wiki/Ring_modulation
- https://en.wikipedia.org/wiki/Bitcrusher
- https://www.merriam-webster.com/dictionary/racket