@webmusic/kernel 0.1.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -21
- package/NOTICE +2 -0
- package/README.md +138 -101
- package/dist/audio-context.cjs.map +1 -1
- package/dist/build-receipt.json +3 -3
- package/dist/chunk-27LH6QLZ.cjs +277 -0
- package/dist/chunk-27LH6QLZ.cjs.map +1 -0
- package/dist/chunk-3INDOVUC.cjs.map +1 -1
- package/dist/chunk-3RR2VIKA.js +393 -0
- package/dist/chunk-3RR2VIKA.js.map +1 -0
- package/dist/chunk-3YTKIKKX.cjs +378 -0
- package/dist/chunk-3YTKIKKX.cjs.map +1 -0
- package/dist/chunk-4RG4WQKC.js +360 -0
- package/dist/chunk-4RG4WQKC.js.map +1 -0
- package/dist/chunk-5AHVQXTF.cjs +620 -0
- package/dist/chunk-5AHVQXTF.cjs.map +1 -0
- package/dist/chunk-624KWJWZ.js +170 -0
- package/dist/chunk-624KWJWZ.js.map +1 -0
- package/dist/chunk-6HGFEKD3.cjs +851 -0
- package/dist/chunk-6HGFEKD3.cjs.map +1 -0
- package/dist/chunk-7ZTZZ5PN.cjs.map +1 -1
- package/dist/chunk-ALWV4P7D.js +726 -0
- package/dist/chunk-ALWV4P7D.js.map +1 -0
- package/dist/chunk-BADJJ6DV.cjs +143 -0
- package/dist/chunk-BADJJ6DV.cjs.map +1 -0
- package/dist/chunk-C3LMS36L.cjs +393 -0
- package/dist/chunk-C3LMS36L.cjs.map +1 -0
- package/dist/chunk-C3YWUZW3.cjs.map +1 -1
- package/dist/chunk-CR6OUWBJ.cjs +726 -0
- package/dist/chunk-CR6OUWBJ.cjs.map +1 -0
- package/dist/chunk-CYWDZLWC.js +2141 -0
- package/dist/chunk-CYWDZLWC.js.map +1 -0
- package/dist/chunk-DDOGX2D5.js +378 -0
- package/dist/chunk-DDOGX2D5.js.map +1 -0
- package/dist/chunk-DVN6E5U3.js +620 -0
- package/dist/chunk-DVN6E5U3.js.map +1 -0
- package/dist/chunk-EURMRU2S.js +208 -0
- package/dist/chunk-EURMRU2S.js.map +1 -0
- package/dist/chunk-EXDCK2VL.cjs +20 -0
- package/dist/chunk-EXDCK2VL.cjs.map +1 -0
- package/dist/chunk-G5EIUP52.js +114 -0
- package/dist/chunk-G5EIUP52.js.map +1 -0
- package/dist/chunk-GB4DGKLZ.js +143 -0
- package/dist/chunk-GB4DGKLZ.js.map +1 -0
- package/dist/chunk-GPOEAYOW.js +2147 -0
- package/dist/chunk-GPOEAYOW.js.map +1 -0
- package/dist/chunk-I4YMA5VM.cjs +120 -0
- package/dist/chunk-I4YMA5VM.cjs.map +1 -0
- package/dist/chunk-IVWHMDCB.cjs +4383 -0
- package/dist/chunk-IVWHMDCB.cjs.map +1 -0
- package/dist/chunk-JFCBJMA7.cjs +2147 -0
- package/dist/chunk-JFCBJMA7.cjs.map +1 -0
- package/dist/chunk-JLVSAZ3K.cjs +813 -0
- package/dist/chunk-JLVSAZ3K.cjs.map +1 -0
- package/dist/chunk-K7FYH6UG.cjs +208 -0
- package/dist/chunk-K7FYH6UG.cjs.map +1 -0
- package/dist/chunk-L4MYCETM.cjs +970 -0
- package/dist/chunk-L4MYCETM.cjs.map +1 -0
- package/dist/chunk-MNCMYNYL.js +970 -0
- package/dist/chunk-MNCMYNYL.js.map +1 -0
- package/dist/chunk-NT2BZ3QM.js +120 -0
- package/dist/chunk-NT2BZ3QM.js.map +1 -0
- package/dist/chunk-O7SA5GLC.js +277 -0
- package/dist/chunk-O7SA5GLC.js.map +1 -0
- package/dist/chunk-OCKAHITL.cjs +548 -0
- package/dist/chunk-OCKAHITL.cjs.map +1 -0
- package/dist/{chunk-HOKRTYPV.js → chunk-OPBHDUZK.js} +39 -1
- package/dist/chunk-OPBHDUZK.js.map +1 -0
- package/dist/chunk-OTXYWCLA.js +206 -0
- package/dist/chunk-OTXYWCLA.js.map +1 -0
- package/dist/chunk-P6ZA63J7.js +548 -0
- package/dist/chunk-P6ZA63J7.js.map +1 -0
- package/dist/chunk-QLF3BOST.js +20 -0
- package/dist/chunk-QLF3BOST.js.map +1 -0
- package/dist/chunk-RCWFRZDR.js +4383 -0
- package/dist/chunk-RCWFRZDR.js.map +1 -0
- package/dist/chunk-RZBLPM3L.cjs +206 -0
- package/dist/chunk-RZBLPM3L.cjs.map +1 -0
- package/dist/chunk-TA3TNJZU.cjs +360 -0
- package/dist/chunk-TA3TNJZU.cjs.map +1 -0
- package/dist/chunk-TZSRPTQL.cjs +2141 -0
- package/dist/chunk-TZSRPTQL.cjs.map +1 -0
- package/dist/chunk-UMTPJ76S.cjs.map +1 -1
- package/dist/chunk-UY77FXDW.js +813 -0
- package/dist/chunk-UY77FXDW.js.map +1 -0
- package/dist/chunk-VFU3S7OC.js +851 -0
- package/dist/chunk-VFU3S7OC.js.map +1 -0
- package/dist/chunk-VY6WWZSW.cjs.map +1 -1
- package/dist/chunk-WN5DZOVT.cjs +170 -0
- package/dist/chunk-WN5DZOVT.cjs.map +1 -0
- package/dist/{chunk-HZQX4J2J.cjs → chunk-WOPW6WLR.cjs} +40 -2
- package/dist/chunk-WOPW6WLR.cjs.map +1 -0
- package/dist/chunk-XBSIYUHM.cjs +114 -0
- package/dist/chunk-XBSIYUHM.cjs.map +1 -0
- package/dist/chunk-ZMU72HJS.cjs.map +1 -1
- package/dist/context-DSa0ymyN.d.cts +664 -0
- package/dist/context-DaxfAg3b.d.ts +664 -0
- package/dist/effect-chain-Cu03O5Y0.d.ts +91 -0
- package/dist/effect-chain-Do75T7uK.d.cts +91 -0
- package/dist/effect.cjs +16 -1
- package/dist/effect.cjs.map +1 -1
- package/dist/effect.d.cts +56 -14
- package/dist/effect.d.ts +56 -14
- package/dist/effect.js +16 -1
- package/dist/elements.cjs +37 -2
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.d.cts +197 -8
- package/dist/elements.d.ts +197 -8
- package/dist/elements.js +36 -1
- package/dist/events.cjs.map +1 -1
- package/dist/index.cjs +556 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -5
- package/dist/index.d.ts +17 -5
- package/dist/index.js +567 -20
- package/dist/message.cjs +104 -0
- package/dist/message.cjs.map +1 -0
- package/dist/message.d.cts +738 -0
- package/dist/message.d.ts +738 -0
- package/dist/message.js +104 -0
- package/dist/meter.cjs +2 -2
- package/dist/meter.cjs.map +1 -1
- package/dist/meter.d.cts +9 -1
- package/dist/meter.d.ts +9 -1
- package/dist/meter.js +1 -1
- package/dist/module-control-C25BMtH7.d.ts +61 -0
- package/dist/module-control-yH6nTJM9.d.cts +61 -0
- package/dist/module-plugin-BnPmq1VP.d.ts +198 -0
- package/dist/module-plugin-CHb-5W0Y.d.cts +198 -0
- package/dist/module.cjs +263 -0
- package/dist/module.cjs.map +1 -0
- package/dist/module.d.cts +1112 -0
- package/dist/module.d.ts +1112 -0
- package/dist/module.js +263 -0
- package/dist/parameter-DwQzFmBR.d.cts +172 -0
- package/dist/parameter-DwQzFmBR.d.ts +172 -0
- package/dist/player.cjs.map +1 -1
- package/dist/processor-worklet.cjs +18 -0
- package/dist/processor-worklet.cjs.map +1 -0
- package/dist/processor-worklet.d.cts +166 -0
- package/dist/processor-worklet.d.ts +166 -0
- package/dist/processor-worklet.js +18 -0
- package/dist/processor-worklet.js.map +1 -0
- package/dist/processor.cjs +51 -0
- package/dist/processor.cjs.map +1 -0
- package/dist/processor.d.cts +397 -0
- package/dist/processor.d.ts +397 -0
- package/dist/processor.js +51 -0
- package/dist/processor.js.map +1 -0
- package/dist/project-types-BU4awMnL.d.ts +323 -0
- package/dist/project-types-DufCV8Ma.d.cts +323 -0
- package/dist/ring-C-i9N90a.d.cts +139 -0
- package/dist/ring-DkcMt2Eg.d.ts +139 -0
- package/dist/sequence.cjs +68 -0
- package/dist/sequence.cjs.map +1 -0
- package/dist/sequence.d.cts +303 -0
- package/dist/sequence.d.ts +303 -0
- package/dist/sequence.js +68 -0
- package/dist/sequence.js.map +1 -0
- package/dist/session.cjs +16 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +407 -0
- package/dist/session.d.ts +407 -0
- package/dist/session.js +16 -0
- package/dist/session.js.map +1 -0
- package/dist/tick.cjs.map +1 -1
- package/dist/transport.cjs +50 -2
- package/dist/transport.cjs.map +1 -1
- package/dist/transport.d.cts +145 -1
- package/dist/transport.d.ts +145 -1
- package/dist/transport.js +51 -3
- package/dist/worker.cjs.map +1 -1
- package/package.json +62 -11
- package/dist/chunk-53YD73OY.js +0 -162
- package/dist/chunk-53YD73OY.js.map +0 -1
- package/dist/chunk-BR63OD53.cjs +0 -1
- package/dist/chunk-BR63OD53.cjs.map +0 -1
- package/dist/chunk-HOKRTYPV.js.map +0 -1
- package/dist/chunk-HZQX4J2J.cjs.map +0 -1
- package/dist/chunk-JNXB74G3.cjs +0 -987
- package/dist/chunk-JNXB74G3.cjs.map +0 -1
- package/dist/chunk-SM5YPDDI.cjs +0 -162
- package/dist/chunk-SM5YPDDI.cjs.map +0 -1
- package/dist/chunk-TEM2I2NN.js +0 -1
- package/dist/chunk-VVZX7DQ6.cjs +0 -254
- package/dist/chunk-VVZX7DQ6.cjs.map +0 -1
- package/dist/chunk-WNFGDB7B.js +0 -254
- package/dist/chunk-WNFGDB7B.js.map +0 -1
- package/dist/chunk-XBJBY4J5.js +0 -987
- package/dist/chunk-XBJBY4J5.js.map +0 -1
- package/dist/sync.cjs +0 -12
- package/dist/sync.cjs.map +0 -1
- package/dist/sync.d.cts +0 -304
- package/dist/sync.d.ts +0 -304
- package/dist/sync.js +0 -12
- /package/dist/{chunk-TEM2I2NN.js.map → message.js.map} +0 -0
- /package/dist/{sync.js.map → module.js.map} +0 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
import { C as ConnectionLease, a as ControlSignal, d as ParamHandle } from './parameter-DwQzFmBR.js';
|
|
2
|
+
import { TransportClockReader } from './transport.js';
|
|
3
|
+
import { TickSourceOptions } from './tick.js';
|
|
4
|
+
|
|
5
|
+
/** Follower role: a transport that can join the master's timeline. */
|
|
6
|
+
interface SyncFollowerTransport {
|
|
7
|
+
/**
|
|
8
|
+
* Start playback. `when` (optional, absolute reference-clock seconds) is
|
|
9
|
+
* the scheduled start the join dance relies on: the follower MUST honor
|
|
10
|
+
* it sample-accurately for gapless joins (a follower that starts
|
|
11
|
+
* immediately instead will sit one lead-in ahead and be re-corrected
|
|
12
|
+
* forever by the drift monitor).
|
|
13
|
+
*/
|
|
14
|
+
play(when?: number): Promise<void> | void;
|
|
15
|
+
pause(): void;
|
|
16
|
+
stop(): void;
|
|
17
|
+
seek(position: number): void;
|
|
18
|
+
setRate?(rate: number): void;
|
|
19
|
+
/** Current position on the follower's own axis. */
|
|
20
|
+
readonly position: number;
|
|
21
|
+
/** Whether the follower is running, when it can say (optional). */
|
|
22
|
+
readonly running?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Read-only clock on the follower's own axis, when the transport has one.
|
|
25
|
+
* When present, the drift monitor reads position and running state from
|
|
26
|
+
* it instead of sampling `position`/`running`.
|
|
27
|
+
*/
|
|
28
|
+
readonly clock?: TransportClockReader;
|
|
29
|
+
dispose?(): void;
|
|
30
|
+
}
|
|
31
|
+
/** Per-follower registration options. */
|
|
32
|
+
interface FollowerOptions {
|
|
33
|
+
/** Follower position corresponding to master position zero. Default 0. */
|
|
34
|
+
offsetSeconds?: number;
|
|
35
|
+
/** Positive affine scale: local position = offsetSeconds + master position × positionScale.
|
|
36
|
+
* The follower's playback rate is scaled by the same factor. Default 1.
|
|
37
|
+
* This is a constant map, not nonlinear warping. */
|
|
38
|
+
positionScale?: number;
|
|
39
|
+
/** Local loop bounds for a transport ALREADY configured to loop natively.
|
|
40
|
+
* The group maps join/seek positions and drift into this phase; it does not
|
|
41
|
+
* configure or schedule that native loop. Positions before the loop end
|
|
42
|
+
* retain their intro; at/past the end they wrap into [start, end). */
|
|
43
|
+
loop?: SyncLoopRegion;
|
|
44
|
+
}
|
|
45
|
+
interface TransportGroupOptions {
|
|
46
|
+
/** Scheduling headroom before followers join, in seconds. Default 0.06. */
|
|
47
|
+
leadInSeconds?: number;
|
|
48
|
+
/** Re-join a follower when |follower − expected| exceeds this. Default 0.03 s. */
|
|
49
|
+
driftToleranceSeconds?: number;
|
|
50
|
+
/** Drift check cadence. Default 250 ms. 0 disables follower drift checks;
|
|
51
|
+
* the playback watcher still detects natural master stops and loop ends. */
|
|
52
|
+
driftCheckIntervalMs?: number;
|
|
53
|
+
/** Loop region on the master axis; also settable live via {@link TransportGroup.setLoop}. */
|
|
54
|
+
loop?: SyncLoopRegion | null;
|
|
55
|
+
/** Injectable tick source options (tests; custom hosting). */
|
|
56
|
+
tick?: TickSourceOptions;
|
|
57
|
+
/**
|
|
58
|
+
* Observer for failures of the group's own fire-and-forget operations
|
|
59
|
+
* (drift and rate re-joins, loop wraps, pause/stop reconciliation). Those
|
|
60
|
+
* run behind the command queue with no caller promise to reject, and on
|
|
61
|
+
* failure they settle the group into a paused state — without an observer
|
|
62
|
+
* that settlement is silent. Observer exceptions are swallowed.
|
|
63
|
+
*/
|
|
64
|
+
onOperationError?: (operation: string, error: unknown) => void;
|
|
65
|
+
}
|
|
66
|
+
/** A loop region on the master position axis. */
|
|
67
|
+
interface SyncLoopRegion {
|
|
68
|
+
startSeconds: number;
|
|
69
|
+
endSeconds: number;
|
|
70
|
+
}
|
|
71
|
+
/** Commands accepted by the group's single authority. Positions use the master's
|
|
72
|
+
* stable content axis, never a duration divided by the current playback rate. */
|
|
73
|
+
type TransportCommand = {
|
|
74
|
+
readonly type: 'play' | 'pause' | 'stop';
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: 'seek';
|
|
77
|
+
readonly position: number;
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: 'rate';
|
|
80
|
+
readonly rate: number;
|
|
81
|
+
} | {
|
|
82
|
+
readonly type: 'loop';
|
|
83
|
+
readonly loop: SyncLoopRegion | null;
|
|
84
|
+
};
|
|
85
|
+
/** Coherent observation at one reference-clock instant. This is a snapshot,
|
|
86
|
+
* not a display timer; read again or use clock.positionAt for moving positions. */
|
|
87
|
+
interface TransportSnapshot {
|
|
88
|
+
readonly revision: number;
|
|
89
|
+
readonly referenceTime: number;
|
|
90
|
+
readonly position: number;
|
|
91
|
+
readonly rate: number;
|
|
92
|
+
readonly paused: boolean;
|
|
93
|
+
readonly holding: boolean;
|
|
94
|
+
readonly loop: Readonly<SyncLoopRegion> | null;
|
|
95
|
+
readonly pending: boolean;
|
|
96
|
+
readonly disposed: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface TransportCommit {
|
|
99
|
+
readonly revision: number;
|
|
100
|
+
readonly command: TransportCommand;
|
|
101
|
+
/** A newer command or disposal supersedes this operation's authority. */
|
|
102
|
+
readonly status: 'committed' | 'superseded';
|
|
103
|
+
readonly snapshot: TransportSnapshot;
|
|
104
|
+
}
|
|
105
|
+
/** Invalidation precedes participant commands, settlement follows their
|
|
106
|
+
* asynchronous work. Engines retract/re-arm through their existing commands;
|
|
107
|
+
* this observer protocol does not inject a shared writable clock. */
|
|
108
|
+
type TransportEvent = {
|
|
109
|
+
readonly type: 'snapshot';
|
|
110
|
+
readonly snapshot: TransportSnapshot;
|
|
111
|
+
} | {
|
|
112
|
+
readonly type: 'reconcile';
|
|
113
|
+
readonly operation: string;
|
|
114
|
+
readonly phase: 'invalidate' | 'settled';
|
|
115
|
+
readonly snapshot: TransportSnapshot;
|
|
116
|
+
} | {
|
|
117
|
+
readonly type: 'operation-error';
|
|
118
|
+
readonly operation: string;
|
|
119
|
+
readonly error: unknown;
|
|
120
|
+
readonly snapshot: TransportSnapshot;
|
|
121
|
+
} | {
|
|
122
|
+
readonly type: 'invalidate';
|
|
123
|
+
readonly revision: number;
|
|
124
|
+
readonly command: TransportCommand;
|
|
125
|
+
readonly snapshot: TransportSnapshot;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: 'commit';
|
|
128
|
+
readonly commit: TransportCommit;
|
|
129
|
+
readonly snapshot: TransportSnapshot;
|
|
130
|
+
} | {
|
|
131
|
+
readonly type: 'error';
|
|
132
|
+
readonly revision: number;
|
|
133
|
+
readonly command: TransportCommand;
|
|
134
|
+
readonly error: unknown;
|
|
135
|
+
readonly snapshot: TransportSnapshot;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
interface SessionSchedulingSnapshot {
|
|
139
|
+
readonly epoch: number;
|
|
140
|
+
readonly phase: 'invalidated' | 'ready' | 'disposed';
|
|
141
|
+
readonly referenceTime: number;
|
|
142
|
+
readonly originTime: number;
|
|
143
|
+
readonly originPosition: number;
|
|
144
|
+
readonly rate: number;
|
|
145
|
+
readonly paused: boolean;
|
|
146
|
+
readonly holding: boolean;
|
|
147
|
+
readonly loop: Readonly<SyncLoopRegion> | null;
|
|
148
|
+
}
|
|
149
|
+
interface SessionScheduleSegment {
|
|
150
|
+
readonly epoch: number;
|
|
151
|
+
/** Zero includes the intro and first pass; later loop passes increment it. */
|
|
152
|
+
readonly iteration: number;
|
|
153
|
+
readonly referenceStart: number;
|
|
154
|
+
readonly referenceEnd: number;
|
|
155
|
+
readonly positionStart: number;
|
|
156
|
+
readonly positionEnd: number;
|
|
157
|
+
readonly rate: number;
|
|
158
|
+
}
|
|
159
|
+
interface SessionSchedulingEvent {
|
|
160
|
+
readonly type: 'invalidate' | 'anchor' | 'dispose';
|
|
161
|
+
readonly snapshot: SessionSchedulingSnapshot;
|
|
162
|
+
readonly cause?: TransportCommand['type'];
|
|
163
|
+
}
|
|
164
|
+
/** A borrowed read-only view of one authority, mapped into one named local axis. */
|
|
165
|
+
interface SessionSchedulingBinding {
|
|
166
|
+
readonly authority: object;
|
|
167
|
+
readonly axis: string;
|
|
168
|
+
readonly epoch: number;
|
|
169
|
+
/** Continuous unwrapped position; use segments to schedule wrapped passes. */
|
|
170
|
+
readonly clock: TransportClockReader;
|
|
171
|
+
readonly snapshot: SessionSchedulingSnapshot;
|
|
172
|
+
positionAt(referenceTime: number): number;
|
|
173
|
+
segments(fromReferenceTime: number, toReferenceTime: number): readonly SessionScheduleSegment[];
|
|
174
|
+
/** Initial delivery is synchronous. Scheduling callbacks must be synchronous. */
|
|
175
|
+
subscribe(listener: (event: SessionSchedulingEvent) => void): () => void;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface SessionAutomationPoint {
|
|
179
|
+
readonly type: 'set' | 'linear' | 'exponential';
|
|
180
|
+
readonly value: number;
|
|
181
|
+
/** Position in the scheduling binding's named seconds axis. */
|
|
182
|
+
readonly timeSeconds: number;
|
|
183
|
+
}
|
|
184
|
+
interface SessionModulationOptions {
|
|
185
|
+
/** Repeat follows wrapped positions; once follows the unwrapped shared axis. */
|
|
186
|
+
readonly loop?: 'repeat' | 'once';
|
|
187
|
+
/** Native work is submitted this far ahead; default 0.25 reference seconds. */
|
|
188
|
+
readonly lookaheadSeconds?: number;
|
|
189
|
+
readonly tick?: TickSourceOptions;
|
|
190
|
+
readonly onError?: (error: unknown) => void;
|
|
191
|
+
}
|
|
192
|
+
interface SessionAutomationOptions extends SessionModulationOptions {
|
|
193
|
+
/** Baseline at axis zero before the first point; defaults to the parameter base at attachment. */
|
|
194
|
+
readonly initialValue?: number;
|
|
195
|
+
/** Called synchronously once after ownership ends and cleanup completes, including manual overrides. Observer failures are contained. */
|
|
196
|
+
readonly onRelease?: () => void;
|
|
197
|
+
}
|
|
198
|
+
interface SessionAutomationLease extends ConnectionLease {
|
|
199
|
+
readonly error: unknown;
|
|
200
|
+
readonly initialValue: number;
|
|
201
|
+
}
|
|
202
|
+
/** Own a relative automation track; bindings/parameters/context remain borrowed. */
|
|
203
|
+
declare function attachSessionAutomation(binding: SessionSchedulingBinding, context: BaseAudioContext, parameter: ParamHandle, points: readonly SessionAutomationPoint[], options?: SessionAutomationOptions): SessionAutomationLease;
|
|
204
|
+
interface SessionLFOOptions extends SessionModulationOptions {
|
|
205
|
+
/** Cycles per binding-axis second, scaled by Session playback rate. */
|
|
206
|
+
readonly frequency?: number;
|
|
207
|
+
readonly waveform?: 'sine' | 'square' | 'triangle' | 'sawtooth';
|
|
208
|
+
/** Initial phase in cycles, [0, 1]. */
|
|
209
|
+
readonly phase?: number;
|
|
210
|
+
}
|
|
211
|
+
/** Native waveform segments whose phase is derived from the shared Session axis. */
|
|
212
|
+
declare class SessionLFO {
|
|
213
|
+
private readonly context;
|
|
214
|
+
private readonly binding;
|
|
215
|
+
private readonly options;
|
|
216
|
+
readonly signal: ControlSignal;
|
|
217
|
+
readonly frequency: ParamHandle;
|
|
218
|
+
readonly phase: ParamHandle;
|
|
219
|
+
private readonly output;
|
|
220
|
+
private readonly ticker;
|
|
221
|
+
private readonly sources;
|
|
222
|
+
private readonly lookahead;
|
|
223
|
+
private buffer;
|
|
224
|
+
private shape;
|
|
225
|
+
private cycles;
|
|
226
|
+
private phaseOffset;
|
|
227
|
+
private scheduledUntil;
|
|
228
|
+
private stopped;
|
|
229
|
+
private unbind;
|
|
230
|
+
private failure;
|
|
231
|
+
constructor(context: BaseAudioContext, binding: SessionSchedulingBinding, options?: SessionLFOOptions);
|
|
232
|
+
get waveform(): NonNullable<SessionLFOOptions['waveform']>;
|
|
233
|
+
get error(): unknown;
|
|
234
|
+
setWaveform(waveform: NonNullable<SessionLFOOptions['waveform']>): void;
|
|
235
|
+
dispose(): void;
|
|
236
|
+
private rearm;
|
|
237
|
+
private cancel;
|
|
238
|
+
private fill;
|
|
239
|
+
private makeBuffer;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* How a participant actually times its sound (DEC-068). `shared-anchor`
|
|
244
|
+
* schedules natively from the Session's read-only anchor; `callback` attaches
|
|
245
|
+
* scheduling but starts notes from timer callbacks; `media-follower` follows
|
|
246
|
+
* commands like a media element; `external` drives a device or engine the
|
|
247
|
+
* Session cannot schedule (Web MIDI, a third-party engine).
|
|
248
|
+
*/
|
|
249
|
+
type ParticipantTiming = 'shared-anchor' | 'callback' | 'media-follower' | 'external';
|
|
250
|
+
/** Domain adapters name their stable local seconds axis explicitly. */
|
|
251
|
+
interface SessionParticipantOptions extends FollowerOptions {
|
|
252
|
+
axis: string;
|
|
253
|
+
/** Local endpoint in the declared axis. null is unknown; Infinity is live. */
|
|
254
|
+
durationSeconds: number | null | (() => number | null);
|
|
255
|
+
/** Actual engine completion, never inferred from a paused transport. */
|
|
256
|
+
ended?: () => boolean;
|
|
257
|
+
/** Opt in to completion at the mapped finite endpoint when no ended signal exists. */
|
|
258
|
+
endPolicy?: 'participant' | 'position';
|
|
259
|
+
/** The borrowed engine itself; prevents duplicates through different adapters. */
|
|
260
|
+
identity?: object;
|
|
261
|
+
/** Prepare resources before establishing a shared start origin. */
|
|
262
|
+
prepare?: () => void | Promise<void>;
|
|
263
|
+
/**
|
|
264
|
+
* Refuse a start this participant cannot join now: called synchronously
|
|
265
|
+
* for each play, before anything is prepared, and what it throws rejects
|
|
266
|
+
* that play. A preload does not ask, so `prepare` may wait for what a
|
|
267
|
+
* start must not.
|
|
268
|
+
*/
|
|
269
|
+
assertStartable?: () => void;
|
|
270
|
+
/** Resume reference-clock resources only when playback is explicitly requested. */
|
|
271
|
+
activate?: () => void | Promise<void>;
|
|
272
|
+
/** Opt into one shared scheduling authority instead of legacy follower commands. */
|
|
273
|
+
attachScheduling?: (binding: SessionSchedulingBinding) => ConnectionLease;
|
|
274
|
+
/**
|
|
275
|
+
* The participant's real timing. Defaults to `shared-anchor` with
|
|
276
|
+
* `attachScheduling`, otherwise `media-follower`. `shared-anchor` requires
|
|
277
|
+
* `attachScheduling`; a callback-timed engine must not claim it.
|
|
278
|
+
*/
|
|
279
|
+
timing?: ParticipantTiming;
|
|
280
|
+
}
|
|
281
|
+
interface SessionParticipantLease {
|
|
282
|
+
readonly token: symbol;
|
|
283
|
+
readonly active: boolean;
|
|
284
|
+
/** Resolves after explicit play/preload preparation and registration (or release).
|
|
285
|
+
* Merely discovering a member in a paused Session does not prepare resources.
|
|
286
|
+
* After a rejected attempt, a retried preparation exposes a fresh promise. */
|
|
287
|
+
readonly ready: Promise<void>;
|
|
288
|
+
/** Resolves after release and cancellation of late preparation/play work. */
|
|
289
|
+
readonly settled: Promise<void>;
|
|
290
|
+
/** A failed cancellation blocks reuse until a later release() succeeds. */
|
|
291
|
+
readonly cancellationError: unknown;
|
|
292
|
+
/** Unregister first, then cancel only this member; never disposes its engine. */
|
|
293
|
+
release(): void;
|
|
294
|
+
/**
|
|
295
|
+
* The member's source changed in place (a new duration or end), without a
|
|
296
|
+
* new registration: observers receive a `participants` event and re-read
|
|
297
|
+
* the snapshot. Ignored once released.
|
|
298
|
+
*/
|
|
299
|
+
refresh(): void;
|
|
300
|
+
}
|
|
301
|
+
/** A pending data load, never a fabricated transport participant. */
|
|
302
|
+
interface SessionPendingSourceLease {
|
|
303
|
+
readonly token: symbol;
|
|
304
|
+
readonly active: boolean;
|
|
305
|
+
readonly ready: Promise<void>;
|
|
306
|
+
/** Complete only after registering the actual loaded participant. */
|
|
307
|
+
resolve(): void;
|
|
308
|
+
/** Keep failed readiness explicit until retry/replacement/cancellation releases it. */
|
|
309
|
+
reject(error: unknown): void;
|
|
310
|
+
/** Cancel this reservation and unblock waiters; stale completions are ignored. */
|
|
311
|
+
release(): void;
|
|
312
|
+
}
|
|
313
|
+
interface SessionTransportOptions extends TransportGroupOptions {
|
|
314
|
+
/** Explicit Session-seconds bounds override inferred member duration/end policy. */
|
|
315
|
+
range?: SyncLoopRegion;
|
|
316
|
+
}
|
|
317
|
+
interface SessionTransportSnapshot extends TransportSnapshot {
|
|
318
|
+
readonly axis: 'session-seconds';
|
|
319
|
+
readonly durationSeconds: number | null;
|
|
320
|
+
readonly participantCount: number;
|
|
321
|
+
readonly pendingSourceCount: number;
|
|
322
|
+
readonly membershipRevision: number;
|
|
323
|
+
readonly ended: boolean;
|
|
324
|
+
readonly range: Readonly<SyncLoopRegion> | null;
|
|
325
|
+
readonly schedulingEpoch: number;
|
|
326
|
+
/** `shared-anchor` only when every participant reports that timing; `legacy` when none attaches scheduling. */
|
|
327
|
+
readonly schedulingMode: 'shared-anchor' | 'mixed' | 'legacy';
|
|
328
|
+
/** Participant count per reported timing. */
|
|
329
|
+
readonly participantTiming: Readonly<Record<ParticipantTiming, number>>;
|
|
330
|
+
}
|
|
331
|
+
type WithSessionSnapshot<Event> = Event extends {
|
|
332
|
+
snapshot: TransportSnapshot;
|
|
333
|
+
} ? Omit<Event, 'snapshot'> & {
|
|
334
|
+
readonly snapshot: SessionTransportSnapshot;
|
|
335
|
+
} : never;
|
|
336
|
+
type SessionTransportEvent = WithSessionSnapshot<TransportEvent> | {
|
|
337
|
+
readonly type: 'participants';
|
|
338
|
+
readonly snapshot: SessionTransportSnapshot;
|
|
339
|
+
} | {
|
|
340
|
+
readonly type: 'source-error';
|
|
341
|
+
readonly error: unknown;
|
|
342
|
+
readonly snapshot: SessionTransportSnapshot;
|
|
343
|
+
} | {
|
|
344
|
+
readonly type: 'participant-error';
|
|
345
|
+
readonly error: unknown;
|
|
346
|
+
readonly snapshot: SessionTransportSnapshot;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* The Session authority as modules borrow it through a ModuleContext. Kernel
|
|
350
|
+
* modules depend on this interface, not on the {@link SessionTransport} class,
|
|
351
|
+
* so a provider can lend a Session it does not implement itself.
|
|
352
|
+
*/
|
|
353
|
+
interface ModuleSession {
|
|
354
|
+
readonly clock: TransportClockReader;
|
|
355
|
+
readonly position: number;
|
|
356
|
+
readonly snapshot: SessionTransportSnapshot;
|
|
357
|
+
readonly participantCount: number;
|
|
358
|
+
readonly scheduling: SessionSchedulingBinding;
|
|
359
|
+
subscribe(listener: (event: SessionTransportEvent) => void): () => void;
|
|
360
|
+
register(transport: SyncFollowerTransport, options: SessionParticipantOptions): SessionParticipantLease;
|
|
361
|
+
holdPendingSource(): SessionPendingSourceLease;
|
|
362
|
+
dispatch(command: TransportCommand): Promise<TransportCommit>;
|
|
363
|
+
/** Start; `when` (reference-clock time) defers the shared start origin to no earlier than it. */
|
|
364
|
+
play(when?: number): Promise<TransportCommit>;
|
|
365
|
+
pause(): Promise<TransportCommit>;
|
|
366
|
+
stop(): Promise<TransportCommit>;
|
|
367
|
+
seek(position: number): Promise<TransportCommit>;
|
|
368
|
+
setRate(rate: number): Promise<TransportCommit>;
|
|
369
|
+
setLoop(loop: SyncLoopRegion | null): Promise<TransportCommit>;
|
|
370
|
+
preload(): Promise<void>;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* A source-free conductor on Session seconds. It owns a clock and the existing
|
|
374
|
+
* TransportGroup command authority, borrowing engines through leaf adapters.
|
|
375
|
+
* It creates no audio resources and never elects a member as a hidden master.
|
|
376
|
+
* All adapters must use the same reference clock supplied by `now`.
|
|
377
|
+
*/
|
|
378
|
+
declare class SessionTransport implements ModuleSession {
|
|
379
|
+
#private;
|
|
380
|
+
readonly scheduling: SessionSchedulingBinding;
|
|
381
|
+
constructor(now: () => number, options?: SessionTransportOptions);
|
|
382
|
+
get clock(): TransportClockReader;
|
|
383
|
+
get position(): number;
|
|
384
|
+
get snapshot(): SessionTransportSnapshot;
|
|
385
|
+
get participantCount(): number;
|
|
386
|
+
holdPendingSource(): SessionPendingSourceLease;
|
|
387
|
+
subscribe(listener: (event: SessionTransportEvent) => void): () => void;
|
|
388
|
+
register(transport: SyncFollowerTransport, options: SessionParticipantOptions): SessionParticipantLease;
|
|
389
|
+
dispatch(command: TransportCommand): Promise<TransportCommit>;
|
|
390
|
+
/**
|
|
391
|
+
* Start every participant from one shared origin. With `when` (a time on the
|
|
392
|
+
* Session's reference clock) the origin is no earlier than `when`, so a
|
|
393
|
+
* caller can schedule a start; an expired `when` starts after the lead-in.
|
|
394
|
+
*/
|
|
395
|
+
play(when?: number): Promise<TransportCommit>;
|
|
396
|
+
pause(): Promise<TransportCommit>;
|
|
397
|
+
stop(): Promise<TransportCommit>;
|
|
398
|
+
seek(position: number): Promise<TransportCommit>;
|
|
399
|
+
setRate(rate: number): Promise<TransportCommit>;
|
|
400
|
+
setLoop(loop: SyncLoopRegion | null): Promise<TransportCommit>;
|
|
401
|
+
checkDrift(): number;
|
|
402
|
+
/** Explicit resource preparation; registration alone cannot allocate audio. */
|
|
403
|
+
preload(): Promise<void>;
|
|
404
|
+
dispose(): void;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
export { type FollowerOptions, type ModuleSession, type ParticipantTiming, type SessionAutomationLease, type SessionAutomationOptions, type SessionAutomationPoint, SessionLFO, type SessionLFOOptions, type SessionModulationOptions, type SessionParticipantLease, type SessionParticipantOptions, type SessionPendingSourceLease, type SessionScheduleSegment, type SessionSchedulingBinding, type SessionSchedulingEvent, type SessionSchedulingSnapshot, SessionTransport, type SessionTransportEvent, type SessionTransportOptions, type SessionTransportSnapshot, type SyncFollowerTransport, type SyncLoopRegion, type TransportCommand, type TransportCommit, type TransportEvent, type TransportSnapshot, attachSessionAutomation };
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SessionLFO,
|
|
3
|
+
SessionTransport,
|
|
4
|
+
attachSessionAutomation
|
|
5
|
+
} from "./chunk-GPOEAYOW.js";
|
|
6
|
+
import "./chunk-DVN6E5U3.js";
|
|
7
|
+
import "./chunk-FJLY3RWZ.js";
|
|
8
|
+
import "./chunk-4RG4WQKC.js";
|
|
9
|
+
import "./chunk-QLF3BOST.js";
|
|
10
|
+
import "./chunk-PXG64RU4.js";
|
|
11
|
+
export {
|
|
12
|
+
SessionLFO,
|
|
13
|
+
SessionTransport,
|
|
14
|
+
attachSessionAutomation
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/tick.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users
|
|
1
|
+
{"version":3,"sources":["/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/tick.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,iIAAC","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/tick.cjs"}
|
package/dist/transport.cjs
CHANGED
|
@@ -1,8 +1,56 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkTA3TNJZUcjs = require('./chunk-TA3TNJZU.cjs');
|
|
4
28
|
require('./chunk-7ZTZZ5PN.cjs');
|
|
5
29
|
|
|
6
30
|
|
|
7
|
-
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.DEFAULT_MUSICAL_TEMPO = _chunkTA3TNJZUcjs.DEFAULT_MUSICAL_TEMPO; exports.MAX_TEMPO_GRID_BEATS_PER_BAR = _chunkTA3TNJZUcjs.MAX_TEMPO_GRID_BEATS_PER_BAR; exports.MAX_TEMPO_GRID_BPM = _chunkTA3TNJZUcjs.MAX_TEMPO_GRID_BPM; exports.TICKS_PER_QUARTER = _chunkTA3TNJZUcjs.TICKS_PER_QUARTER; exports.TempoClock = _chunkTA3TNJZUcjs.TempoClock; exports.TransportClock = _chunkTA3TNJZUcjs.TransportClock; exports.barsBeatsTicksAt = _chunkTA3TNJZUcjs.barsBeatsTicksAt; exports.createMusicalTempo = _chunkTA3TNJZUcjs.createMusicalTempo; exports.createTempoGrid = _chunkTA3TNJZUcjs.createTempoGrid; exports.formatBarsBeatsTicks = _chunkTA3TNJZUcjs.formatBarsBeatsTicks; exports.nextGridTime = _chunkTA3TNJZUcjs.nextGridTime; exports.secondsAtBarsBeatsTicks = _chunkTA3TNJZUcjs.secondsAtBarsBeatsTicks; exports.snapToTempoGrid = _chunkTA3TNJZUcjs.snapToTempoGrid; exports.tapTempo = _chunkTA3TNJZUcjs.tapTempo; exports.tempoGridBeatLength = _chunkTA3TNJZUcjs.tempoGridBeatLength; exports.tempoGridBeatPosition = _chunkTA3TNJZUcjs.tempoGridBeatPosition; exports.tempoGridJump = _chunkTA3TNJZUcjs.tempoGridJump; exports.tempoGridLines = _chunkTA3TNJZUcjs.tempoGridLines; exports.tempoGridMapping = _chunkTA3TNJZUcjs.tempoGridMapping; exports.tempoGridPosition = _chunkTA3TNJZUcjs.tempoGridPosition; exports.tickSeconds = _chunkTA3TNJZUcjs.tickSeconds; exports.ticksPerBar = _chunkTA3TNJZUcjs.ticksPerBar; exports.ticksPerBeat = _chunkTA3TNJZUcjs.ticksPerBeat; exports.timeValueSeconds = _chunkTA3TNJZUcjs.timeValueSeconds; exports.timeValueTicks = _chunkTA3TNJZUcjs.timeValueTicks;
|
|
8
56
|
//# sourceMappingURL=transport.cjs.map
|
package/dist/transport.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users
|
|
1
|
+
{"version":3,"sources":["/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/transport.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,oiDAAC","file":"/private/tmp/claude-501/-Users-mamingchen-GitHub-public-WebMusic/77eac0d8-82c0-45c6-aba8-0cd73cfd2b1b/scratchpad/release-0.4.0/platform/kernel/dist/transport.cjs"}
|
package/dist/transport.d.cts
CHANGED
|
@@ -110,5 +110,149 @@ interface TimelineMapping {
|
|
|
110
110
|
positionToSeconds(position: number): number;
|
|
111
111
|
secondsToPosition(seconds: number): number;
|
|
112
112
|
}
|
|
113
|
+
/** Upper bound on a grid tempo; beyond it beat lines are denser than any musical use. */
|
|
114
|
+
declare const MAX_TEMPO_GRID_BPM = 1000;
|
|
115
|
+
/** Upper bound on beats per bar. */
|
|
116
|
+
declare const MAX_TEMPO_GRID_BEATS_PER_BAR = 64;
|
|
117
|
+
/**
|
|
118
|
+
* A constant-tempo beat grid on a transport position axis (typically
|
|
119
|
+
* seconds). `anchor` is the position of one downbeat; every other beat lies a
|
|
120
|
+
* whole number of beat lengths away, extending in both directions without
|
|
121
|
+
* end. Immutable once created through {@link createTempoGrid}.
|
|
122
|
+
*/
|
|
123
|
+
interface TempoGrid {
|
|
124
|
+
/** Beats per minute of the position axis; finite, > 0 and ≤ {@link MAX_TEMPO_GRID_BPM}. */
|
|
125
|
+
readonly bpm: number;
|
|
126
|
+
/** Position of a downbeat (bar start), on the transport axis. */
|
|
127
|
+
readonly anchor: number;
|
|
128
|
+
/** Beats in one bar; an integer from 1 to {@link MAX_TEMPO_GRID_BEATS_PER_BAR}. */
|
|
129
|
+
readonly beatsPerBar: number;
|
|
130
|
+
}
|
|
131
|
+
interface TempoGridInit {
|
|
132
|
+
readonly bpm: number;
|
|
133
|
+
readonly anchor?: number;
|
|
134
|
+
readonly beatsPerBar?: number;
|
|
135
|
+
}
|
|
136
|
+
/** Where a position falls on a {@link TempoGrid}. */
|
|
137
|
+
interface TempoGridPosition {
|
|
138
|
+
/** Continuous beat index from the anchor; negative before it. */
|
|
139
|
+
readonly beat: number;
|
|
140
|
+
/** Bar index from the anchor's bar (0); negative before it. */
|
|
141
|
+
readonly bar: number;
|
|
142
|
+
/** Beat inside the bar, 0 … beatsPerBar − 1. */
|
|
143
|
+
readonly beatInBar: number;
|
|
144
|
+
/** Fraction of the current beat already elapsed, in [0, 1). */
|
|
145
|
+
readonly phase: number;
|
|
146
|
+
}
|
|
147
|
+
/** Validate and freeze a grid. Throws RangeError for an invalid tempo, anchor or meter. */
|
|
148
|
+
declare function createTempoGrid(init: TempoGridInit): TempoGrid;
|
|
149
|
+
/** Length of one beat on the grid's position axis (60 / bpm for a seconds axis). */
|
|
150
|
+
declare function tempoGridBeatLength(grid: TempoGrid): number;
|
|
151
|
+
/** Beat, bar and phase at a position. */
|
|
152
|
+
declare function tempoGridPosition(grid: TempoGrid, position: number): TempoGridPosition;
|
|
153
|
+
/** Position of a (possibly fractional) beat index. */
|
|
154
|
+
declare function tempoGridBeatPosition(grid: TempoGrid, beat: number): number;
|
|
155
|
+
interface TempoGridSnapOptions {
|
|
156
|
+
/** Grid lines per beat: 1 beats, 2 eighths in 4/4, 0.25 one line per 4 beats. Default 1. */
|
|
157
|
+
readonly division?: number;
|
|
158
|
+
/** `nearest` (default), `forward` (at or after) or `backward` (at or before). */
|
|
159
|
+
readonly direction?: 'nearest' | 'forward' | 'backward';
|
|
160
|
+
}
|
|
161
|
+
/** The grid line nearest a position, or the next/previous one. */
|
|
162
|
+
declare function snapToTempoGrid(grid: TempoGrid, position: number, options?: TempoGridSnapOptions): number;
|
|
163
|
+
/**
|
|
164
|
+
* Quantized jump: the position near `to` that keeps the beat phase of
|
|
165
|
+
* `from`, so a running transport lands on the beat as it would have played
|
|
166
|
+
* there (the DJ "quantize" behavior). `to` is rounded to its nearest beat
|
|
167
|
+
* first; the phase of `from` is then added.
|
|
168
|
+
*/
|
|
169
|
+
declare function tempoGridJump(grid: TempoGrid, from: number, to: number): number;
|
|
170
|
+
/** Positions of the grid lines inside [start, end], with their beat index. */
|
|
171
|
+
declare function tempoGridLines(grid: TempoGrid, start: number, end: number, division?: number): readonly {
|
|
172
|
+
readonly position: number;
|
|
173
|
+
readonly beat: number;
|
|
174
|
+
readonly downbeat: boolean;
|
|
175
|
+
}[];
|
|
176
|
+
/** The grid as a {@link TimelineMapping} between beats and its position axis. */
|
|
177
|
+
declare function tempoGridMapping(grid: TempoGrid): TimelineMapping;
|
|
178
|
+
/**
|
|
179
|
+
* Tempo from tap times (any monotonic seconds, such as `performance.now() / 1000`):
|
|
180
|
+
* the median interval of the most recent run of taps, where a gap longer than
|
|
181
|
+
* `resetSeconds` starts a new run. Undefined until a run has two taps.
|
|
182
|
+
*/
|
|
183
|
+
declare function tapTempo(times: readonly number[], resetSeconds?: number): number | undefined;
|
|
184
|
+
/**
|
|
185
|
+
* Beats read from a transport clock: a {@link TransportClockReader} paired
|
|
186
|
+
* with a {@link TempoGrid} on the same position axis. Read-only — it never
|
|
187
|
+
* re-anchors the clock — and immutable; pair the clock with a new grid
|
|
188
|
+
* through {@link withGrid}. All reference times are the clock's.
|
|
189
|
+
*/
|
|
190
|
+
declare class TempoClock {
|
|
191
|
+
readonly clock: TransportClockReader;
|
|
192
|
+
readonly grid: TempoGrid;
|
|
193
|
+
constructor(clock: TransportClockReader, grid: TempoGrid);
|
|
194
|
+
/** Same clock, another grid. */
|
|
195
|
+
withGrid(grid: TempoGrid): TempoClock;
|
|
196
|
+
/** Beat, bar and phase at reference time `t`. */
|
|
197
|
+
positionAt(t: number): TempoGridPosition;
|
|
198
|
+
/** Continuous beat index at reference time `t`. */
|
|
199
|
+
beatAt(t: number): number;
|
|
200
|
+
/** Tempo heard at the current rate: grid bpm × clock rate. */
|
|
201
|
+
get effectiveBpm(): number;
|
|
202
|
+
/**
|
|
203
|
+
* Reference time of the next grid line strictly after `t` (`division`
|
|
204
|
+
* lines per beat) — the instant to schedule a quantized action. Throws
|
|
205
|
+
* RangeError while the clock is paused, like {@link TransportClock.timeAt}.
|
|
206
|
+
*/
|
|
207
|
+
nextGridTime(t: number, division?: number): number;
|
|
208
|
+
/** Reference time at which a beat index plays. Throws RangeError while paused. */
|
|
209
|
+
timeAtBeat(beat: number): number;
|
|
210
|
+
}
|
|
211
|
+
/** Ticks in one quarter note, as in Max. */
|
|
212
|
+
declare const TICKS_PER_QUARTER = 480;
|
|
213
|
+
interface MusicalTempo {
|
|
214
|
+
/** Quarter notes per minute; finite and > 0. */
|
|
215
|
+
readonly bpm: number;
|
|
216
|
+
/** Beats in a bar (time-signature numerator). */
|
|
217
|
+
readonly beatsPerBar: number;
|
|
218
|
+
/** The note value of one beat (time-signature denominator): 2, 4, 8 or 16. */
|
|
219
|
+
readonly beatUnit: number;
|
|
220
|
+
}
|
|
221
|
+
/** A position as bars, beats and ticks, all counted from 1 except ticks (from 0). */
|
|
222
|
+
interface BarsBeatsTicks {
|
|
223
|
+
readonly bar: number;
|
|
224
|
+
readonly beat: number;
|
|
225
|
+
readonly tick: number;
|
|
226
|
+
}
|
|
227
|
+
declare const DEFAULT_MUSICAL_TEMPO: MusicalTempo;
|
|
228
|
+
/** Validate and freeze a tempo. */
|
|
229
|
+
declare function createMusicalTempo(init?: Partial<MusicalTempo>): MusicalTempo;
|
|
230
|
+
/** Seconds per tick at a tempo. */
|
|
231
|
+
declare const tickSeconds: (tempo: MusicalTempo) => number;
|
|
232
|
+
/** Ticks in one beat of the meter. */
|
|
233
|
+
declare const ticksPerBeat: (tempo: MusicalTempo) => number;
|
|
234
|
+
/** Ticks in one bar. */
|
|
235
|
+
declare const ticksPerBar: (tempo: MusicalTempo) => number;
|
|
236
|
+
/**
|
|
237
|
+
* The length in ticks of a time value: a note value (`1n`, `4n`, `8nd`
|
|
238
|
+
* dotted, `16nt` triplet), `bars.beats.ticks` as a length (`1.0.0` is one
|
|
239
|
+
* bar), or `480 ticks`. Undefined for a value that is not musical (`250ms`,
|
|
240
|
+
* `2hz`, a plain number of milliseconds).
|
|
241
|
+
*/
|
|
242
|
+
declare function timeValueTicks(text: string, tempo?: MusicalTempo): number | undefined;
|
|
243
|
+
/**
|
|
244
|
+
* The length in seconds of a time value at `tempo`: any musical value of
|
|
245
|
+
* {@link timeValueTicks}, or `250ms`, `0.5s`, `2hz` (one period) or a plain
|
|
246
|
+
* number of milliseconds.
|
|
247
|
+
*/
|
|
248
|
+
declare function timeValueSeconds(text: string, tempo?: MusicalTempo): number;
|
|
249
|
+
/** Bars, beats and ticks at `seconds` from `anchor` (where bar 1 beat 1 begins). */
|
|
250
|
+
declare function barsBeatsTicksAt(seconds: number, tempo: MusicalTempo, anchor?: number): BarsBeatsTicks;
|
|
251
|
+
/** Seconds at a bars:beats:ticks position. */
|
|
252
|
+
declare function secondsAtBarsBeatsTicks(position: BarsBeatsTicks, tempo: MusicalTempo, anchor?: number): number;
|
|
253
|
+
/** `bar.beat.tick`, as Max shows a transport position. */
|
|
254
|
+
declare function formatBarsBeatsTicks(position: BarsBeatsTicks): string;
|
|
255
|
+
/** The next multiple of `interval` seconds at or after `position`, measured from `anchor`. */
|
|
256
|
+
declare function nextGridTime(position: number, interval: number, anchor?: number): number;
|
|
113
257
|
|
|
114
|
-
export { type TimelineMapping, TransportClock, type TransportClockReader, type TransportClockState };
|
|
258
|
+
export { type BarsBeatsTicks, DEFAULT_MUSICAL_TEMPO, MAX_TEMPO_GRID_BEATS_PER_BAR, MAX_TEMPO_GRID_BPM, type MusicalTempo, TICKS_PER_QUARTER, TempoClock, type TempoGrid, type TempoGridInit, type TempoGridPosition, type TempoGridSnapOptions, type TimelineMapping, TransportClock, type TransportClockReader, type TransportClockState, barsBeatsTicksAt, createMusicalTempo, createTempoGrid, formatBarsBeatsTicks, nextGridTime, secondsAtBarsBeatsTicks, snapToTempoGrid, tapTempo, tempoGridBeatLength, tempoGridBeatPosition, tempoGridJump, tempoGridLines, tempoGridMapping, tempoGridPosition, tickSeconds, ticksPerBar, ticksPerBeat, timeValueSeconds, timeValueTicks };
|