Lab

step-player

A clock that counts the steps of a pattern at a tempo and tells a Sequencer which one is playing, for a preview in any framework

pnpm dlx shadcn@latest add @audio-ui/step-player
import { createStepPlayer } from "@/lib/step-player";
Fileslib/step-player.ts
Depends onNothing
npmNothing
Used bysequencer-svelte-demo, sequencer-vue-demo, sequencer-web-demo
ExportKindWhat it is
createStepPlayerfunctionA clock that counts steps at a tempo, for a pattern played in a preview.

Usage

Counts the steps of a pattern at a tempo and calls you on each one, to play what the pattern holds there. Its source is the step being played, -1 while stopped, as a live source a Sequencer takes: a clock that ticks every step costs no render in any framework.

import { createStepPlayer } from "@/lib/step-player";

const player = createStepPlayer({
  bpm: 112,
  onStep: (step) => playKit(step),
  steps: 16,
});

player.start();
player.stop();

It ticks with a timer, so it is not sample accurate. For a transport that keeps time under load, use useTransportClock, over the scheduler of @audio-ui/engine/time.

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