Lab

synced-rate

The rate of an oscillator that is either free, in hertz, or synced: one cycle per note value of the host's tempo. The two parameters a device adds for it, and the function that reads the rate.

pnpm dlx shadcn@latest add @audio-ui/synced-rate
import { SYNCED_RATE_PARAMETERS, lfoRate } from "@/lib/synced-rate";
Fileslib/synced-rate.ts
Depends onNothing
npm@audio-ui/engine
Used byauto-pan-device, chorus-device, phaser-device, wah-device
ExportKindWhat it is
RateStateinterfaceThe parameters that give an oscillator its rate: free in hertz, or a cycle per note value of the tempo.
SYNCED_RATE_PARAMETERSconstThe two descriptors a synced rate adds beside the one in hertz: a switch and the note list.
lfoRatefunctionThe rate of an oscillator in hertz: the one in the state, or, when it is synced, one cycle for each note value at tempo, so 1/4 at 120 BPM is 2 Hz.

Usage

A modulation rate in hertz, or a note value that follows the host's tempo: what an auto pan, a chorus or a phaser's LFO runs at.

import { lfoRate } from "@/lib/synced-rate";

const hertz = lfoRate(state, tempo); // state.sync ? the division at the tempo : state.rateHz

The tempo comes from the host's DeviceContext, given with each update.

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