Skip to content

Latest commit

 

History

History
135 lines (99 loc) · 4.22 KB

File metadata and controls

135 lines (99 loc) · 4.22 KB

Racket

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.

Features

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

Setup

Build from Source

# 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/racket

Pre-built Binaries

Pre-built binaries for common platforms will be available in the Releases section.

Optional Dependencies

  • To handle mp3 files, you need to have ffmpeg installed on your system.
  • To process files in parallel, you need to have GNU parallel installed.

Usage

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:

  1. Receive as input a path to a directory containing mp3 files.
  2. Recursively find all mp3 files in that directory.
  3. Convert each mp3 file to wav using ffmpeg.
  4. Process each wav file with racket to apply the effects.
  5. Convert the processed wav files back to mp3 using ffmpeg.
  6. Save the processed mp3 files near the original files with a _processed suffix.

Examples

./target/release/racket data/input/original.wav data/output/noisy.wav
./racket.sh data/input/mp3_files

Help

racket --help

Effect Parameters

The 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.

Technical Details

  • 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

Dependencies

  • hound - WAV file I/O
  • rand - Random number generation
  • clap - Command-line argument parsing

License

See here for license details.

Enhancements

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

References