Skip to content

BitCrush

Added in v0.35.0

Apply a bit crush effect to the audio by reducing the bit depth. In other words, it reduces the number of bits that can be used for representing each audio sample. This adds quantization noise, and affects dynamic range. This transform does not apply dithering.

For more information, see

Input-output example

Here we reduce the bit depth from 16 to 6 bits per sample

Input-output waveforms and spectrograms

Input sound Transformed sound

Usage example

from audiomentations import BitCrush

transform = BitCrush(min_bit_depth=5, max_bit_depth=14, p=1.0)

augmented_sound = transform(my_waveform_ndarray, sample_rate=16000)

BitCrush API

min_bit_depth: int • unit: bits • range: [1, 32]
Minimum bit depth the audio will be "converted" to
max_bit_depth: int • unit: bits • range: [1, 32]
Maximum bit depth the audio will be "converted" to
p: float • range: [0.0, 1.0]
Default: 0.5. The probability of applying this transform.

Source code

audiomentations/augmentations/bit_crush.py