Skip to content

About

A command-line audio quantization tool written in C++ (STL) for retro DSP effects.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Audio Bitcrusher

A small command-line audio effect for 16-bit PCM WAV files, written in C++11 with the standard library. It reads sample data into memory, applies integer quantization and sample-and-hold processing, then writes a WAV file.

Listen

Input Output
Original sample Processed sample

Features

  • Binary input and output with std::ifstream and std::ofstream.
  • Integer quantization controlled by crush_factor.
  • Sample-and-hold processing controlled by downsample_factor.
  • No external audio-processing library.

The processing changes the sample values; it does not change the WAV header's sample rate or bit depth. downsample_factor controls how often a new sample value is taken, so the result can sound similar to lower-rate audio without creating a lower-sample-rate file.

Build and run

The supplied Makefile uses g++, make, and -std=c++11:

make
./bitcrusher samples/demo_original.wav samples/out.wav 256 4

On Windows with MinGW, use mingw32-make and run bitcrusher.exe.

bitcrusher <input.wav> <output.wav> [crush_factor] [downsample_factor]

Both factors are optional. The defaults are 256 and 1, respectively. A larger crush_factor reduces sample precision; a larger downsample_factor holds each selected value for more sample positions.

Current format limits

The reader assumes a conventional 44-byte WAV header followed immediately by 16-bit PCM sample data. It checks the RIFF and WAVE identifiers, but does not fully validate the WAV format or handle arbitrary extra chunks. The sample-and-hold loop processes interleaved sample positions, so stereo channels are not handled independently. Use a copy of the input audio and a simple 16-bit PCM WAV file when trying the tool.

The implementation uses std::vector<int16_t> for audio samples. It does not use memory-mapped files.

License

MIT. See LICENSE.

About

A command-line audio quantization tool written in C++ (STL) for retro DSP effects.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages