Audio UI
Roughens the sound like an early sampler. It keeps only some bits of each sample and holds each sample for several. It is a device: a state, a panel, an engine and tools, each its own file.
Installation
Copy to Clipboardpnpm dlx shadcn@latest add @audio-ui/redux
It installs the device's state, its engine and its panel to components/audio-ui/devices/redux/. The demo above, which wires them to a loop, is @audio-ui/block-redux.
Controls
Controls · 5
Panel
The panel draws the stairs the bits make against the straight line of a clean sound. quantize(input, bits) is one step of the quantizer.
Copy to Clipboardimport { ReduxPanel } from "@/components/audio-ui/devices/redux/panel"; import { reduxDevice } from "@/components/audio-ui/devices/redux/device"; const [state, setState] = useState(() => reduxDevice.defaults()); <ReduxPanel onValueChange={setState} value={state} />;
Engine
Create it, connect it and update it as for any device: see The engine.
Rounded to the nearest level, the bits are a quantizer table in a WaveShaperNode, rebuilt only when they change. The sample hold is an AudioWorklet (REDUX_WORKLET is its source): the bitcrusher of @audio/effect-bitcrusher at 24 bits, and for a shaped quantizer the error feedback of @audio/effect-noiseshaper, the table then out of the way. A worklet cannot import, so the device carries their code as published (REDUX_KERNELS, in its kernels.ts). Until it is ready the bits are already rounded to the nearest level, shaped or not, and the rate is not yet reduced, and engine.ready resolves to false in a context that cannot run worklets. The hold takes whole samples, not a filtered resampling, so it aliases, which is the sound.