audio/ui
Toggle Mode D
Copy to Clipboardpnpm dlx shadcn@latest add @audio-ui/step-player
Copy to Clipboardimport { createStepPlayer } from "@/lib/step-player";
| Files | lib/step-player.ts |
|---|---|
| Depends on | Nothing |
| npm | Nothing |
| Used by | sequencer-svelte-demo, sequencer-vue-demo, sequencer-web-demo |
| Export | Kind | What it is |
|---|---|---|
createStepPlayer | function | A 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.
Copy to Clipboardimport { 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 @/lib/engine/time.