Skip to main content

Bitcrusher

The Bitcrusher takes the audio signal and reduces the resolution, making it sound "crunchy" or pixelated like a retro game console sound board.

Visualization

Quick Start

import { createBitcrusherNode } from "clawdio";

const context = new AudioContext();
const oscillatorNode = context.createOscillator();
oscillatorNode.start();

const createBitcrusherWorklet = async (id: string) => {
// Create the node using our helper function
const bitcrusher = await createBitcrusherNode(context, 4, 0.1);

// Connect the node
oscillatorNode.connect(bitcrusher.node);
bitcrusher.node.connect(context.destination);
};

await createBitcrusherWorklet();

Controls

PropertyTypeDefaultDescription
Bitsnumber4The resolution of the audio
Norm Freqnumber0.10 to 1. The amount of bitcrushing, lower number means stronger effect.

Bits

const bitcrusher = await createBitcrusherNode(context, 4, 0.1);
const bitcrusherNode = bitcrusher.node;

const setBits = (newBits: number) => {
bitcrusherNode.port.postMessage({ type: "set-bits", data: newBits });
};

// Set the bits inside worklet anytime you need
setBits(4);

Norm Freq

const bitcrusher = await createBitcrusherNode(context, 4, 0.1);
const bitcrusherNode = bitcrusher.node;

const setNormfreq = (newFreq: number) => {
if (!nodeRef) return;
nodeRef.port.postMessage({ type: "set-normfreq", data: newFreq });
};

// Set the norm freq inside worklet anytime you need
setNormfreq(1);

Video Example