@waveform-playlist/engine 14.0.0-next.5 → 14.0.0-next.7
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 +11 -3
- package/dist/index.d.mts +64 -8
- package/dist/index.d.ts +64 -8
- package/dist/index.js +149 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -117,7 +117,7 @@ The engine's track, clip, mixer, recording and history methods call the arrangem
|
|
|
117
117
|
|
|
118
118
|
### Mixer moves are undo steps
|
|
119
119
|
|
|
120
|
-
`setTrackVolume`, `setTrackMute`, `setTrackSolo` and `
|
|
120
|
+
`setTrackVolume`, `setTrackMute`, `setTrackSolo`, `setTrackPan` and `setTrackPanLaw` (on the arrangement and on the engine) are undo steps: an undo puts the fader back. Their last argument, `options?: MixerChangeOptions`, says how a change goes into the history:
|
|
121
121
|
|
|
122
122
|
- nothing: each call is a step of its own;
|
|
123
123
|
- `{ gesture: id }`: calls with the same id, one after another, are one step (a fader drag from press to release);
|
|
@@ -238,7 +238,8 @@ Rules that hold for the engine and the arrangement alike:
|
|
|
238
238
|
|
|
239
239
|
- **Nothing handed out is a copy.** `arrangement.getTracks()` and `engine.getState().tracks` are shared with the undo history. The tracks an adapter receives are copies without the view fields (core's `TRACK_VIEW_FIELDS`, typed `PlayoutTrack`) that share these clips, frozen the same way. Never write to the array, a track or a clip: copy first (`{ ...track, clips: [...] }`) and pass the copy to `updateTrack`. `arrangement.updateTrack`, given a track object or a function, keeps each clip object the track already holds and copies every other clip, so the clips you did not replace are the same objects afterwards. Outside production builds (`process.env.NODE_ENV` is not `'production'`; a page that loads the module with no bundler, and so has no `process`, counts as production) the tracks array, each track, its `clips` array and each clip are frozen, so a write throws in strict code (every module is strict). What a clip refers to (its `AudioBuffer`, peaks, fades, notes) is not frozen. Tracks are copied on their way in, so the objects you pass stay yours.
|
|
240
240
|
- **A change replaces only what changed.** The tracks array and the changed track and clip objects are new; every other track is the same object as before, so a comparison by identity finds what changed. The exception is `setTracks`, which copies every track it is given: after it no track is the object it was.
|
|
241
|
-
- **The mix is separate from the tracks.** A track's own `volume`, `muted`, `soloed` and `
|
|
241
|
+
- **The mix is separate from the tracks.** A track's own `volume`, `muted`, `soloed`, `pan` and `panLaw` fields are the values it enters with. They seed its mixer entry when its id has none. `setTracks` keeps the mix of an id that is in the tracks it replaces, and `updateTrack` keeps the track's mix (also when it gives the track a new id); in those cases the fields are not read. `addTrack` seeds the entry from the new track's fields, also for the id of a track removed earlier. `getMixer()` holds the entries of the current tracks; each undo and redo state keeps its own. Change the mix with `setTrackVolume`, `setTrackMute`, `setTrackSolo`, `setTrackPan` and `setTrackPanLaw`, which act on a track that is in the current tracks. `engine.getState().tracks` and the tracks an adapter receives carry the current mix in those fields; `arrangement.getTracks()` does not (read `getMixer()`).
|
|
242
|
+
- **The pan law is a mixer value that the first audio decides.** `getMixer().get(id).panLaw` is `'auto'`, `'mono'` or `'stereo'`. A track enters with its own `panLaw` field when that is `'mono'` or `'stereo'`, else with the law of the decoded audio it holds (`'stereo'` if a clip's buffer has two or more channels), else with `'auto'`. A track that is `'auto'` gets the law of the first decoded audio it holds, in the same change that brings the audio: the same undo step for a clip added decoded, no step for a clip that finishes loading (every state the arrangement can return to gets the law of its own tracks; an undo or redo step that this makes equal to the state next to it is dropped, so a finished load can turn `canUndo` or `canRedo` false). From then on the clips do not change it: not a clip of the other kind, not the removal of every clip, not `setTracks` with the same id. The law belongs to the id, like the rest of the mix: an app that reuses a track id for other material gets the law the id had (use a new id, pass through `setTracks([])`, which drops every entry, or set the law). `setTrackPanLaw(id, 'mono' | 'stereo')` changes it and may be called before the track has audio; any other value, `'auto'` included, throws a `TypeError`. A MIDI track stays `'auto'` (it plays with the mono law), and the setter does nothing for it. The law converts no audio: a stereo clip on a `'mono'` track stays stereo. `engine.getState().tracks` and the tracks an adapter receives carry the law in `panLaw` (a track that carries no field and is `'auto'` is sent without one). A change of the law alone is one call of the adapter's optional `setTrackPanLaw`, also when an undo returns a track without audio to `'auto'`; an adapter without the method is sent the track again. Unlike the other four engine setters, `engine.setTrackPanLaw` makes no adapter call when the arrangement changed nothing (a track it does not hold, the law the track already has).
|
|
242
243
|
- **Undo, redo and an aborted transaction restore the tracks, the clips and the mix** of the state they return to. Undoing a `removeTrack` brings the track back with the mix it had, and undoing an `updateTrack` that gave a track a new id brings back the old id with the mix it had then.
|
|
243
244
|
- **Ids are unique.** `setTracks`, `addTrack` and `updateTrack` throw an `Error` for a duplicate track id, for two clips with one id on the same track, and for a track whose clips do not match its `kind` (a loading clip is an audio clip), before anything changes.
|
|
244
245
|
- **Without an engine** clips are given no `startTick`, and a clip that came with one loses it when it is moved, trimmed on the left or split. Every clip without a tick, in the current tracks and in every undo and redo state, gets one from its `startSample` when an engine attaches. The shortest a clip may be is 0.1 s at the clip's own sample rate.
|
|
@@ -286,6 +287,7 @@ class PlaylistEngine {
|
|
|
286
287
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
287
288
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
288
289
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
290
|
+
setTrackPanLaw(trackId: string, panLaw: 'mono' | 'stereo', options?: MixerChangeOptions): void;
|
|
289
291
|
setTrackRecording(trackId: string, recording: boolean): void; // plays muted during the take; not an undo step
|
|
290
292
|
readonly recordingTrackIds: ReadonlySet<string>; // the arrangement's set (the same object), read-only
|
|
291
293
|
zoomIn(): void;
|
|
@@ -327,7 +329,9 @@ interface Arrangement {
|
|
|
327
329
|
// read
|
|
328
330
|
getTracks(): readonly ArrangementTrack[];
|
|
329
331
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
330
|
-
|
|
332
|
+
// Called with the kind of change: 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' |
|
|
333
|
+
// 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history'
|
|
334
|
+
subscribe(listener: (change: { readonly type: ArrangementChangeType }) => void): () => void;
|
|
331
335
|
readonly tracksVersion: number;
|
|
332
336
|
readonly mixerVersion: number;
|
|
333
337
|
|
|
@@ -354,6 +358,7 @@ interface Arrangement {
|
|
|
354
358
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
355
359
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
356
360
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
361
|
+
setTrackPanLaw(trackId: string, panLaw: 'mono' | 'stereo', options?: MixerChangeOptions): void;
|
|
357
362
|
|
|
358
363
|
// the take's mute: the tracks a take is recording onto (outside the history)
|
|
359
364
|
readonly recordingTrackIds: ReadonlySet<string>;
|
|
@@ -439,6 +444,9 @@ interface PlayoutAdapter {
|
|
|
439
444
|
setTrackMute(trackId: string, muted: boolean): void;
|
|
440
445
|
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
441
446
|
setTrackPan(trackId: string, pan: number): void;
|
|
447
|
+
// Optional. 'auto': from the track's clips (core's trackPanLaw). Without it the engine sends
|
|
448
|
+
// the track again (updateTrack, else setTracks), with the law in track.panLaw.
|
|
449
|
+
setTrackPanLaw?(trackId: string, panLaw: PanLaw): void;
|
|
442
450
|
setLoop(enabled: boolean, start: number, end: number): void;
|
|
443
451
|
|
|
444
452
|
setTempo?(bpm: number, atTick?: number): boolean | void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
1
|
+
import { AudioClip, ClipTrack, ClipSource, PanLaw, ArrangementTrack, DecidedPanLaw, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Clip Operations
|
|
@@ -209,8 +209,8 @@ interface ArrangementSourcesValue {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
* The mixer part of an arrangement: volume, mute, solo and pan by
|
|
213
|
-
* as pure functions over an immutable Map.
|
|
212
|
+
* The mixer part of an arrangement: volume, mute, solo, pan and pan law by
|
|
213
|
+
* track id, as pure functions over an immutable Map.
|
|
214
214
|
*
|
|
215
215
|
* The values live here and not on the track objects, so a fader move
|
|
216
216
|
* replaces no track. The current Map holds an entry for each current track;
|
|
@@ -218,6 +218,11 @@ interface ArrangementSourcesValue {
|
|
|
218
218
|
* `volume` / `muted` / `soloed` / `pan` fields are the values it ENTERED
|
|
219
219
|
* with; they seed its entry when its id has none, and are not read while it
|
|
220
220
|
* has one.
|
|
221
|
+
*
|
|
222
|
+
* The pan law (#684) is `'auto'` until the track holds decoded audio; that
|
|
223
|
+
* audio decides it (`decidePanLaws`), and from then on the track's clips do
|
|
224
|
+
* not change it. `'auto'` is only ever the law of a track with no decoded
|
|
225
|
+
* audio, or of a MIDI track (which always plays with the mono law).
|
|
221
226
|
*/
|
|
222
227
|
|
|
223
228
|
interface TrackMixerValues {
|
|
@@ -225,6 +230,8 @@ interface TrackMixerValues {
|
|
|
225
230
|
muted: boolean;
|
|
226
231
|
soloed: boolean;
|
|
227
232
|
pan: number;
|
|
233
|
+
/** `'auto'` until the track's first decoded audio decides it (#684). */
|
|
234
|
+
panLaw: PanLaw;
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/**
|
|
@@ -270,6 +277,28 @@ interface MixerChangeOptions {
|
|
|
270
277
|
/** Not an undo step: the value is written into every saved state as well. */
|
|
271
278
|
undoable?: false;
|
|
272
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The kind of change a `subscribe` listener is told of:
|
|
282
|
+
*
|
|
283
|
+
* - `'set'`: `setTracks` replaced the whole set.
|
|
284
|
+
* - `'add'`, `'remove'`, `'reorder'`: one track was added, removed or moved.
|
|
285
|
+
* - `'update'`: one track changed (`updateTrack`, a clip added, removed,
|
|
286
|
+
* moved, trimmed or split).
|
|
287
|
+
* - `'restore'`: an undo, a redo or an abort changed the tracks (and maybe
|
|
288
|
+
* the mix); `'restoreMix'`: it changed the mix only.
|
|
289
|
+
* - `'load'`: audio arrived and loading clips became loaded clips.
|
|
290
|
+
* - `'mixer'`: one of the mixer setters changed a volume, mute, solo, pan
|
|
291
|
+
* or pan law.
|
|
292
|
+
* - `'recording'`: a take started or stopped recording onto a track.
|
|
293
|
+
* - `'recompute'`: every track was gone through again: clip positions after
|
|
294
|
+
* a tempo change, or clip ticks when an engine attached.
|
|
295
|
+
* - `'history'`: only what can be undone or redone changed.
|
|
296
|
+
*/
|
|
297
|
+
type ArrangementChangeType = 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' | 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history';
|
|
298
|
+
/** What a `subscribe` listener is told about a change. */
|
|
299
|
+
interface ArrangementChangeInfo {
|
|
300
|
+
readonly type: ArrangementChangeType;
|
|
301
|
+
}
|
|
273
302
|
/**
|
|
274
303
|
* The owner of the tracks, of the mix and of the undo history. Everything
|
|
275
304
|
* else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
|
|
@@ -299,11 +328,12 @@ interface Arrangement {
|
|
|
299
328
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
300
329
|
/**
|
|
301
330
|
* Be told after every change (tracks, mix or history), once per change, in
|
|
302
|
-
* the order the changes were made
|
|
303
|
-
*
|
|
304
|
-
*
|
|
331
|
+
* the order the changes were made, with the kind of change it was. Read
|
|
332
|
+
* what changed from the arrangement itself. Returns a function that stops
|
|
333
|
+
* it. A listener that throws is reported with `console.warn` and does not
|
|
334
|
+
* fail the change.
|
|
305
335
|
*/
|
|
306
|
-
subscribe(listener: () => void): () => void;
|
|
336
|
+
subscribe(listener: (change: ArrangementChangeInfo) => void): () => void;
|
|
307
337
|
/** Counts changes to the tracks. */
|
|
308
338
|
readonly tracksVersion: number;
|
|
309
339
|
/** Counts changes to the mix. */
|
|
@@ -341,6 +371,13 @@ interface Arrangement {
|
|
|
341
371
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
342
372
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
343
373
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
374
|
+
/**
|
|
375
|
+
* Set a track's pan law (#684): `'mono'` or `'stereo'`. Any other value,
|
|
376
|
+
* `'auto'` included, throws a `TypeError`. A mixer value like the four
|
|
377
|
+
* above: `'auto'` until the track's first decoded audio decides it, after
|
|
378
|
+
* which the track's clips do not change it. A MIDI track has none to set.
|
|
379
|
+
*/
|
|
380
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
344
381
|
/**
|
|
345
382
|
* The ids of the tracks a take is recording onto. The same Set until one
|
|
346
383
|
* is added or removed; never write to it.
|
|
@@ -425,6 +462,10 @@ interface CreateArrangementOptions {
|
|
|
425
462
|
* (`setTrackRecording`, `recordingTrackIds`, `'recording'`).
|
|
426
463
|
*
|
|
427
464
|
* v3 (#848): `addTrack(track, { index })` puts the track at a place in the order.
|
|
465
|
+
*
|
|
466
|
+
* Not a new key (#826): `subscribe` listeners are called with `{ type }`. The
|
|
467
|
+
* engine does not call `subscribe`, and a listener that takes no argument
|
|
468
|
+
* works with either copy.
|
|
428
469
|
*/
|
|
429
470
|
|
|
430
471
|
type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
@@ -491,6 +532,13 @@ interface PlayoutAdapter {
|
|
|
491
532
|
setTrackMute(trackId: string, muted: boolean): void;
|
|
492
533
|
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
493
534
|
setTrackPan(trackId: string, pan: number): void;
|
|
535
|
+
/**
|
|
536
|
+
* A track's pan law changed (#684). `'auto'` means "from the track's
|
|
537
|
+
* clips" (core's `trackPanLaw`); it is sent when an undo returns a track
|
|
538
|
+
* without audio to it. Optional: an adapter without it is sent the track
|
|
539
|
+
* again (`updateTrack`, else `setTracks`), with the law in `track.panLaw`.
|
|
540
|
+
*/
|
|
541
|
+
setTrackPanLaw?(trackId: string, panLaw: PanLaw): void;
|
|
494
542
|
setLoop(enabled: boolean, start: number, end: number): void;
|
|
495
543
|
/** Set tempo at a tick position. A defaulted (no atTick) call sets the base
|
|
496
544
|
* tempo on a single-entry map; adapters MAY refuse it when their tempo map
|
|
@@ -744,6 +792,14 @@ declare class PlaylistEngine {
|
|
|
744
792
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
745
793
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
746
794
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
795
|
+
/**
|
|
796
|
+
* Set a track's pan law (#684): the arrangement's `setTrackPanLaw`.
|
|
797
|
+
* Unlike the four setters above, nothing is sent to the adapter when the
|
|
798
|
+
* arrangement changed nothing (a track it does not hold, the law the
|
|
799
|
+
* track already has): for an adapter without `setTrackPanLaw` the call
|
|
800
|
+
* would be a whole-track `updateTrack`.
|
|
801
|
+
*/
|
|
802
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
747
803
|
/**
|
|
748
804
|
* Mark a track as the one a take is recording onto, or clear it when the
|
|
749
805
|
* take ends: the arrangement's `setTrackRecording`. That track plays muted
|
|
@@ -799,4 +855,4 @@ declare class PlaylistEngine {
|
|
|
799
855
|
private _emitStateChange;
|
|
800
856
|
}
|
|
801
857
|
|
|
802
|
-
export { type AddTrackOptions, type Arrangement, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type CreateArrangementOptions, type EngineDisposeOptions, type EngineEvents, type EngineState, type LoadSource, type MixerChangeOptions, PlaylistEngine, type PlaylistEngineOptions, type PlayoutAdapter, type RemoveClipOptions, type RemoveTrackOptions, type TrackMixerValues, attachDecodeContext, calculateDuration, calculateSplitPoint, calculateViewportBounds, calculateZoomScrollPosition, canSplitAt, clampSeekPosition, constrainBoundaryTrim, constrainClipDrag, createArrangement, defaultLoadSource, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip };
|
|
858
|
+
export { type AddTrackOptions, type Arrangement, type ArrangementChangeInfo, type ArrangementChangeType, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type CreateArrangementOptions, type EngineDisposeOptions, type EngineEvents, type EngineState, type LoadSource, type MixerChangeOptions, PlaylistEngine, type PlaylistEngineOptions, type PlayoutAdapter, type RemoveClipOptions, type RemoveTrackOptions, type TrackMixerValues, attachDecodeContext, calculateDuration, calculateSplitPoint, calculateViewportBounds, calculateZoomScrollPosition, canSplitAt, clampSeekPosition, constrainBoundaryTrim, constrainClipDrag, createArrangement, defaultLoadSource, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
1
|
+
import { AudioClip, ClipTrack, ClipSource, PanLaw, ArrangementTrack, DecidedPanLaw, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Clip Operations
|
|
@@ -209,8 +209,8 @@ interface ArrangementSourcesValue {
|
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
/**
|
|
212
|
-
* The mixer part of an arrangement: volume, mute, solo and pan by
|
|
213
|
-
* as pure functions over an immutable Map.
|
|
212
|
+
* The mixer part of an arrangement: volume, mute, solo, pan and pan law by
|
|
213
|
+
* track id, as pure functions over an immutable Map.
|
|
214
214
|
*
|
|
215
215
|
* The values live here and not on the track objects, so a fader move
|
|
216
216
|
* replaces no track. The current Map holds an entry for each current track;
|
|
@@ -218,6 +218,11 @@ interface ArrangementSourcesValue {
|
|
|
218
218
|
* `volume` / `muted` / `soloed` / `pan` fields are the values it ENTERED
|
|
219
219
|
* with; they seed its entry when its id has none, and are not read while it
|
|
220
220
|
* has one.
|
|
221
|
+
*
|
|
222
|
+
* The pan law (#684) is `'auto'` until the track holds decoded audio; that
|
|
223
|
+
* audio decides it (`decidePanLaws`), and from then on the track's clips do
|
|
224
|
+
* not change it. `'auto'` is only ever the law of a track with no decoded
|
|
225
|
+
* audio, or of a MIDI track (which always plays with the mono law).
|
|
221
226
|
*/
|
|
222
227
|
|
|
223
228
|
interface TrackMixerValues {
|
|
@@ -225,6 +230,8 @@ interface TrackMixerValues {
|
|
|
225
230
|
muted: boolean;
|
|
226
231
|
soloed: boolean;
|
|
227
232
|
pan: number;
|
|
233
|
+
/** `'auto'` until the track's first decoded audio decides it (#684). */
|
|
234
|
+
panLaw: PanLaw;
|
|
228
235
|
}
|
|
229
236
|
|
|
230
237
|
/**
|
|
@@ -270,6 +277,28 @@ interface MixerChangeOptions {
|
|
|
270
277
|
/** Not an undo step: the value is written into every saved state as well. */
|
|
271
278
|
undoable?: false;
|
|
272
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* The kind of change a `subscribe` listener is told of:
|
|
282
|
+
*
|
|
283
|
+
* - `'set'`: `setTracks` replaced the whole set.
|
|
284
|
+
* - `'add'`, `'remove'`, `'reorder'`: one track was added, removed or moved.
|
|
285
|
+
* - `'update'`: one track changed (`updateTrack`, a clip added, removed,
|
|
286
|
+
* moved, trimmed or split).
|
|
287
|
+
* - `'restore'`: an undo, a redo or an abort changed the tracks (and maybe
|
|
288
|
+
* the mix); `'restoreMix'`: it changed the mix only.
|
|
289
|
+
* - `'load'`: audio arrived and loading clips became loaded clips.
|
|
290
|
+
* - `'mixer'`: one of the mixer setters changed a volume, mute, solo, pan
|
|
291
|
+
* or pan law.
|
|
292
|
+
* - `'recording'`: a take started or stopped recording onto a track.
|
|
293
|
+
* - `'recompute'`: every track was gone through again: clip positions after
|
|
294
|
+
* a tempo change, or clip ticks when an engine attached.
|
|
295
|
+
* - `'history'`: only what can be undone or redone changed.
|
|
296
|
+
*/
|
|
297
|
+
type ArrangementChangeType = 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' | 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history';
|
|
298
|
+
/** What a `subscribe` listener is told about a change. */
|
|
299
|
+
interface ArrangementChangeInfo {
|
|
300
|
+
readonly type: ArrangementChangeType;
|
|
301
|
+
}
|
|
273
302
|
/**
|
|
274
303
|
* The owner of the tracks, of the mix and of the undo history. Everything
|
|
275
304
|
* else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
|
|
@@ -299,11 +328,12 @@ interface Arrangement {
|
|
|
299
328
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
300
329
|
/**
|
|
301
330
|
* Be told after every change (tracks, mix or history), once per change, in
|
|
302
|
-
* the order the changes were made
|
|
303
|
-
*
|
|
304
|
-
*
|
|
331
|
+
* the order the changes were made, with the kind of change it was. Read
|
|
332
|
+
* what changed from the arrangement itself. Returns a function that stops
|
|
333
|
+
* it. A listener that throws is reported with `console.warn` and does not
|
|
334
|
+
* fail the change.
|
|
305
335
|
*/
|
|
306
|
-
subscribe(listener: () => void): () => void;
|
|
336
|
+
subscribe(listener: (change: ArrangementChangeInfo) => void): () => void;
|
|
307
337
|
/** Counts changes to the tracks. */
|
|
308
338
|
readonly tracksVersion: number;
|
|
309
339
|
/** Counts changes to the mix. */
|
|
@@ -341,6 +371,13 @@ interface Arrangement {
|
|
|
341
371
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
342
372
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
343
373
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
374
|
+
/**
|
|
375
|
+
* Set a track's pan law (#684): `'mono'` or `'stereo'`. Any other value,
|
|
376
|
+
* `'auto'` included, throws a `TypeError`. A mixer value like the four
|
|
377
|
+
* above: `'auto'` until the track's first decoded audio decides it, after
|
|
378
|
+
* which the track's clips do not change it. A MIDI track has none to set.
|
|
379
|
+
*/
|
|
380
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
344
381
|
/**
|
|
345
382
|
* The ids of the tracks a take is recording onto. The same Set until one
|
|
346
383
|
* is added or removed; never write to it.
|
|
@@ -425,6 +462,10 @@ interface CreateArrangementOptions {
|
|
|
425
462
|
* (`setTrackRecording`, `recordingTrackIds`, `'recording'`).
|
|
426
463
|
*
|
|
427
464
|
* v3 (#848): `addTrack(track, { index })` puts the track at a place in the order.
|
|
465
|
+
*
|
|
466
|
+
* Not a new key (#826): `subscribe` listeners are called with `{ type }`. The
|
|
467
|
+
* engine does not call `subscribe`, and a listener that takes no argument
|
|
468
|
+
* works with either copy.
|
|
428
469
|
*/
|
|
429
470
|
|
|
430
471
|
type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
@@ -491,6 +532,13 @@ interface PlayoutAdapter {
|
|
|
491
532
|
setTrackMute(trackId: string, muted: boolean): void;
|
|
492
533
|
setTrackSolo(trackId: string, soloed: boolean): void;
|
|
493
534
|
setTrackPan(trackId: string, pan: number): void;
|
|
535
|
+
/**
|
|
536
|
+
* A track's pan law changed (#684). `'auto'` means "from the track's
|
|
537
|
+
* clips" (core's `trackPanLaw`); it is sent when an undo returns a track
|
|
538
|
+
* without audio to it. Optional: an adapter without it is sent the track
|
|
539
|
+
* again (`updateTrack`, else `setTracks`), with the law in `track.panLaw`.
|
|
540
|
+
*/
|
|
541
|
+
setTrackPanLaw?(trackId: string, panLaw: PanLaw): void;
|
|
494
542
|
setLoop(enabled: boolean, start: number, end: number): void;
|
|
495
543
|
/** Set tempo at a tick position. A defaulted (no atTick) call sets the base
|
|
496
544
|
* tempo on a single-entry map; adapters MAY refuse it when their tempo map
|
|
@@ -744,6 +792,14 @@ declare class PlaylistEngine {
|
|
|
744
792
|
setTrackMute(trackId: string, muted: boolean, options?: MixerChangeOptions): void;
|
|
745
793
|
setTrackSolo(trackId: string, soloed: boolean, options?: MixerChangeOptions): void;
|
|
746
794
|
setTrackPan(trackId: string, pan: number, options?: MixerChangeOptions): void;
|
|
795
|
+
/**
|
|
796
|
+
* Set a track's pan law (#684): the arrangement's `setTrackPanLaw`.
|
|
797
|
+
* Unlike the four setters above, nothing is sent to the adapter when the
|
|
798
|
+
* arrangement changed nothing (a track it does not hold, the law the
|
|
799
|
+
* track already has): for an adapter without `setTrackPanLaw` the call
|
|
800
|
+
* would be a whole-track `updateTrack`.
|
|
801
|
+
*/
|
|
802
|
+
setTrackPanLaw(trackId: string, panLaw: DecidedPanLaw, options?: MixerChangeOptions): void;
|
|
747
803
|
/**
|
|
748
804
|
* Mark a track as the one a take is recording onto, or clear it when the
|
|
749
805
|
* take ends: the arrangement's `setTrackRecording`. That track plays muted
|
|
@@ -799,4 +855,4 @@ declare class PlaylistEngine {
|
|
|
799
855
|
private _emitStateChange;
|
|
800
856
|
}
|
|
801
857
|
|
|
802
|
-
export { type AddTrackOptions, type Arrangement, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type CreateArrangementOptions, type EngineDisposeOptions, type EngineEvents, type EngineState, type LoadSource, type MixerChangeOptions, PlaylistEngine, type PlaylistEngineOptions, type PlayoutAdapter, type RemoveClipOptions, type RemoveTrackOptions, type TrackMixerValues, attachDecodeContext, calculateDuration, calculateSplitPoint, calculateViewportBounds, calculateZoomScrollPosition, canSplitAt, clampSeekPosition, constrainBoundaryTrim, constrainClipDrag, createArrangement, defaultLoadSource, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip };
|
|
858
|
+
export { type AddTrackOptions, type Arrangement, type ArrangementChangeInfo, type ArrangementChangeType, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, type CreateArrangementOptions, type EngineDisposeOptions, type EngineEvents, type EngineState, type LoadSource, type MixerChangeOptions, PlaylistEngine, type PlaylistEngineOptions, type PlayoutAdapter, type RemoveClipOptions, type RemoveTrackOptions, type TrackMixerValues, attachDecodeContext, calculateDuration, calculateSplitPoint, calculateViewportBounds, calculateZoomScrollPosition, canSplitAt, clampSeekPosition, constrainBoundaryTrim, constrainClipDrag, createArrangement, defaultLoadSource, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip };
|
package/dist/index.js
CHANGED
|
@@ -194,7 +194,7 @@ function clampSeekPosition(time, duration) {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
// src/arrangement/Arrangement.ts
|
|
197
|
-
var
|
|
197
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
198
198
|
|
|
199
199
|
// src/arrangement/attach.ts
|
|
200
200
|
var ARRANGEMENT_ATTACH_DECODE = /* @__PURE__ */ Symbol.for(
|
|
@@ -748,6 +748,7 @@ function sameValue(a, b) {
|
|
|
748
748
|
}
|
|
749
749
|
|
|
750
750
|
// src/arrangement/mixer.ts
|
|
751
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
751
752
|
var EMPTY_MIXER = /* @__PURE__ */ new Map();
|
|
752
753
|
var DEFAULT_VOLUME = 1;
|
|
753
754
|
var DEFAULT_PAN = 0;
|
|
@@ -756,9 +757,33 @@ function mixerValuesOf(track) {
|
|
|
756
757
|
volume: track.volume ?? DEFAULT_VOLUME,
|
|
757
758
|
muted: track.muted ?? false,
|
|
758
759
|
soloed: track.soloed ?? false,
|
|
759
|
-
pan: track.pan ?? DEFAULT_PAN
|
|
760
|
+
pan: track.pan ?? DEFAULT_PAN,
|
|
761
|
+
panLaw: enteringPanLaw(track)
|
|
760
762
|
};
|
|
761
763
|
}
|
|
764
|
+
function decidedByAudio(track) {
|
|
765
|
+
if ((0, import_core5.trackKind)(track) === "midi") return null;
|
|
766
|
+
return (0, import_core5.audioPanLaw)({
|
|
767
|
+
clips: track.clips.filter((clip) => !(0, import_core5.isLoadingClip)(clip))
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
function enteringPanLaw(track) {
|
|
771
|
+
if ((0, import_core5.trackKind)(track) === "midi") return import_core5.DEFAULT_PAN_LAW;
|
|
772
|
+
if ((0, import_core5.isDecidedPanLaw)(track.panLaw)) return track.panLaw;
|
|
773
|
+
return decidedByAudio(track) ?? import_core5.DEFAULT_PAN_LAW;
|
|
774
|
+
}
|
|
775
|
+
function decidePanLaws(mixer, tracks) {
|
|
776
|
+
let next = null;
|
|
777
|
+
for (const track of tracks) {
|
|
778
|
+
const entry = mixer.get(track.id);
|
|
779
|
+
if (!entry || entry.panLaw !== import_core5.DEFAULT_PAN_LAW) continue;
|
|
780
|
+
const panLaw = decidedByAudio(track);
|
|
781
|
+
if (!panLaw) continue;
|
|
782
|
+
if (!next) next = new Map(mixer);
|
|
783
|
+
next.set(track.id, { ...entry, panLaw });
|
|
784
|
+
}
|
|
785
|
+
return next ?? mixer;
|
|
786
|
+
}
|
|
762
787
|
function seedMixer(mixer, tracks) {
|
|
763
788
|
let next = null;
|
|
764
789
|
for (const track of tracks) {
|
|
@@ -795,7 +820,7 @@ function withoutEntry(mixer, trackId) {
|
|
|
795
820
|
return next;
|
|
796
821
|
}
|
|
797
822
|
function sameValues(a, b) {
|
|
798
|
-
return a.volume === b.volume && a.muted === b.muted && a.soloed === b.soloed && a.pan === b.pan;
|
|
823
|
+
return a.volume === b.volume && a.muted === b.muted && a.soloed === b.soloed && a.pan === b.pan && a.panLaw === b.panLaw;
|
|
799
824
|
}
|
|
800
825
|
function sameMixerValues(a, b) {
|
|
801
826
|
if (a === b) return true;
|
|
@@ -817,12 +842,14 @@ function mixerChanges(before, after) {
|
|
|
817
842
|
if (was.muted !== now.muted) values.muted = now.muted;
|
|
818
843
|
if (was.soloed !== now.soloed) values.soloed = now.soloed;
|
|
819
844
|
if (was.pan !== now.pan) values.pan = now.pan;
|
|
845
|
+
if (was.panLaw !== now.panLaw) values.panLaw = now.panLaw;
|
|
820
846
|
if (Object.keys(values).length > 0) changes.push({ trackId, values });
|
|
821
847
|
}
|
|
822
848
|
return changes;
|
|
823
849
|
}
|
|
824
850
|
function withMixerValues(track, values) {
|
|
825
|
-
if (!values || track.volume === values.volume && track.muted === values.muted && track.soloed === values.soloed && track.pan === values.pan
|
|
851
|
+
if (!values || track.volume === values.volume && track.muted === values.muted && track.soloed === values.soloed && track.pan === values.pan && // A track that carries no law is an 'auto' track: no copy for that alone.
|
|
852
|
+
(track.panLaw ?? import_core5.DEFAULT_PAN_LAW) === values.panLaw) {
|
|
826
853
|
return track;
|
|
827
854
|
}
|
|
828
855
|
return { ...track, ...values };
|
|
@@ -983,6 +1010,27 @@ function stateWithMixerValues(trackId, patch) {
|
|
|
983
1010
|
return next;
|
|
984
1011
|
};
|
|
985
1012
|
}
|
|
1013
|
+
function stateWithDecidedPanLaws() {
|
|
1014
|
+
const decided = /* @__PURE__ */ new Map();
|
|
1015
|
+
const states = /* @__PURE__ */ new Map();
|
|
1016
|
+
return (state) => {
|
|
1017
|
+
const known = states.get(state);
|
|
1018
|
+
if (known) return known;
|
|
1019
|
+
let byTracks = decided.get(state.mixer);
|
|
1020
|
+
if (!byTracks) {
|
|
1021
|
+
byTracks = /* @__PURE__ */ new Map();
|
|
1022
|
+
decided.set(state.mixer, byTracks);
|
|
1023
|
+
}
|
|
1024
|
+
let mixer = byTracks.get(state.tracks);
|
|
1025
|
+
if (!mixer) {
|
|
1026
|
+
mixer = decidePanLaws(state.mixer, state.tracks);
|
|
1027
|
+
byTracks.set(state.tracks, mixer);
|
|
1028
|
+
}
|
|
1029
|
+
const next = mixer === state.mixer ? state : { ...state, mixer };
|
|
1030
|
+
states.set(state, next);
|
|
1031
|
+
return next;
|
|
1032
|
+
};
|
|
1033
|
+
}
|
|
986
1034
|
function writeThrough(history, base, current, write) {
|
|
987
1035
|
const nextBase = base && { ...base, state: write(base.state) };
|
|
988
1036
|
return {
|
|
@@ -992,9 +1040,9 @@ function writeThrough(history, base, current, write) {
|
|
|
992
1040
|
}
|
|
993
1041
|
|
|
994
1042
|
// src/arrangement/ticks.ts
|
|
995
|
-
var
|
|
1043
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
996
1044
|
function forLoadedClips(change) {
|
|
997
|
-
return (clip) => (0,
|
|
1045
|
+
return (clip) => (0, import_core6.isLoadingClip)(clip) ? clip : change(clip);
|
|
998
1046
|
}
|
|
999
1047
|
function withClips(track, change) {
|
|
1000
1048
|
let changed = false;
|
|
@@ -1037,12 +1085,12 @@ function rescaleTick(tick, fromPpqn, toPpqn) {
|
|
|
1037
1085
|
}
|
|
1038
1086
|
|
|
1039
1087
|
// src/arrangement/validate.ts
|
|
1040
|
-
var
|
|
1088
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
1041
1089
|
function assertClipsOfTrackKind(track) {
|
|
1042
1090
|
const clips = track.clips.map(
|
|
1043
|
-
(clip) => (0,
|
|
1091
|
+
(clip) => (0, import_core7.isLoadingClip)(clip) ? { id: clip.id, name: clip.name } : clip
|
|
1044
1092
|
);
|
|
1045
|
-
(0,
|
|
1093
|
+
(0, import_core7.assertTrackKind)({ ...track, clips });
|
|
1046
1094
|
}
|
|
1047
1095
|
function assertUniqueClipIds(track) {
|
|
1048
1096
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1167,7 +1215,7 @@ var ArrangementImpl = class {
|
|
|
1167
1215
|
}
|
|
1168
1216
|
/** Be told after every change. See `Arrangement.subscribe`. */
|
|
1169
1217
|
subscribe(listener) {
|
|
1170
|
-
const entry = () => listener();
|
|
1218
|
+
const entry = (change) => listener(change);
|
|
1171
1219
|
this._subscribers.add(entry);
|
|
1172
1220
|
return () => {
|
|
1173
1221
|
this._subscribers.delete(entry);
|
|
@@ -1451,6 +1499,23 @@ var ArrangementImpl = class {
|
|
|
1451
1499
|
setTrackPan(trackId, pan, options) {
|
|
1452
1500
|
this._setMixerValues(trackId, { pan }, options);
|
|
1453
1501
|
}
|
|
1502
|
+
/**
|
|
1503
|
+
* Set a track's pan law (#684): a mixer value like the four above. It
|
|
1504
|
+
* takes a decided law; anything else, `'auto'` included, throws before
|
|
1505
|
+
* anything changes (a decided track does not go back to `'auto'`). May be
|
|
1506
|
+
* called before the track holds audio: the law is then decided, and the
|
|
1507
|
+
* first audio does not change it. A MIDI track has no law to set.
|
|
1508
|
+
*/
|
|
1509
|
+
setTrackPanLaw(trackId, panLaw, options) {
|
|
1510
|
+
if (!(0, import_core8.isDecidedPanLaw)(panLaw)) {
|
|
1511
|
+
throw new TypeError(
|
|
1512
|
+
`setTrackPanLaw: panLaw must be 'mono' or 'stereo', got ${JSON.stringify(panLaw) ?? String(panLaw)}`
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
const track = this._tracks.find((t) => t.id === trackId);
|
|
1516
|
+
if (!track || (0, import_core8.trackKind)(track) === "midi") return;
|
|
1517
|
+
this._setMixerValues(trackId, { panLaw }, options);
|
|
1518
|
+
}
|
|
1454
1519
|
// ---------------------------------------------------------------------------
|
|
1455
1520
|
// Recording mute (the track a take is recording onto)
|
|
1456
1521
|
// ---------------------------------------------------------------------------
|
|
@@ -1531,7 +1596,7 @@ var ArrangementImpl = class {
|
|
|
1531
1596
|
...track,
|
|
1532
1597
|
clips: track.clips.map((clip) => {
|
|
1533
1598
|
if (held?.has(clip)) return clip;
|
|
1534
|
-
if ((0,
|
|
1599
|
+
if ((0, import_core8.isLoadingClip)(clip)) return { ...clip };
|
|
1535
1600
|
return { ...clip, startTick: clip.startTick ?? this._tickAt(clip.startSample) };
|
|
1536
1601
|
})
|
|
1537
1602
|
};
|
|
@@ -1748,8 +1813,58 @@ var ArrangementImpl = class {
|
|
|
1748
1813
|
state: withStateTracks(state, pass.stored(state.tracks))
|
|
1749
1814
|
};
|
|
1750
1815
|
}
|
|
1816
|
+
this._decidePanLaws();
|
|
1751
1817
|
return this._tracks === previous ? null : previous;
|
|
1752
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* First audio decides a track's pan law (#684): in the current state and
|
|
1821
|
+
* in every state the arrangement can return to, a track whose law is
|
|
1822
|
+
* `'auto'` and that holds decoded audio gets the law of that audio, each
|
|
1823
|
+
* state from its own tracks. Part of the change that brought the audio:
|
|
1824
|
+
* not an undo step. `mixerVersion` counts it when the current mix changed.
|
|
1825
|
+
*
|
|
1826
|
+
* A saved step that no longer differs from the state next to it is
|
|
1827
|
+
* dropped, as `_writeMixerThrough` does (a law set on a track whose only
|
|
1828
|
+
* clip was loading, and the clip turns out to have that law): its undo, or
|
|
1829
|
+
* its redo, would do nothing. A gesture whose own step went has no step to
|
|
1830
|
+
* join, and its next change pushes a new one; a gesture whose step is still
|
|
1831
|
+
* the top one goes on.
|
|
1832
|
+
*/
|
|
1833
|
+
_decidePanLaws() {
|
|
1834
|
+
const decide = stateWithDecidedPanLaws();
|
|
1835
|
+
const current = this._currentState();
|
|
1836
|
+
const decided = decide(current);
|
|
1837
|
+
if (decided !== current) {
|
|
1838
|
+
this._mixer = decided.mixer;
|
|
1839
|
+
this._mixerVersion++;
|
|
1840
|
+
}
|
|
1841
|
+
const changedIn = (before, after) => after.undo.some((state, i) => state !== before.undo[i]) || after.redo.some((state, i) => state !== before.redo[i]);
|
|
1842
|
+
let base = this._transaction?.state ?? null;
|
|
1843
|
+
if (this._transaction && base) {
|
|
1844
|
+
const decidedBase = decide(base);
|
|
1845
|
+
if (decidedBase !== base) {
|
|
1846
|
+
base = decidedBase;
|
|
1847
|
+
this._transaction = { ...this._transaction, state: decidedBase };
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
const mapped = mapHistoryStates(this._history, decide);
|
|
1851
|
+
const savedChanged = changedIn(this._history, mapped);
|
|
1852
|
+
if (savedChanged || decided !== current) {
|
|
1853
|
+
const top = mapped.undo[mapped.undo.length - 1];
|
|
1854
|
+
const kept = dropRepeats(mapped, base ?? decided);
|
|
1855
|
+
if (savedChanged || kept !== mapped) this._history = kept;
|
|
1856
|
+
if (this._gesture && kept !== mapped) {
|
|
1857
|
+
const newTop = kept.undo[kept.undo.length - 1];
|
|
1858
|
+
if (!(newTop !== void 0 && top !== void 0 && sameState(newTop, top))) {
|
|
1859
|
+
this._gesture = null;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
if (this._gesture) {
|
|
1864
|
+
const before = mapHistoryStates(this._gesture.before, decide);
|
|
1865
|
+
if (changedIn(this._gesture.before, before)) this._gesture = { ...this._gesture, before };
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1753
1868
|
/** A load finished or failed by itself (not inside one of this arrangement's methods). */
|
|
1754
1869
|
_onSourceSettled() {
|
|
1755
1870
|
const previous = this._switchLoaded();
|
|
@@ -1797,9 +1912,10 @@ var ArrangementImpl = class {
|
|
|
1797
1912
|
}
|
|
1798
1913
|
}
|
|
1799
1914
|
}
|
|
1915
|
+
const info = Object.freeze({ type: next.change.type });
|
|
1800
1916
|
for (const subscriber of [...this._subscribers]) {
|
|
1801
1917
|
try {
|
|
1802
|
-
subscriber();
|
|
1918
|
+
subscriber(info);
|
|
1803
1919
|
} catch (error) {
|
|
1804
1920
|
console.warn("[waveform-playlist] Error in an arrangement subscriber:", error);
|
|
1805
1921
|
}
|
|
@@ -1819,7 +1935,7 @@ function createArrangement(options = {}) {
|
|
|
1819
1935
|
}
|
|
1820
1936
|
|
|
1821
1937
|
// src/adapterSync.ts
|
|
1822
|
-
var
|
|
1938
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
1823
1939
|
var AdapterSync = class {
|
|
1824
1940
|
constructor(_arrangement, _adapter) {
|
|
1825
1941
|
this._arrangement = _arrangement;
|
|
@@ -1910,6 +2026,13 @@ var AdapterSync = class {
|
|
|
1910
2026
|
}
|
|
1911
2027
|
if (values.soloed !== void 0) this._adapter?.setTrackSolo(trackId, values.soloed);
|
|
1912
2028
|
if (values.pan !== void 0) this._adapter?.setTrackPan(trackId, values.pan);
|
|
2029
|
+
if (values.panLaw !== void 0) this._sendPanLaw(trackId, values.panLaw);
|
|
2030
|
+
}
|
|
2031
|
+
/** The adapter's setter for a pan law, or, for an adapter without one, the track again (#684). */
|
|
2032
|
+
_sendPanLaw(trackId, panLaw) {
|
|
2033
|
+
if (!this._adapter) return;
|
|
2034
|
+
if (this._adapter.setTrackPanLaw) this._adapter.setTrackPanLaw(trackId, panLaw);
|
|
2035
|
+
else this.sendTrack(trackId);
|
|
1913
2036
|
}
|
|
1914
2037
|
/**
|
|
1915
2038
|
* After an undo, a redo or an abort brought back another mix: the setter
|
|
@@ -2033,7 +2156,7 @@ var AdapterSync = class {
|
|
|
2033
2156
|
if (before.clips.some((clip, i) => clip !== now.clips[i])) return false;
|
|
2034
2157
|
const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(now)]);
|
|
2035
2158
|
keys.delete("clips");
|
|
2036
|
-
for (const field of
|
|
2159
|
+
for (const field of import_core9.TRACK_VIEW_FIELDS) keys.delete(field);
|
|
2037
2160
|
return [...keys].every((key) => Object.is(before[key], now[key]));
|
|
2038
2161
|
}
|
|
2039
2162
|
/** What `getState()` is given for one of the arrangement's tracks (an adapter: `_playout` of it). */
|
|
@@ -2048,7 +2171,7 @@ var AdapterSync = class {
|
|
|
2048
2171
|
_loaded(track) {
|
|
2049
2172
|
const known = this._loadedMemo.get(track);
|
|
2050
2173
|
if (known) return known;
|
|
2051
|
-
const clips = track.clips.filter((clip) => !(0,
|
|
2174
|
+
const clips = track.clips.filter((clip) => !(0, import_core9.isLoadingClip)(clip));
|
|
2052
2175
|
const loaded = clips.length === track.clips.length ? track : { ...track, clips };
|
|
2053
2176
|
this._loadedMemo.set(track, loaded);
|
|
2054
2177
|
return loaded;
|
|
@@ -2064,7 +2187,7 @@ var AdapterSync = class {
|
|
|
2064
2187
|
/** A projected track without its view fields: a copy that shares its clips. */
|
|
2065
2188
|
_playout(track) {
|
|
2066
2189
|
const copy = { ...track };
|
|
2067
|
-
for (const field of
|
|
2190
|
+
for (const field of import_core9.TRACK_VIEW_FIELDS) delete copy[field];
|
|
2068
2191
|
return freezeTrackInDevelopment(copy);
|
|
2069
2192
|
}
|
|
2070
2193
|
/**
|
|
@@ -2489,6 +2612,16 @@ var PlaylistEngine = class {
|
|
|
2489
2612
|
const changed = this._mixerChanged(() => this._arrangement.setTrackPan(trackId, pan, options));
|
|
2490
2613
|
if (!changed && !this._disposed) this._adapter?.setTrackPan(trackId, pan);
|
|
2491
2614
|
}
|
|
2615
|
+
/**
|
|
2616
|
+
* Set a track's pan law (#684): the arrangement's `setTrackPanLaw`.
|
|
2617
|
+
* Unlike the four setters above, nothing is sent to the adapter when the
|
|
2618
|
+
* arrangement changed nothing (a track it does not hold, the law the
|
|
2619
|
+
* track already has): for an adapter without `setTrackPanLaw` the call
|
|
2620
|
+
* would be a whole-track `updateTrack`.
|
|
2621
|
+
*/
|
|
2622
|
+
setTrackPanLaw(trackId, panLaw, options) {
|
|
2623
|
+
this._arrangement.setTrackPanLaw(trackId, panLaw, options);
|
|
2624
|
+
}
|
|
2492
2625
|
/**
|
|
2493
2626
|
* Mark a track as the one a take is recording onto, or clear it when the
|
|
2494
2627
|
* take ends: the arrangement's `setTrackRecording`. That track plays muted
|