pnpm dlx shadcn@latest add @audio-ui/synced-rate
import { SYNCED_RATE_PARAMETERS, lfoRate } from "@/lib/synced-rate";| Files | lib/synced-rate.ts |
|---|---|
| Depends on | Nothing |
| npm | @audio-ui/engine |
| Used by | auto-pan-device, chorus-device, phaser-device, wah-device |
| Export | Kind | What it is |
|---|---|---|
RateState | interface | The parameters that give an oscillator its rate: free in hertz, or a cycle per note value of the tempo. |
SYNCED_RATE_PARAMETERS | const | The two descriptors a synced rate adds beside the one in hertz: a switch and the note list. |
lfoRate | function | The 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.rateHzThe tempo comes from the host's DeviceContext, given with each update.