Lab

oversampling

What a waveshaper that oversamples costs in time, and a delay that holds a dry path back by it, so a distortion mixed with its dry sound does not comb. Measured in Chrome.

pnpm dlx shadcn@latest add @audio-ui/oversampling
import { oversamplingSeconds, oversamplingDelay, createOversamplingDelay } from "@/lib/oversampling";
Fileslib/oversampling.ts
Depends onNothing
npmNothing
Used bydistortion-device, distortion-engine, limiter-device, overdrive-device, overdrive-engine, saturator-device, saturator-engine, vibe-device, wave-shaper-device, wave-shaper-engine
ExportKindWhat it is
oversamplingSecondsfunctionThe delay in seconds a WaveShaperNode adds when it oversamples at amount, at a sample rate.
oversamplingDelayfunctionThe delay in seconds a WaveShaperNode adds when it oversamples at amount, in a context.
createOversamplingDelayfunctionA delay node that holds a dry path back by the oversampling of a shaper.

Usage

Waveshaping without aliasing, and the latency it costs: a WaveShaperNode oversampled 2x or 4x delays the sound a little, so a dry path mixed beside it has to wait as long.

import { createOversamplingDelay, oversamplingSeconds } from "@/lib/oversampling";

shaper.oversample = "4x";
const dryDelay = createOversamplingDelay(ctx, "4x"); // the dry path waits as long as the shaper
const latency = oversamplingSeconds("4x", ctx.sampleRate); // what a device declares

The saturator, overdrive and wave shaper use it.

Built by Ouest Labs, the source code is available on GitHub.
RSS