@waveform-playlist/engine 14.0.0-next.4 → 14.0.0-next.5
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 +8 -5
- package/dist/index.d.mts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +19 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ What happens to a loading clip:
|
|
|
188
188
|
- **It is held like any clip.** It is copied on its way in, is the same object through every operation on its track, keeps its place among the track's clips and is part of the undo steps. It has no `startTick`.
|
|
189
189
|
- **It cannot be edited.** `moveClip`, `trimClip` and `splitClip` on it log a warning (`… is still loading and cannot be edited until its audio has loaded`) and change nothing; `getClipBounds` returns `null` and `constrainTrimDelta` returns 0. Loaded clips do not collide with it.
|
|
190
190
|
- **It is audio.** A loading clip on a `kind: 'midi'` track is refused: `createArrangement({ tracks })`, `setTracks`, `addTrack` and `updateTrack` throw the error for a track whose clips do not match its kind, and nothing changes.
|
|
191
|
-
- **An engine does not play or report it.** The tracks an adapter is sent and `engine.getState().tracks` are each track without its loading clips, and `getState().duration` counts loaded clips only. A change that leaves a track's loaded clips (the same objects in the same order) and its own fields as they were makes no adapter call for that track; the `statechange` is still emitted. `engine.updateTrack(id)` always sends.
|
|
191
|
+
- **An engine does not play or report it.** The tracks an adapter is sent and `engine.getState().tracks` are each track without its loading clips, and `getState().duration` counts loaded clips only. A change that leaves a track's loaded clips (the same objects in the same order) and its own fields other than the view fields (`TRACK_VIEW_FIELDS`) as they were makes no adapter call for that track; the `statechange` is still emitted. `engine.updateTrack(id)` always sends.
|
|
192
192
|
|
|
193
193
|
Which sources are loaded: every source a loading clip names in the current tracks, in an undo or redo state or in the base of an open transaction. So an undo never fetches a source again, and a source is dropped (its load aborted, its audio let go) when no state names it any more; named again later, it is fetched again. A loaded clip that carries both `src` and `audioBuffer` counts too: its buffer is used for that source and nothing is fetched. A loaded clip with `src` and no `audioBuffer` is not fetched and is not in `sources`: it never gets audio from the arrangement.
|
|
194
194
|
|
|
@@ -236,7 +236,7 @@ One context at a time: attaching a second while one is attached logs a warning a
|
|
|
236
236
|
|
|
237
237
|
Rules that hold for the engine and the arrangement alike:
|
|
238
238
|
|
|
239
|
-
- **Nothing handed out is a copy.** `arrangement.getTracks()
|
|
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
241
|
- **The mix is separate from the tracks.** A track's own `volume`, `muted`, `soloed` and `pan` 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` and `setTrackPan`, 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
242
|
- **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.
|
|
@@ -419,10 +419,13 @@ interface PlayoutAdapter {
|
|
|
419
419
|
setPpqn?(ppqn: number): void;
|
|
420
420
|
|
|
421
421
|
init(): Promise<void>;
|
|
422
|
-
|
|
423
|
-
|
|
422
|
+
// PlayoutTrack (core): a ClipTrack without the view fields of TRACK_VIEW_FIELDS (name,
|
|
423
|
+
// color, height, renderMode, spectrogramConfig, spectrogramColorMap); a change of those
|
|
424
|
+
// alone makes no adapter call. Read the tracks, never write to them. Loaded clips only
|
|
425
|
+
setTracks(tracks: readonly PlayoutTrack[]): void;
|
|
426
|
+
addTrack?(track: PlayoutTrack): void;
|
|
424
427
|
removeTrack?(trackId: string): void;
|
|
425
|
-
updateTrack?(trackId: string, track:
|
|
428
|
+
updateTrack?(trackId: string, track: PlayoutTrack): void;
|
|
426
429
|
|
|
427
430
|
play(startTime: number, endTime?: number): void;
|
|
428
431
|
pause(): void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource } from '@waveform-playlist/core';
|
|
1
|
+
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Clip Operations
|
|
@@ -463,14 +463,18 @@ interface PlayoutAdapter {
|
|
|
463
463
|
/** Set the adapter's tick resolution. Optional — adapters with fixed PPQN ignore this. */
|
|
464
464
|
setPpqn?(ppqn: number): void;
|
|
465
465
|
init(): Promise<void>;
|
|
466
|
-
/**
|
|
467
|
-
|
|
466
|
+
/**
|
|
467
|
+
* Copies of the engine's tracks without their view fields (core's
|
|
468
|
+
* `TRACK_VIEW_FIELDS`), sharing its clips: read them, never write to them.
|
|
469
|
+
* A change of view fields alone causes no adapter call.
|
|
470
|
+
*/
|
|
471
|
+
setTracks(tracks: readonly PlayoutTrack[]): void;
|
|
468
472
|
/** Incrementally add a single track without rebuilding the entire playout. */
|
|
469
|
-
addTrack?(track:
|
|
473
|
+
addTrack?(track: PlayoutTrack): void;
|
|
470
474
|
/** Incrementally remove a single track without rebuilding the entire playout. */
|
|
471
475
|
removeTrack?(trackId: string): void;
|
|
472
476
|
/** Update a single track's clips (removes old, adds new). */
|
|
473
|
-
updateTrack?(trackId: string, track:
|
|
477
|
+
updateTrack?(trackId: string, track: PlayoutTrack): void;
|
|
474
478
|
play(startTime: number, endTime?: number): void;
|
|
475
479
|
pause(): void;
|
|
476
480
|
stop(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource } from '@waveform-playlist/core';
|
|
1
|
+
import { AudioClip, ClipTrack, ClipSource, ArrangementTrack, ValueSource, PlayoutTrack } from '@waveform-playlist/core';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Clip Operations
|
|
@@ -463,14 +463,18 @@ interface PlayoutAdapter {
|
|
|
463
463
|
/** Set the adapter's tick resolution. Optional — adapters with fixed PPQN ignore this. */
|
|
464
464
|
setPpqn?(ppqn: number): void;
|
|
465
465
|
init(): Promise<void>;
|
|
466
|
-
/**
|
|
467
|
-
|
|
466
|
+
/**
|
|
467
|
+
* Copies of the engine's tracks without their view fields (core's
|
|
468
|
+
* `TRACK_VIEW_FIELDS`), sharing its clips: read them, never write to them.
|
|
469
|
+
* A change of view fields alone causes no adapter call.
|
|
470
|
+
*/
|
|
471
|
+
setTracks(tracks: readonly PlayoutTrack[]): void;
|
|
468
472
|
/** Incrementally add a single track without rebuilding the entire playout. */
|
|
469
|
-
addTrack?(track:
|
|
473
|
+
addTrack?(track: PlayoutTrack): void;
|
|
470
474
|
/** Incrementally remove a single track without rebuilding the entire playout. */
|
|
471
475
|
removeTrack?(trackId: string): void;
|
|
472
476
|
/** Update a single track's clips (removes old, adds new). */
|
|
473
|
-
updateTrack?(trackId: string, track:
|
|
477
|
+
updateTrack?(trackId: string, track: PlayoutTrack): void;
|
|
474
478
|
play(startTime: number, endTime?: number): void;
|
|
475
479
|
pause(): void;
|
|
476
480
|
stop(): void;
|
package/dist/index.js
CHANGED
|
@@ -1865,6 +1865,14 @@ var AdapterSync = class {
|
|
|
1865
1865
|
this._projection = { tracksVersion, mixerVersion, tracks };
|
|
1866
1866
|
return tracks;
|
|
1867
1867
|
}
|
|
1868
|
+
/**
|
|
1869
|
+
* `tracks()` as the adapter is given them: without the view fields. Made
|
|
1870
|
+
* for each send; nothing depends on the adapter's tracks keeping their
|
|
1871
|
+
* identity between sends.
|
|
1872
|
+
*/
|
|
1873
|
+
_playoutTracks() {
|
|
1874
|
+
return freezeTracksInDevelopment(this.tracks().map((track) => this._playout(track)));
|
|
1875
|
+
}
|
|
1868
1876
|
/** When an engine attaches: send the tracks that are there. With none, the adapter is in step as it is. */
|
|
1869
1877
|
sendInitialTracks() {
|
|
1870
1878
|
if (this._arrangement.getTracks().length > 0) {
|
|
@@ -1876,7 +1884,7 @@ var AdapterSync = class {
|
|
|
1876
1884
|
/** Send the adapter every track, and remember up to which change that covers. */
|
|
1877
1885
|
sendAllTracks() {
|
|
1878
1886
|
const version = this._arrangement.tracksVersion;
|
|
1879
|
-
this._adapter?.setTracks(this.
|
|
1887
|
+
this._adapter?.setTracks(this._playoutTracks());
|
|
1880
1888
|
this._syncedTracksVersion = version;
|
|
1881
1889
|
}
|
|
1882
1890
|
/** Send the arrangement's current track to the adapter. False when there is no such track. */
|
|
@@ -1884,7 +1892,7 @@ var AdapterSync = class {
|
|
|
1884
1892
|
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
1885
1893
|
if (!track) return false;
|
|
1886
1894
|
if (this._adapter?.updateTrack) {
|
|
1887
|
-
this._adapter.updateTrack(trackId, this._project(track));
|
|
1895
|
+
this._adapter.updateTrack(trackId, this._playout(this._project(track)));
|
|
1888
1896
|
} else {
|
|
1889
1897
|
this.sendAllTracks();
|
|
1890
1898
|
}
|
|
@@ -1985,7 +1993,7 @@ var AdapterSync = class {
|
|
|
1985
1993
|
_addTrack(trackId) {
|
|
1986
1994
|
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
1987
1995
|
if (track && this._adapter?.addTrack) {
|
|
1988
|
-
this._adapter.addTrack(this._project(track));
|
|
1996
|
+
this._adapter.addTrack(this._playout(this._project(track)));
|
|
1989
1997
|
} else {
|
|
1990
1998
|
this.sendAllTracks();
|
|
1991
1999
|
}
|
|
@@ -2025,9 +2033,10 @@ var AdapterSync = class {
|
|
|
2025
2033
|
if (before.clips.some((clip, i) => clip !== now.clips[i])) return false;
|
|
2026
2034
|
const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(now)]);
|
|
2027
2035
|
keys.delete("clips");
|
|
2036
|
+
for (const field of import_core8.TRACK_VIEW_FIELDS) keys.delete(field);
|
|
2028
2037
|
return [...keys].every((key) => Object.is(before[key], now[key]));
|
|
2029
2038
|
}
|
|
2030
|
-
/** What
|
|
2039
|
+
/** What `getState()` is given for one of the arrangement's tracks (an adapter: `_playout` of it). */
|
|
2031
2040
|
_project(track) {
|
|
2032
2041
|
return this._withMix(this._loaded(track));
|
|
2033
2042
|
}
|
|
@@ -2052,6 +2061,12 @@ var AdapterSync = class {
|
|
|
2052
2061
|
_recordingNow(trackId) {
|
|
2053
2062
|
return this._arrangement.recordingTrackIds.has(trackId) && this._arrangement.getMixer().has(trackId);
|
|
2054
2063
|
}
|
|
2064
|
+
/** A projected track without its view fields: a copy that shares its clips. */
|
|
2065
|
+
_playout(track) {
|
|
2066
|
+
const copy = { ...track };
|
|
2067
|
+
for (const field of import_core8.TRACK_VIEW_FIELDS) delete copy[field];
|
|
2068
|
+
return freezeTrackInDevelopment(copy);
|
|
2069
|
+
}
|
|
2055
2070
|
/**
|
|
2056
2071
|
* One track with its current mixer values in its fields, muted while a
|
|
2057
2072
|
* take records onto it (memoized per track object).
|