/ music / double-pendulum
Sign in
music / double-pendulum
double-pendulum / src / core / composition.ts
34 lines · 1.3 KBCodeBlameHistory
73fe08adouble pendulum: album app with composition 1 (poincaré)Jeremy Magland 1import type { AudioEngine } from "./audio.ts";
2import type { ParamSpec, Params } from "./params.ts";
4/** A running (or ready-to-run) performance of a composition, bound to a view element. */
5export interface Piece {
6 /** Start (or restart) from piece time `offset` seconds. Resolves once sound has begun. */
7 start(audio: AudioEngine, offset: number): Promise<void>;
8 stop(): void;
9 /** Called every animation frame, playing or not. */
10 draw(): void;
11 readonly playing: boolean;
12 /** Current piece time in seconds. */
13 now(): number;
14 /** Total length in seconds, including any tail. */
15 length(): number;
8a22646orbits: limit the orbit count to what the device can play liveJeremy Magland 16 /** A short message for every listener (e.g. "checking this device…"), or null. */
17 notice?(): string | null;
73fe08adouble pendulum: album app with composition 1 (poincaré)Jeremy Magland 18 /** Diagnostic values shown in author mode. */
19 readouts(): Record<string, string>;
20 /** Called when the piece reaches its end on its own. */
21 onEnded?: () => void;
22 dispose(): void;
25export interface Composition {
26 /** used in the URL, e.g. "01-poincare" */
27 id: string;
28 title: string;
29 schema: ParamSpec[];
30 /** The published settings: the contents of the composition's defaults.json */
31 defaults: Partial<Params>;
32 /** `params` is live: read it whenever needed so author edits take effect immediately. */
33 create(view: HTMLElement, params: () => Params): Piece;
↑↓ move↵openescclose