@waveform-playlist/engine 14.0.0-next.6 → 14.0.0-next.8
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 +3 -1
- package/dist/index.d.mts +39 -5
- package/dist/index.d.ts +39 -5
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -329,7 +329,9 @@ interface Arrangement {
|
|
|
329
329
|
// read
|
|
330
330
|
getTracks(): readonly ArrangementTrack[];
|
|
331
331
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
332
|
-
|
|
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;
|
|
333
335
|
readonly tracksVersion: number;
|
|
334
336
|
readonly mixerVersion: number;
|
|
335
337
|
|
package/dist/index.d.mts
CHANGED
|
@@ -49,6 +49,13 @@ declare function calculateSplitPoint(splitSample: number, samplesPerPixel: numbe
|
|
|
49
49
|
*
|
|
50
50
|
* The left clip retains the original fadeIn; the right clip retains the original fadeOut.
|
|
51
51
|
* Both clips share the same waveformData reference and the same `src`.
|
|
52
|
+
* A MIDI clip's halves both keep its whole `midiNotes` list (the same array),
|
|
53
|
+
* `midiChannel` and `midiProgram` (#838): like an audio clip's buffer, the notes
|
|
54
|
+
* are the source and each half is a window on them (`offsetSamples` and
|
|
55
|
+
* `durationSamples`), the notes the Tone MIDI tracks play and the piano roll
|
|
56
|
+
* draws. A note that crosses the split is released by the left half at the
|
|
57
|
+
* split (a SoundFont sample that does not loop rings on) and struck again
|
|
58
|
+
* there by the right half.
|
|
52
59
|
* The left clip keeps the original's `id`; the right clip gets a new one.
|
|
53
60
|
* If the clip has a name, suffixes " (1)" and " (2)" are appended.
|
|
54
61
|
*
|
|
@@ -277,6 +284,28 @@ interface MixerChangeOptions {
|
|
|
277
284
|
/** Not an undo step: the value is written into every saved state as well. */
|
|
278
285
|
undoable?: false;
|
|
279
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* The kind of change a `subscribe` listener is told of:
|
|
289
|
+
*
|
|
290
|
+
* - `'set'`: `setTracks` replaced the whole set.
|
|
291
|
+
* - `'add'`, `'remove'`, `'reorder'`: one track was added, removed or moved.
|
|
292
|
+
* - `'update'`: one track changed (`updateTrack`, a clip added, removed,
|
|
293
|
+
* moved, trimmed or split).
|
|
294
|
+
* - `'restore'`: an undo, a redo or an abort changed the tracks (and maybe
|
|
295
|
+
* the mix); `'restoreMix'`: it changed the mix only.
|
|
296
|
+
* - `'load'`: audio arrived and loading clips became loaded clips.
|
|
297
|
+
* - `'mixer'`: one of the mixer setters changed a volume, mute, solo, pan
|
|
298
|
+
* or pan law.
|
|
299
|
+
* - `'recording'`: a take started or stopped recording onto a track.
|
|
300
|
+
* - `'recompute'`: every track was gone through again: clip positions after
|
|
301
|
+
* a tempo change, or clip ticks when an engine attached.
|
|
302
|
+
* - `'history'`: only what can be undone or redone changed.
|
|
303
|
+
*/
|
|
304
|
+
type ArrangementChangeType = 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' | 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history';
|
|
305
|
+
/** What a `subscribe` listener is told about a change. */
|
|
306
|
+
interface ArrangementChangeInfo {
|
|
307
|
+
readonly type: ArrangementChangeType;
|
|
308
|
+
}
|
|
280
309
|
/**
|
|
281
310
|
* The owner of the tracks, of the mix and of the undo history. Everything
|
|
282
311
|
* else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
|
|
@@ -306,11 +335,12 @@ interface Arrangement {
|
|
|
306
335
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
307
336
|
/**
|
|
308
337
|
* Be told after every change (tracks, mix or history), once per change, in
|
|
309
|
-
* the order the changes were made
|
|
310
|
-
*
|
|
311
|
-
*
|
|
338
|
+
* the order the changes were made, with the kind of change it was. Read
|
|
339
|
+
* what changed from the arrangement itself. Returns a function that stops
|
|
340
|
+
* it. A listener that throws is reported with `console.warn` and does not
|
|
341
|
+
* fail the change.
|
|
312
342
|
*/
|
|
313
|
-
subscribe(listener: () => void): () => void;
|
|
343
|
+
subscribe(listener: (change: ArrangementChangeInfo) => void): () => void;
|
|
314
344
|
/** Counts changes to the tracks. */
|
|
315
345
|
readonly tracksVersion: number;
|
|
316
346
|
/** Counts changes to the mix. */
|
|
@@ -439,6 +469,10 @@ interface CreateArrangementOptions {
|
|
|
439
469
|
* (`setTrackRecording`, `recordingTrackIds`, `'recording'`).
|
|
440
470
|
*
|
|
441
471
|
* v3 (#848): `addTrack(track, { index })` puts the track at a place in the order.
|
|
472
|
+
*
|
|
473
|
+
* Not a new key (#826): `subscribe` listeners are called with `{ type }`. The
|
|
474
|
+
* engine does not call `subscribe`, and a listener that takes no argument
|
|
475
|
+
* works with either copy.
|
|
442
476
|
*/
|
|
443
477
|
|
|
444
478
|
type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
@@ -828,4 +862,4 @@ declare class PlaylistEngine {
|
|
|
828
862
|
private _emitStateChange;
|
|
829
863
|
}
|
|
830
864
|
|
|
831
|
-
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 };
|
|
865
|
+
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
|
@@ -49,6 +49,13 @@ declare function calculateSplitPoint(splitSample: number, samplesPerPixel: numbe
|
|
|
49
49
|
*
|
|
50
50
|
* The left clip retains the original fadeIn; the right clip retains the original fadeOut.
|
|
51
51
|
* Both clips share the same waveformData reference and the same `src`.
|
|
52
|
+
* A MIDI clip's halves both keep its whole `midiNotes` list (the same array),
|
|
53
|
+
* `midiChannel` and `midiProgram` (#838): like an audio clip's buffer, the notes
|
|
54
|
+
* are the source and each half is a window on them (`offsetSamples` and
|
|
55
|
+
* `durationSamples`), the notes the Tone MIDI tracks play and the piano roll
|
|
56
|
+
* draws. A note that crosses the split is released by the left half at the
|
|
57
|
+
* split (a SoundFont sample that does not loop rings on) and struck again
|
|
58
|
+
* there by the right half.
|
|
52
59
|
* The left clip keeps the original's `id`; the right clip gets a new one.
|
|
53
60
|
* If the clip has a name, suffixes " (1)" and " (2)" are appended.
|
|
54
61
|
*
|
|
@@ -277,6 +284,28 @@ interface MixerChangeOptions {
|
|
|
277
284
|
/** Not an undo step: the value is written into every saved state as well. */
|
|
278
285
|
undoable?: false;
|
|
279
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* The kind of change a `subscribe` listener is told of:
|
|
289
|
+
*
|
|
290
|
+
* - `'set'`: `setTracks` replaced the whole set.
|
|
291
|
+
* - `'add'`, `'remove'`, `'reorder'`: one track was added, removed or moved.
|
|
292
|
+
* - `'update'`: one track changed (`updateTrack`, a clip added, removed,
|
|
293
|
+
* moved, trimmed or split).
|
|
294
|
+
* - `'restore'`: an undo, a redo or an abort changed the tracks (and maybe
|
|
295
|
+
* the mix); `'restoreMix'`: it changed the mix only.
|
|
296
|
+
* - `'load'`: audio arrived and loading clips became loaded clips.
|
|
297
|
+
* - `'mixer'`: one of the mixer setters changed a volume, mute, solo, pan
|
|
298
|
+
* or pan law.
|
|
299
|
+
* - `'recording'`: a take started or stopped recording onto a track.
|
|
300
|
+
* - `'recompute'`: every track was gone through again: clip positions after
|
|
301
|
+
* a tempo change, or clip ticks when an engine attached.
|
|
302
|
+
* - `'history'`: only what can be undone or redone changed.
|
|
303
|
+
*/
|
|
304
|
+
type ArrangementChangeType = 'set' | 'add' | 'remove' | 'update' | 'reorder' | 'restore' | 'restoreMix' | 'load' | 'mixer' | 'recording' | 'recompute' | 'history';
|
|
305
|
+
/** What a `subscribe` listener is told about a change. */
|
|
306
|
+
interface ArrangementChangeInfo {
|
|
307
|
+
readonly type: ArrangementChangeType;
|
|
308
|
+
}
|
|
280
309
|
/**
|
|
281
310
|
* The owner of the tracks, of the mix and of the undo history. Everything
|
|
282
311
|
* else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
|
|
@@ -306,11 +335,12 @@ interface Arrangement {
|
|
|
306
335
|
getMixer(): ReadonlyMap<string, TrackMixerValues>;
|
|
307
336
|
/**
|
|
308
337
|
* Be told after every change (tracks, mix or history), once per change, in
|
|
309
|
-
* the order the changes were made
|
|
310
|
-
*
|
|
311
|
-
*
|
|
338
|
+
* the order the changes were made, with the kind of change it was. Read
|
|
339
|
+
* what changed from the arrangement itself. Returns a function that stops
|
|
340
|
+
* it. A listener that throws is reported with `console.warn` and does not
|
|
341
|
+
* fail the change.
|
|
312
342
|
*/
|
|
313
|
-
subscribe(listener: () => void): () => void;
|
|
343
|
+
subscribe(listener: (change: ArrangementChangeInfo) => void): () => void;
|
|
314
344
|
/** Counts changes to the tracks. */
|
|
315
345
|
readonly tracksVersion: number;
|
|
316
346
|
/** Counts changes to the mix. */
|
|
@@ -439,6 +469,10 @@ interface CreateArrangementOptions {
|
|
|
439
469
|
* (`setTrackRecording`, `recordingTrackIds`, `'recording'`).
|
|
440
470
|
*
|
|
441
471
|
* v3 (#848): `addTrack(track, { index })` puts the track at a place in the order.
|
|
472
|
+
*
|
|
473
|
+
* Not a new key (#826): `subscribe` listeners are called with `{ type }`. The
|
|
474
|
+
* engine does not call `subscribe`, and a listener that takes no argument
|
|
475
|
+
* works with either copy.
|
|
442
476
|
*/
|
|
443
477
|
|
|
444
478
|
type GetDecodeContext = () => Promise<BaseAudioContext>;
|
|
@@ -828,4 +862,4 @@ declare class PlaylistEngine {
|
|
|
828
862
|
private _emitStateChange;
|
|
829
863
|
}
|
|
830
864
|
|
|
831
|
-
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 };
|
|
865
|
+
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
|
@@ -86,6 +86,11 @@ function calculateSplitPoint(splitSample, samplesPerPixel) {
|
|
|
86
86
|
function splitClip(clip, splitSample) {
|
|
87
87
|
const leftDuration = splitSample - clip.startSample;
|
|
88
88
|
const rightDuration = clip.durationSamples - leftDuration;
|
|
89
|
+
const midi = {
|
|
90
|
+
midiNotes: clip.midiNotes,
|
|
91
|
+
midiChannel: clip.midiChannel,
|
|
92
|
+
midiProgram: clip.midiProgram
|
|
93
|
+
};
|
|
89
94
|
const leftName = clip.name ? `${clip.name} (1)` : void 0;
|
|
90
95
|
const rightName = clip.name ? `${clip.name} (2)` : void 0;
|
|
91
96
|
const left = {
|
|
@@ -101,7 +106,8 @@ function splitClip(clip, splitSample) {
|
|
|
101
106
|
fadeIn: clip.fadeIn,
|
|
102
107
|
audioBuffer: clip.audioBuffer,
|
|
103
108
|
waveformData: clip.waveformData,
|
|
104
|
-
src: clip.src
|
|
109
|
+
src: clip.src,
|
|
110
|
+
...midi
|
|
105
111
|
}),
|
|
106
112
|
id: clip.id
|
|
107
113
|
};
|
|
@@ -117,7 +123,8 @@ function splitClip(clip, splitSample) {
|
|
|
117
123
|
fadeOut: clip.fadeOut,
|
|
118
124
|
audioBuffer: clip.audioBuffer,
|
|
119
125
|
waveformData: clip.waveformData,
|
|
120
|
-
src: clip.src
|
|
126
|
+
src: clip.src,
|
|
127
|
+
...midi
|
|
121
128
|
});
|
|
122
129
|
return { left, right };
|
|
123
130
|
}
|
|
@@ -1215,7 +1222,7 @@ var ArrangementImpl = class {
|
|
|
1215
1222
|
}
|
|
1216
1223
|
/** Be told after every change. See `Arrangement.subscribe`. */
|
|
1217
1224
|
subscribe(listener) {
|
|
1218
|
-
const entry = () => listener();
|
|
1225
|
+
const entry = (change) => listener(change);
|
|
1219
1226
|
this._subscribers.add(entry);
|
|
1220
1227
|
return () => {
|
|
1221
1228
|
this._subscribers.delete(entry);
|
|
@@ -1912,9 +1919,10 @@ var ArrangementImpl = class {
|
|
|
1912
1919
|
}
|
|
1913
1920
|
}
|
|
1914
1921
|
}
|
|
1922
|
+
const info = Object.freeze({ type: next.change.type });
|
|
1915
1923
|
for (const subscriber of [...this._subscribers]) {
|
|
1916
1924
|
try {
|
|
1917
|
-
subscriber();
|
|
1925
|
+
subscriber(info);
|
|
1918
1926
|
} catch (error) {
|
|
1919
1927
|
console.warn("[waveform-playlist] Error in an arrangement subscriber:", error);
|
|
1920
1928
|
}
|