@waveform-playlist/engine 14.0.0-next.1 → 14.0.0-next.10
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/README.md +104 -44
- package/dist/index.d.mts +274 -55
- package/dist/index.d.ts +274 -55
- package/dist/index.js +951 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +958 -231
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource } from '@waveform-playlist/core';
|
|
1
|
+
import { AudioClip, LoadingClip, ClipTrack, ClipSource, PanLaw, ArrangementTrack, DecidedPanLaw, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Clip Operations
|
|
@@ -7,17 +7,37 @@ import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource } from
|
|
|
7
7
|
* and splitting clips on a timeline. All positions are in samples (integers).
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
/** What a move or a trim collides with: a clip's place on the timeline, in samples. */
|
|
11
|
+
interface ClipSpan {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly startSample: number;
|
|
14
|
+
readonly durationSamples: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A track's clips as a move or a trim sees them, in timeline order (#859).
|
|
18
|
+
* A loaded clip is itself (so `indexOf(clip)` finds it). A loading clip is
|
|
19
|
+
* its `loadingClipSpan` at `sampleRate` (the rate of the edited clip, which
|
|
20
|
+
* is the rate its audio will be decoded at); when only its start is known it
|
|
21
|
+
* holds that one sample, so no edit covers the start, and the arrangement
|
|
22
|
+
* cuts the clip where the next one starts when its audio arrives (also one
|
|
23
|
+
* whose duration, offset or peaks leave no usable length). A loading clip
|
|
24
|
+
* whose start is not usable is left out. The result is the same
|
|
25
|
+
* array for the same clips array and rate; do not mutate it.
|
|
26
|
+
*/
|
|
27
|
+
declare function trackClipSpans(clips: readonly (AudioClip | LoadingClip)[], sampleRate: number): ClipSpan[];
|
|
10
28
|
/**
|
|
11
29
|
* Constrain clip movement delta to prevent overlaps with adjacent clips
|
|
12
|
-
* and going before sample 0.
|
|
30
|
+
* and going before sample 0. A clip that already overlaps a neighbour or
|
|
31
|
+
* starts before 0 can move away from it, not further in.
|
|
13
32
|
*
|
|
14
33
|
* @param clip - The clip being dragged
|
|
15
34
|
* @param deltaSamples - Requested movement in samples (negative = left, positive = right)
|
|
16
|
-
* @param sortedClips -
|
|
35
|
+
* @param sortedClips - Everything on the track it collides with, sorted by startSample
|
|
36
|
+
* (`trackClipSpans`: loaded clips and the spans of loading ones)
|
|
17
37
|
* @param clipIndex - Index of the dragged clip in sortedClips
|
|
18
38
|
* @returns Constrained delta that prevents overlaps
|
|
19
39
|
*/
|
|
20
|
-
declare function constrainClipDrag(clip: AudioClip, deltaSamples: number, sortedClips:
|
|
40
|
+
declare function constrainClipDrag(clip: AudioClip, deltaSamples: number, sortedClips: readonly ClipSpan[], clipIndex: number): number;
|
|
21
41
|
/**
|
|
22
42
|
* Constrain boundary trim delta for left or right edge of a clip.
|
|
23
43
|
*
|
|
@@ -27,15 +47,19 @@ declare function constrainClipDrag(clip: AudioClip, deltaSamples: number, sorted
|
|
|
27
47
|
* RIGHT boundary: delta applied to durationSamples (positive = expand, negative = shrink)
|
|
28
48
|
* - durationSamples += delta
|
|
29
49
|
*
|
|
50
|
+
* A bound the clip already breaks (an edge inside a neighbour, a clip shorter
|
|
51
|
+
* than the minimum) stops the edge where it is: a delta of 0 changes nothing.
|
|
52
|
+
*
|
|
30
53
|
* @param clip - The clip being trimmed
|
|
31
54
|
* @param deltaSamples - Requested trim delta in samples
|
|
32
55
|
* @param boundary - Which edge is being trimmed: 'left' or 'right'
|
|
33
|
-
* @param sortedClips -
|
|
56
|
+
* @param sortedClips - Everything on the track it collides with, sorted by startSample
|
|
57
|
+
* (`trackClipSpans`)
|
|
34
58
|
* @param clipIndex - Index of the trimmed clip in sortedClips
|
|
35
59
|
* @param minDurationSamples - Minimum allowed clip duration in samples
|
|
36
60
|
* @returns Constrained delta
|
|
37
61
|
*/
|
|
38
|
-
declare function constrainBoundaryTrim(clip: AudioClip, deltaSamples: number, boundary: 'left' | 'right', sortedClips:
|
|
62
|
+
declare function constrainBoundaryTrim(clip: AudioClip, deltaSamples: number, boundary: 'left' | 'right', sortedClips: readonly ClipSpan[], clipIndex: number, minDurationSamples: number): number;
|
|
39
63
|
/**
|
|
40
64
|
* Snap a split sample position to the nearest pixel boundary.
|
|
41
65
|
*
|
|
@@ -49,6 +73,14 @@ declare function calculateSplitPoint(splitSample: number, samplesPerPixel: numbe
|
|
|
49
73
|
*
|
|
50
74
|
* The left clip retains the original fadeIn; the right clip retains the original fadeOut.
|
|
51
75
|
* Both clips share the same waveformData reference and the same `src`.
|
|
76
|
+
* A MIDI clip's halves both keep its whole `midiNotes` list (the same array),
|
|
77
|
+
* `midiChannel` and `midiProgram` (#838): like an audio clip's buffer, the notes
|
|
78
|
+
* are the source and each half is a window on them (`offsetSamples` and
|
|
79
|
+
* `durationSamples`), the notes the Tone MIDI tracks play and the piano roll
|
|
80
|
+
* draws. A note that crosses the split is released by the left half at the
|
|
81
|
+
* split (a SoundFont sample that does not loop rings on) and struck again
|
|
82
|
+
* there by the right half.
|
|
83
|
+
* The left clip keeps the original's `id`; the right clip gets a new one.
|
|
52
84
|
* If the clip has a name, suffixes " (1)" and " (2)" are appended.
|
|
53
85
|
*
|
|
54
86
|
* @param clip - The clip to split
|
|
@@ -208,14 +240,20 @@ interface ArrangementSourcesValue {
|
|
|
208
240
|
}
|
|
209
241
|
|
|
210
242
|
/**
|
|
211
|
-
* The mixer part of an arrangement: volume, mute, solo and pan by
|
|
212
|
-
* as pure functions over an immutable Map.
|
|
243
|
+
* The mixer part of an arrangement: volume, mute, solo, pan and pan law by
|
|
244
|
+
* track id, as pure functions over an immutable Map.
|
|
213
245
|
*
|
|
214
246
|
* The values live here and not on the track objects, so a fader move
|
|
215
|
-
* replaces no track
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* not read while it
|
|
247
|
+
* replaces no track. The current Map holds an entry for each current track;
|
|
248
|
+
* each saved state of the history holds its own Map (#843). A track's own
|
|
249
|
+
* `volume` / `muted` / `soloed` / `pan` fields are the values it ENTERED
|
|
250
|
+
* with; they seed its entry when its id has none, and are not read while it
|
|
251
|
+
* has one.
|
|
252
|
+
*
|
|
253
|
+
* The pan law (#684) is `'auto'` until the track holds decoded audio; that
|
|
254
|
+
* audio decides it (`decidePanLaws`), and from then on the track's clips do
|
|
255
|
+
* not change it. `'auto'` is only ever the law of a track with no decoded
|
|
256
|
+
* audio, or of a MIDI track (which always plays with the mono law).
|
|
219
257
|
*/
|
|
220
258
|
|
|
221
259
|
interface TrackMixerValues {
|
|
@@ -223,6 +261,8 @@ interface TrackMixerValues {
|
|
|
223
261
|
muted: boolean;
|
|
224
262
|
soloed: boolean;
|
|
225
263
|
pan: number;
|
|
264
|
+
/** `'auto'` until the track's first decoded audio decides it (#684). */
|
|
265
|
+
panLaw: PanLaw;
|
|
226
266
|
}
|
|
227
267
|
|
|
228
268
|
/**
|
|
@@ -244,10 +284,70 @@ interface RemoveTrackOptions {
|
|
|
244
284
|
*/
|
|
245
285
|
undoable?: boolean;
|
|
246
286
|
}
|
|
287
|
+
/** Options of `removeClip`. */
|
|
288
|
+
interface RemoveClipOptions {
|
|
289
|
+
/**
|
|
290
|
+
* `false`: the removal is not an undo step, and the clip is also taken out
|
|
291
|
+
* of every undo and redo state, so no undo or redo brings it back (a
|
|
292
|
+
* `<daw-clip>` the page removed while its track was detached, #848).
|
|
293
|
+
*/
|
|
294
|
+
undoable?: boolean;
|
|
295
|
+
}
|
|
296
|
+
/** Options of `addTrack`. */
|
|
297
|
+
interface AddTrackOptions {
|
|
298
|
+
/**
|
|
299
|
+
* Where the track enters: its index in the new order (cut to a whole
|
|
300
|
+
* number, then held between 0 and the number of tracks). Left out: at the end.
|
|
301
|
+
*/
|
|
302
|
+
index?: number;
|
|
303
|
+
}
|
|
304
|
+
/** How a mixer setter's change goes into the undo history. */
|
|
305
|
+
interface MixerChangeOptions {
|
|
306
|
+
/** Changes with the same id, one after another, are one undo step. */
|
|
307
|
+
gesture?: string;
|
|
308
|
+
/** Not an undo step: the value is written into every saved state as well. */
|
|
309
|
+
undoable?: false;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* The kind of change a `subscribe` listener is told of:
|
|
313
|
+
*
|
|
314
|
+
* - `'set'`: `setTracks` replaced the whole set.
|
|
315
|
+
* - `'add'`, `'remove'`, `'reorder'`: one track was added, removed or moved.
|
|
316
|
+
* - `'update'`: one track changed (`updateTrack`, a clip added, removed,
|
|
317
|
+
* moved, trimmed or split).
|
|
318
|
+
* - `'restore'`: an undo, a redo or an abort changed the tracks (and maybe
|
|
319
|
+
* the mix); `'restoreMix'`: it changed the mix only.
|
|
320
|
+
* - `'load'`: audio arrived and loading clips became loaded clips.
|
|
321
|
+
* - `'mixer'`: one of the mixer setters changed a volume, mute, solo, pan
|
|
322
|
+
* or pan law.
|
|
323
|
+
* - `'recording'`: a take started or stopped recording onto a track.
|
|
324
|
+
* - `'recompute'`: every track was gone through again: clip positions after
|
|
325
|
+
* a tempo change, or clip ticks when an engine attached.
|
|
326
|
+
* - `'history'`: only what can be undone or redone changed.
|
|
327
|
+
*/
|
|
328
|
+
type ArrangementChangeType = 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' | 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history';
|
|
329
|
+
/** A clip the arrangement took out of the current tracks by itself (#859). */
|
|
330
|
+
interface ArrangementRemovedClip {
|
|
331
|
+
readonly trackId: string;
|
|
332
|
+
readonly clipId: string;
|
|
333
|
+
}
|
|
334
|
+
/** What a `subscribe` listener is told about a change. */
|
|
335
|
+
interface ArrangementChangeInfo {
|
|
336
|
+
readonly type: ArrangementChangeType;
|
|
337
|
+
/**
|
|
338
|
+
* The clips this change took out of the current tracks because nothing of
|
|
339
|
+
* their audio was left after their `offset` (#859): a clip still loading
|
|
340
|
+
* whose audio arrived (on a `'load'`), or one added when its audio was
|
|
341
|
+
* loaded already (on that `'add'`, `'update'` or `'set'`). They are gone
|
|
342
|
+
* from every state, not as an undo step. Absent when there are none; a
|
|
343
|
+
* clip the app removes is never listed.
|
|
344
|
+
*/
|
|
345
|
+
readonly removedClips?: readonly ArrangementRemovedClip[];
|
|
346
|
+
}
|
|
247
347
|
/**
|
|
248
348
|
* The owner of the tracks, of the mix and of the undo history. Everything
|
|
249
349
|
* else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
|
|
250
|
-
* calling its methods.
|
|
350
|
+
* calling its methods. An `EditorEngine` built on it plays it.
|
|
251
351
|
*
|
|
252
352
|
* Nothing it returns is a copy: never write to a tracks array, a track, a
|
|
253
353
|
* clip or the mixer Map. Outside production builds the tracks are frozen.
|
|
@@ -260,20 +360,26 @@ interface Arrangement {
|
|
|
260
360
|
*/
|
|
261
361
|
getTracks(): readonly ArrangementTrack[];
|
|
262
362
|
/**
|
|
263
|
-
* The current volume, mute, solo and pan by track id
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
363
|
+
* The current volume, mute, solo and pan by track id (the stored mute: the
|
|
364
|
+
* mute of the track a take is recording onto is not forced here). The same
|
|
365
|
+
* Map until a value changes, a track with a new id enters, entries of
|
|
366
|
+
* tracks that are gone are dropped, or an undo, a redo or an abort brings
|
|
367
|
+
* back another state's Map. `mixerVersion` counts the value changes of
|
|
368
|
+
* current tracks, and also the start or end of a take's mute on a current
|
|
369
|
+
* track, which leaves this Map as it is; an entry seeded, carried or
|
|
370
|
+
* dropped with its track is not counted. A track's own mixer fields in
|
|
371
|
+
* `getTracks()` are the values it entered with; the current ones are here.
|
|
268
372
|
*/
|
|
269
373
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
270
374
|
/**
|
|
271
375
|
* Be told after every change (tracks, mix or history), once per change, in
|
|
272
|
-
* the order the changes were made
|
|
273
|
-
*
|
|
274
|
-
*
|
|
376
|
+
* the order the changes were made, with the kind of change it was and the
|
|
377
|
+
* clips it took out by itself (`removedClips`). Read what changed from the
|
|
378
|
+
* arrangement itself. Returns a function that stops
|
|
379
|
+
* it. A listener that throws is reported with `console.warn` and does not
|
|
380
|
+
* fail the change.
|
|
275
381
|
*/
|
|
276
|
-
subscribe(listener: () => void): () => void;
|
|
382
|
+
subscribe(listener: (change: ArrangementChangeInfo) => void): () => void;
|
|
277
383
|
/** Counts changes to the tracks. */
|
|
278
384
|
readonly tracksVersion: number;
|
|
279
385
|
/** Counts changes to the mix. */
|
|
@@ -283,8 +389,14 @@ interface Arrangement {
|
|
|
283
389
|
* transaction. An id that is in the tracks being replaced keeps its mix.
|
|
284
390
|
*/
|
|
285
391
|
setTracks(tracks: readonly ArrangementTrack[]): void;
|
|
286
|
-
|
|
392
|
+
/** Add a track: an undo step. Throws for an `index` that is not a finite number. */
|
|
393
|
+
addTrack(track: ArrangementTrack, options?: AddTrackOptions): void;
|
|
287
394
|
removeTrack(trackId: string, options?: RemoveTrackOptions): void;
|
|
395
|
+
/**
|
|
396
|
+
* Remove a clip from a track: an undo step. With `undoable: false` there is
|
|
397
|
+
* no step, and the clip is also taken out of every undo and redo state.
|
|
398
|
+
*/
|
|
399
|
+
removeClip(trackId: string, clipId: string, options?: RemoveClipOptions): void;
|
|
288
400
|
/**
|
|
289
401
|
* Replace a track, with a track or with a function of the current one.
|
|
290
402
|
* Changes nothing for an id no track has (a track object is still checked
|
|
@@ -301,10 +413,33 @@ interface Arrangement {
|
|
|
301
413
|
splitClip(trackId: string, clipId: string, atSample: number): void;
|
|
302
414
|
getClipBounds(trackId: string, clipId: string): ClipBounds | null;
|
|
303
415
|
constrainTrimDelta(trackId: string, clipId: string, boundary: 'left' | 'right', deltaSamples: number): number;
|
|
304
|
-
setTrackVolume(trackId: string, volume: number): void;
|
|
305
|
-
setTrackMute(trackId: string, muted: boolean): void;
|
|
306
|
-
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
307
|
-
setTrackPan(trackId: string, pan: number): void;
|
|
416
|
+
setTrackVolume(trackId: string, volume: number, options?: MixerChangeOptions): void;
|
|
417
|
+
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
418
|
+
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
419
|
+
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
420
|
+
/**
|
|
421
|
+
* Set a track's pan law (#684): `'mono'` or `'stereo'`. Any other value,
|
|
422
|
+
* `'auto'` included, throws a `TypeError`. A mixer value like the four
|
|
423
|
+
* above: `'auto'` until the track's first decoded audio decides it, after
|
|
424
|
+
* which the track's clips do not change it. A MIDI track has none to set.
|
|
425
|
+
*/
|
|
426
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
427
|
+
/**
|
|
428
|
+
* The ids of the tracks a take is recording onto. The same Set until one
|
|
429
|
+
* is added or removed; never write to it.
|
|
430
|
+
*/
|
|
431
|
+
readonly recordingTrackIds: ReadonlySet<string>;
|
|
432
|
+
/**
|
|
433
|
+
* Mark a track as the one a take is recording onto, or clear it when the
|
|
434
|
+
* take ends. Such a track plays muted: the engine's `getState().tracks`
|
|
435
|
+
* and its adapter have it muted, while its mute in `getMixer()` stays as
|
|
436
|
+
* it is and comes back when the take ends. This is not an undo step, and
|
|
437
|
+
* undo, redo, an abort, `setTracks` and `clearHistory` do not change which
|
|
438
|
+
* tracks are recording. An id that is not in the current tracks is
|
|
439
|
+
* recorded too, and mutes nothing until a track of that id enters. The
|
|
440
|
+
* same value changes nothing.
|
|
441
|
+
*/
|
|
442
|
+
setTrackRecording(trackId: string, recording: boolean): void;
|
|
308
443
|
readonly canUndo: boolean;
|
|
309
444
|
readonly canRedo: boolean;
|
|
310
445
|
/** With a transaction open: aborts it first. */
|
|
@@ -315,7 +450,7 @@ interface Arrangement {
|
|
|
315
450
|
/** Changes made until `commitTransaction` are one undo step. */
|
|
316
451
|
beginTransaction(): void;
|
|
317
452
|
commitTransaction(): void;
|
|
318
|
-
/** Put the tracks back as they were when the transaction began. */
|
|
453
|
+
/** Put the tracks and the mix back as they were when the transaction began. */
|
|
319
454
|
abortTransaction(): void;
|
|
320
455
|
/**
|
|
321
456
|
* Where each source the clips name is: pending, loaded or failed (also a
|
|
@@ -359,15 +494,29 @@ interface CreateArrangementOptions {
|
|
|
359
494
|
*
|
|
360
495
|
* The keys carry a version. An engine that finds the time-base key treats
|
|
361
496
|
* the object as an arrangement of this version and uses it BY NAME: the
|
|
362
|
-
* whole public `Arrangement` interface (every track, clip, mixer
|
|
363
|
-
* method it delegates to, `getTracks`, `getMixer`,
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* and `
|
|
367
|
-
*
|
|
497
|
+
* whole public `Arrangement` interface (every track, clip, mixer, recording
|
|
498
|
+
* and history method it delegates to, `getTracks`, `getMixer`,
|
|
499
|
+
* `recordingTrackIds`,
|
|
500
|
+
* the two version counters) and the internal `onChange(listener)` (with the
|
|
501
|
+
* `ArrangementChange` and `ArrangementVersions` shapes of this version),
|
|
502
|
+
* `recomputeStartSamples()` and `undoLimit`. A change to any of that needs a
|
|
503
|
+
* new key, so that copies which do not agree refuse each other instead of
|
|
504
|
+
* misreading each other.
|
|
505
|
+
*
|
|
506
|
+
* v2 (#843): the mixer setters take options and are undo steps, the history
|
|
507
|
+
* holds the mix (`'restoreMix'`), and the arrangement has the take's mute
|
|
508
|
+
* (`setTrackRecording`, `recordingTrackIds`, `'recording'`).
|
|
509
|
+
*
|
|
510
|
+
* v3 (#848): `addTrack(track, { index })` puts the track at a place in the order.
|
|
511
|
+
*
|
|
512
|
+
* Not a new key (#826): `subscribe` listeners are called with `{ type }`. The
|
|
513
|
+
* engine does not call `subscribe`, and a listener that takes no argument
|
|
514
|
+
* works with either copy.
|
|
368
515
|
*/
|
|
369
516
|
|
|
370
517
|
type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
518
|
+
/** True for an arrangement made by `createArrangement()`, of this copy of the package or another. */
|
|
519
|
+
declare function isArrangement(value: unknown): boolean;
|
|
371
520
|
/**
|
|
372
521
|
* Give an arrangement the audio context its sources are decoded with.
|
|
373
522
|
* Nothing is fetched before; the sources its clips name are pending
|
|
@@ -378,21 +527,46 @@ type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
|
378
527
|
* flight are aborted and start again at the next attach; what is loaded
|
|
379
528
|
* stays. One context at a time: a second attach warns and replaces the first.
|
|
380
529
|
*
|
|
381
|
-
*
|
|
530
|
+
* An `EditorEngine` with an adapter does this itself with the adapter's
|
|
382
531
|
* context (see its `attachDecodeContext` option).
|
|
383
532
|
*/
|
|
384
533
|
declare function attachDecodeContext(arrangement: Arrangement, getContext: GetDecodeContext): () => void;
|
|
385
534
|
|
|
535
|
+
/**
|
|
536
|
+
* Checks a track must pass before it enters an arrangement. Each throws
|
|
537
|
+
* before anything has changed (#756).
|
|
538
|
+
*/
|
|
539
|
+
|
|
540
|
+
/** Two clips of a track that overlap, by id, in time order. */
|
|
541
|
+
interface ClipOverlap {
|
|
542
|
+
first: string;
|
|
543
|
+
second: string;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* The first two clips of `clips` that overlap, or null (#859; the
|
|
547
|
+
* maintainer's rule of #748: clips on a track do not overlap). Not two loaded
|
|
548
|
+
* clips, not a loaded clip and a loading clip of known length, and no clip
|
|
549
|
+
* starts inside another or where a clip of unknown length starts. Spans are
|
|
550
|
+
* counted at the rate of the loaded clips, the rate edits use; with none, at
|
|
551
|
+
* any rate for clips of known length: both ends of a loading clip are rounded
|
|
552
|
+
* from their own time, so they do not overlap in samples when they do not in
|
|
553
|
+
* seconds. Two starts of clips of unknown length less than one sample apart
|
|
554
|
+
* can round to one sample at another rate (#859 review); at the rate the
|
|
555
|
+
* audio decodes at, the arrival is cut or refused. The rule the
|
|
556
|
+
* arrangement refuses a track by, for a host that refuses one clip instead.
|
|
557
|
+
*/
|
|
558
|
+
declare function findClipOverlap(clips: readonly (AudioClip | LoadingClip)[]): ClipOverlap | null;
|
|
559
|
+
|
|
386
560
|
/**
|
|
387
561
|
* Make an arrangement: the owner of the tracks, the mix and the undo
|
|
388
|
-
* history. It needs no engine; give it to `new
|
|
562
|
+
* history. It needs no engine; give it to `new EditorEngine({ arrangement })`
|
|
389
563
|
* to play it, and to the next engine when that one is disposed.
|
|
390
564
|
*/
|
|
391
565
|
declare function createArrangement(options?: CreateArrangementOptions): Arrangement;
|
|
392
566
|
|
|
393
567
|
/**
|
|
394
568
|
* Interface for pluggable audio playback adapters.
|
|
395
|
-
* Implement this to connect
|
|
569
|
+
* Implement this to connect EditorEngine to any audio backend
|
|
396
570
|
* (Tone.js, openDAW, HTMLAudioElement, etc.)
|
|
397
571
|
*/
|
|
398
572
|
interface PlayoutAdapter {
|
|
@@ -401,14 +575,18 @@ interface PlayoutAdapter {
|
|
|
401
575
|
/** Set the adapter's tick resolution. Optional — adapters with fixed PPQN ignore this. */
|
|
402
576
|
setPpqn?(ppqn: number): void;
|
|
403
577
|
init(): Promise<void>;
|
|
404
|
-
/**
|
|
405
|
-
|
|
578
|
+
/**
|
|
579
|
+
* Copies of the engine's tracks without their view fields (core's
|
|
580
|
+
* `TRACK_VIEW_FIELDS`), sharing its clips: read them, never write to them.
|
|
581
|
+
* A change of view fields alone causes no adapter call.
|
|
582
|
+
*/
|
|
583
|
+
setTracks(tracks: readonly PlayoutTrack[]): void;
|
|
406
584
|
/** Incrementally add a single track without rebuilding the entire playout. */
|
|
407
|
-
addTrack?(track:
|
|
585
|
+
addTrack?(track: PlayoutTrack): void;
|
|
408
586
|
/** Incrementally remove a single track without rebuilding the entire playout. */
|
|
409
587
|
removeTrack?(trackId: string): void;
|
|
410
588
|
/** Update a single track's clips (removes old, adds new). */
|
|
411
|
-
updateTrack?(trackId: string, track:
|
|
589
|
+
updateTrack?(trackId: string, track: PlayoutTrack): void;
|
|
412
590
|
play(startTime: number, endTime?: number): void;
|
|
413
591
|
pause(): void;
|
|
414
592
|
stop(): void;
|
|
@@ -425,6 +603,13 @@ interface PlayoutAdapter {
|
|
|
425
603
|
setTrackMute(trackId: string, muted: boolean): void;
|
|
426
604
|
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
427
605
|
setTrackPan(trackId: string, pan: number): void;
|
|
606
|
+
/**
|
|
607
|
+
* A track's pan law changed (#684). `'auto'` means "from the track's
|
|
608
|
+
* clips" (core's `trackPanLaw`); it is sent when an undo returns a track
|
|
609
|
+
* without audio to it. Optional: an adapter without it is sent the track
|
|
610
|
+
* again (`updateTrack`, else `setTracks`), with the law in `track.panLaw`.
|
|
611
|
+
*/
|
|
612
|
+
setTrackPanLaw?(trackId: string, panLaw: PanLaw): void;
|
|
428
613
|
setLoop(enabled: boolean, start: number, end: number): void;
|
|
429
614
|
/** Set tempo at a tick position. A defaulted (no atTick) call sets the base
|
|
430
615
|
* tempo on a single-entry map; adapters MAY refuse it when their tempo map
|
|
@@ -460,7 +645,7 @@ interface PlayoutAdapter {
|
|
|
460
645
|
* what the listener actually hears. Tone.js Transport reports a position that's
|
|
461
646
|
* `lookAhead` ahead of audible (default 0.1s); native AudioContext-based adapters
|
|
462
647
|
* have no lookahead. Consumers visualizing playback position should use
|
|
463
|
-
* `
|
|
648
|
+
* `EditorEngine.getAudibleTime()`, which applies this (plus
|
|
464
649
|
* `audioContext.outputLatency`) only while playing. Returns 0 or undefined when
|
|
465
650
|
* there's no lookahead. */
|
|
466
651
|
readonly lookAhead?: number;
|
|
@@ -511,10 +696,20 @@ interface EngineState {
|
|
|
511
696
|
/** Whether redo is available. */
|
|
512
697
|
canRedo: boolean;
|
|
513
698
|
}
|
|
699
|
+
/** Options of `EditorEngine.dispose()`. */
|
|
700
|
+
interface EngineDisposeOptions {
|
|
701
|
+
/**
|
|
702
|
+
* Leave the adapter undisposed (#848), for a host that plays another
|
|
703
|
+
* arrangement on the same adapter next: playback is stopped, the engine
|
|
704
|
+
* lets go of its arrangement and of the adapter's `onPlaybackEnded`, and a
|
|
705
|
+
* new engine can be built with the adapter.
|
|
706
|
+
*/
|
|
707
|
+
keepAdapter?: boolean;
|
|
708
|
+
}
|
|
514
709
|
/**
|
|
515
|
-
* Configuration options for
|
|
710
|
+
* Configuration options for EditorEngine constructor.
|
|
516
711
|
*/
|
|
517
|
-
interface
|
|
712
|
+
interface EditorEngineOptions {
|
|
518
713
|
adapter?: PlayoutAdapter;
|
|
519
714
|
/**
|
|
520
715
|
* The arrangement to play, from `createArrangement()`. It outlives the
|
|
@@ -545,7 +740,7 @@ interface PlaylistEngineOptions {
|
|
|
545
740
|
ppqn?: number;
|
|
546
741
|
}
|
|
547
742
|
/**
|
|
548
|
-
* Events emitted by
|
|
743
|
+
* Events emitted by EditorEngine.
|
|
549
744
|
*/
|
|
550
745
|
interface EngineEvents {
|
|
551
746
|
statechange: (state: EngineState) => void;
|
|
@@ -555,7 +750,7 @@ interface EngineEvents {
|
|
|
555
750
|
}
|
|
556
751
|
|
|
557
752
|
/**
|
|
558
|
-
*
|
|
753
|
+
* EditorEngine — Stateful, framework-agnostic timeline engine.
|
|
559
754
|
*
|
|
560
755
|
* Composes an Arrangement (the tracks, the mix, the undo history and
|
|
561
756
|
* transactions) with an event emitter and optional PlayoutAdapter for audio
|
|
@@ -565,7 +760,7 @@ interface EngineEvents {
|
|
|
565
760
|
*/
|
|
566
761
|
|
|
567
762
|
type EventName = keyof EngineEvents;
|
|
568
|
-
declare class
|
|
763
|
+
declare class EditorEngine {
|
|
569
764
|
private _arrangement;
|
|
570
765
|
private _stopFollowingArrangement;
|
|
571
766
|
private _detachFromArrangement;
|
|
@@ -590,7 +785,7 @@ declare class PlaylistEngine {
|
|
|
590
785
|
private _disposed;
|
|
591
786
|
private _listeners;
|
|
592
787
|
readonly undoLimit: number;
|
|
593
|
-
constructor(options?:
|
|
788
|
+
constructor(options?: EditorEngineOptions);
|
|
594
789
|
get canUndo(): boolean;
|
|
595
790
|
get canRedo(): boolean;
|
|
596
791
|
undo(): void;
|
|
@@ -601,7 +796,7 @@ declare class PlaylistEngine {
|
|
|
601
796
|
abortTransaction(): void;
|
|
602
797
|
getState(): EngineState;
|
|
603
798
|
setTracks(tracks: readonly ClipTrack[]): void;
|
|
604
|
-
addTrack(track: ClipTrack): void;
|
|
799
|
+
addTrack(track: ClipTrack, options?: AddTrackOptions): void;
|
|
605
800
|
removeTrack(trackId: string): void;
|
|
606
801
|
/**
|
|
607
802
|
* Move a track to a new position in the track order. Purely organizational —
|
|
@@ -664,16 +859,40 @@ declare class PlaylistEngine {
|
|
|
664
859
|
setSelection(start: number, end: number): void;
|
|
665
860
|
setLoopRegion(start: number, end: number): void;
|
|
666
861
|
setLoopEnabled(enabled: boolean): void;
|
|
667
|
-
setTrackVolume(trackId: string, volume: number): void;
|
|
668
|
-
setTrackMute(trackId: string, muted: boolean): void;
|
|
669
|
-
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
670
|
-
setTrackPan(trackId: string, pan: number): void;
|
|
862
|
+
setTrackVolume(trackId: string, volume: number, options?: MixerChangeOptions): void;
|
|
863
|
+
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
864
|
+
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
865
|
+
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
866
|
+
/**
|
|
867
|
+
* Set a track's pan law (#684): the arrangement's `setTrackPanLaw`.
|
|
868
|
+
* Unlike the four setters above, nothing is sent to the adapter when the
|
|
869
|
+
* arrangement changed nothing (a track it does not hold, the law the
|
|
870
|
+
* track already has): for an adapter without `setTrackPanLaw` the call
|
|
871
|
+
* would be a whole-track `updateTrack`.
|
|
872
|
+
*/
|
|
873
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
874
|
+
/**
|
|
875
|
+
* Mark a track as the one a take is recording onto, or clear it when the
|
|
876
|
+
* take ends: the arrangement's `setTrackRecording`. That track plays muted
|
|
877
|
+
* (here and in the adapter) while its mute in the mix stays as it is; the
|
|
878
|
+
* take's mute is not an undo step. The arrangement's `'recording'`
|
|
879
|
+
* announcement brings the adapter in step, so there is no adapter call of
|
|
880
|
+
* its own here; a disposed engine changes the arrangement only.
|
|
881
|
+
*/
|
|
882
|
+
setTrackRecording(trackId: string, recording: boolean): void;
|
|
883
|
+
/**
|
|
884
|
+
* The tracks a take is recording onto, read from the arrangement (the
|
|
885
|
+
* owner; no copy). The same set object until it changes; never write to
|
|
886
|
+
* it, use `setTrackRecording`. Such a track plays muted, so a UI can
|
|
887
|
+
* disable its mute control while the id is in the set.
|
|
888
|
+
*/
|
|
889
|
+
get recordingTrackIds(): ReadonlySet<string>;
|
|
671
890
|
zoomIn(): void;
|
|
672
891
|
zoomOut(): void;
|
|
673
892
|
setZoomLevel(samplesPerPixel: number): void;
|
|
674
893
|
on<K extends EventName>(event: K, listener: EngineEvents[K]): void;
|
|
675
894
|
off<K extends EventName>(event: K, listener: EngineEvents[K]): void;
|
|
676
|
-
dispose(): void;
|
|
895
|
+
dispose(options?: EngineDisposeOptions): void;
|
|
677
896
|
/** Runs a mixer setter on the arrangement. True when a value changed. */
|
|
678
897
|
private _mixerChanged;
|
|
679
898
|
/**
|
|
@@ -707,4 +926,4 @@ declare class PlaylistEngine {
|
|
|
707
926
|
private _emitStateChange;
|
|
708
927
|
}
|
|
709
928
|
|
|
710
|
-
export { type Arrangement, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type CreateArrangementOptions, type EngineEvents, type EngineState, type LoadSource,
|
|
929
|
+
export { type AddTrackOptions, type Arrangement, type ArrangementChangeInfo, type ArrangementChangeType, type ArrangementRemovedClip, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type ClipOverlap, type ClipSpan, type CreateArrangementOptions, EditorEngine, type EditorEngineOptions, type EngineDisposeOptions, type EngineEvents, type EngineState, type LoadSource, type MixerChangeOptions, type PlayoutAdapter, type RemoveClipOptions, type RemoveTrackOptions, type TrackMixerValues, attachDecodeContext, calculateDuration, calculateSplitPoint, calculateViewportBounds, calculateZoomScrollPosition, canSplitAt, clampSeekPosition, constrainBoundaryTrim, constrainClipDrag, createArrangement, defaultLoadSource, findClipOverlap, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip, trackClipSpans };
|