@waveform-playlist/engine 14.0.0-next.7 → 14.0.0-next.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @waveform-playlist/engine
2
2
 
3
- Framework-agnostic multitrack timeline engine for waveform-playlist — pure clip/track operations, an arrangement that owns the tracks, the mix and the undo history, and a stateful `PlaylistEngine` that plays an arrangement and manages selection, loop and zoom, decoupled from any audio backend via a pluggable `PlayoutAdapter`.
3
+ Framework-agnostic multitrack timeline engine for waveform-playlist — pure clip/track operations, an arrangement that owns the tracks, the mix and the undo history, and a stateful `EditorEngine` that plays an arrangement and manages selection, loop and zoom, decoupled from any audio backend via a pluggable `PlayoutAdapter`.
4
4
 
5
5
  Used by `@waveform-playlist/browser` (the React provider) and `@dawcore/components` (the Lit web-components layer). Pair it with a `PlayoutAdapter` implementation such as `@waveform-playlist/playout` (Tone.js) or `@dawcore/transport` (native Web Audio) to actually produce sound — the engine itself never touches the audio graph directly.
6
6
 
@@ -26,12 +26,12 @@ npm install @waveform-playlist/engine @waveform-playlist/core
26
26
  ## Quick Start
27
27
 
28
28
  ```typescript
29
- import { PlaylistEngine } from '@waveform-playlist/engine';
29
+ import { EditorEngine } from '@waveform-playlist/engine';
30
30
  import { createClipFromSeconds, type ClipTrack } from '@waveform-playlist/core';
31
31
  import { createToneAdapter } from '@waveform-playlist/playout'; // any PlayoutAdapter implementation
32
32
 
33
33
  const adapter = createToneAdapter();
34
- const engine = new PlaylistEngine({ adapter, sampleRate: 48000 });
34
+ const engine = new EditorEngine({ adapter, sampleRate: 48000 });
35
35
  await engine.init();
36
36
 
37
37
  const track: ClipTrack = {
@@ -75,12 +75,12 @@ engine.redo();
75
75
 
76
76
  ## The arrangement
77
77
 
78
- An arrangement is the owner of three things: the tracks with their clips, the mix (volume, mute, solo and pan by track id) and the undo history with its transactions. Everything else reads it and changes it by calling its methods. A `PlaylistEngine` plays an arrangement: it follows it by subscription, and for each change it makes the adapter call and emits `statechange`.
78
+ An arrangement is the owner of three things: the tracks with their clips, the mix (volume, mute, solo and pan by track id) and the undo history with its transactions. Everything else reads it and changes it by calling its methods. An `EditorEngine` plays an arrangement: it follows it by subscription, and for each change it makes the adapter call and emits `statechange`.
79
79
 
80
- An engine built without an `arrangement` option makes one of its own, so `new PlaylistEngine({ adapter })` works as in the Quick Start. Make the arrangement yourself when it has to exist before the engine does, or outlive it:
80
+ An engine built without an `arrangement` option makes one of its own, so `new EditorEngine({ adapter })` works as in the Quick Start. Make the arrangement yourself when it has to exist before the engine does, or outlive it:
81
81
 
82
82
  ```typescript
83
- import { createArrangement, PlaylistEngine } from '@waveform-playlist/engine';
83
+ import { createArrangement, EditorEngine } from '@waveform-playlist/engine';
84
84
 
85
85
  const arrangement = createArrangement({ tracks: [track], undoLimit: 50 });
86
86
 
@@ -96,12 +96,12 @@ const unsubscribe = arrangement.subscribe(() => {
96
96
  });
97
97
 
98
98
  // Play it
99
- const engine = new PlaylistEngine({ adapter: createToneAdapter(), arrangement });
99
+ const engine = new EditorEngine({ adapter: createToneAdapter(), arrangement });
100
100
  await engine.init();
101
101
 
102
102
  // The arrangement outlives the engine
103
103
  engine.dispose();
104
- const next = new PlaylistEngine({ adapter: createToneAdapter(), arrangement });
104
+ const next = new EditorEngine({ adapter: createToneAdapter(), arrangement });
105
105
  // next has the same tracks, the same mix and the same undo history
106
106
  ```
107
107
 
@@ -147,7 +147,7 @@ slider.addEventListener('input', () => {
147
147
  A track of an arrangement is an `ArrangementTrack` (from `@waveform-playlist/core`): its clips are loaded clips (`AudioClip`) or clips whose audio is not loaded yet (`LoadingClip`: a `src` and times in seconds). `isLoadingClip(clip)` tells them apart; narrow with it before reading `startSample`, `durationSamples` or any other sample field of a clip from `arrangement.getTracks()`. `createArrangement({ tracks })`, `getTracks`, `setTracks`, `addTrack` and `updateTrack` of the arrangement use that type. The engine's own `setTracks`, `addTrack` and `updateTrack` still take `ClipTrack` (loaded clips only).
148
148
 
149
149
  ```typescript
150
- import { createArrangement, PlaylistEngine } from '@waveform-playlist/engine';
150
+ import { createArrangement, EditorEngine } from '@waveform-playlist/engine';
151
151
  import { audioTrack, isLoadingClip } from '@waveform-playlist/core';
152
152
 
153
153
  const arrangement = createArrangement({
@@ -161,7 +161,7 @@ const arrangement = createArrangement({
161
161
  arrangement.sources.getSnapshot(); // { sources: Map(2), pendingCount: 2, failedCount: 0, isLoading: true }
162
162
 
163
163
  // An engine with an adapter attaches adapter.audioContext, and the loads start.
164
- const engine = new PlaylistEngine({ adapter: createToneAdapter(), arrangement });
164
+ const engine = new EditorEngine({ adapter: createToneAdapter(), arrangement });
165
165
  await engine.init();
166
166
 
167
167
  arrangement.sources.subscribe(({ sources, isLoading, failedCount }) => {
@@ -220,7 +220,7 @@ const arrangement = createArrangement({ loadSource });
220
220
 
221
221
  The messages of `defaultLoadSource`'s own errors (`Failed to fetch <source>: <status> <statusText>`, `Failed to fetch <source>` when `fetch` threw a `TypeError`, `Decoded audio is empty: <source>`) name a URL without its query string, its fragment and a user name or password before the host (a URL the browser's parser finds credentials in is named in its parsed, absolute form; a malformed one the parser refuses loses only its query string and fragment), never echo a `data:` or `blob:` URL, and call a `File` by its name and any other `Blob` "Blob". The browser's `TypeError` is kept in `cause` only when the name in the message is the source unchanged. When anything was left out of the name (a user name or password, a query string, a fragment, a `data:` or `blob:` URL) the error has no `cause`, because the browser's own message can quote the whole URL. An `Error` the browser's decoder rejects with is passed on as it is, so its message is the browser's and does not name the source.
222
222
 
223
- Nothing is fetched until the arrangement has an audio context to decode with; until then its sources are `pending`. A `PlaylistEngine` built with an adapter attaches `adapter.audioContext` in its constructor and detaches it in `dispose()`. Without an engine, or with `new PlaylistEngine({ adapter, arrangement, attachDecodeContext: false })`, attach one yourself:
223
+ Nothing is fetched until the arrangement has an audio context to decode with; until then its sources are `pending`. An `EditorEngine` built with an adapter attaches `adapter.audioContext` in its constructor and detaches it in `dispose()`. Without an engine, or with `new EditorEngine({ adapter, arrangement, attachDecodeContext: false })`, attach one yourself:
224
224
 
225
225
  ```typescript
226
226
  import { attachDecodeContext } from '@waveform-playlist/engine';
@@ -246,13 +246,13 @@ Rules that hold for the engine and the arrangement alike:
246
246
 
247
247
  ## API
248
248
 
249
- ### PlaylistEngine
249
+ ### EditorEngine
250
250
 
251
- Key methods (see `src/types.ts` for the full `EngineState` shape). `PlaylistEngineOptions` takes `adapter`, `arrangement`, `sampleRate`, `samplesPerPixel`, `zoomLevels`, `undoLimit`, `attachDecodeContext`, `bpm` and `ppqn`, all optional:
251
+ Key methods (see `src/types.ts` for the full `EngineState` shape). `EditorEngineOptions` takes `adapter`, `arrangement`, `sampleRate`, `samplesPerPixel`, `zoomLevels`, `undoLimit`, `attachDecodeContext`, `bpm` and `ppqn`, all optional:
252
252
 
253
253
  ```typescript
254
- class PlaylistEngine {
255
- constructor(options?: PlaylistEngineOptions);
254
+ class EditorEngine {
255
+ constructor(options?: EditorEngineOptions);
256
256
 
257
257
  // Tracks
258
258
  setTracks(tracks: readonly ClipTrack[]): void; // replaces every track, clears the undo history
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
  *
@@ -302,7 +309,7 @@ interface ArrangementChangeInfo {
302
309
  /**
303
310
  * The owner of the tracks, of the mix and of the undo history. Everything
304
311
  * else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
305
- * calling its methods. A `PlaylistEngine` built on it plays it.
312
+ * calling its methods. An `EditorEngine` built on it plays it.
306
313
  *
307
314
  * Nothing it returns is a copy: never write to a tracks array, a track, a
308
315
  * clip or the mixer Map. Outside production builds the tracks are frozen.
@@ -481,21 +488,21 @@ declare function isArrangement(value: unknown): boolean;
481
488
  * flight are aborted and start again at the next attach; what is loaded
482
489
  * stays. One context at a time: a second attach warns and replaces the first.
483
490
  *
484
- * A `PlaylistEngine` with an adapter does this itself with the adapter's
491
+ * An `EditorEngine` with an adapter does this itself with the adapter's
485
492
  * context (see its `attachDecodeContext` option).
486
493
  */
487
494
  declare function attachDecodeContext(arrangement: Arrangement, getContext: GetDecodeContext): () => void;
488
495
 
489
496
  /**
490
497
  * Make an arrangement: the owner of the tracks, the mix and the undo
491
- * history. It needs no engine; give it to `new PlaylistEngine({ arrangement })`
498
+ * history. It needs no engine; give it to `new EditorEngine({ arrangement })`
492
499
  * to play it, and to the next engine when that one is disposed.
493
500
  */
494
501
  declare function createArrangement(options?: CreateArrangementOptions): Arrangement;
495
502
 
496
503
  /**
497
504
  * Interface for pluggable audio playback adapters.
498
- * Implement this to connect PlaylistEngine to any audio backend
505
+ * Implement this to connect EditorEngine to any audio backend
499
506
  * (Tone.js, openDAW, HTMLAudioElement, etc.)
500
507
  */
501
508
  interface PlayoutAdapter {
@@ -574,7 +581,7 @@ interface PlayoutAdapter {
574
581
  * what the listener actually hears. Tone.js Transport reports a position that's
575
582
  * `lookAhead` ahead of audible (default 0.1s); native AudioContext-based adapters
576
583
  * have no lookahead. Consumers visualizing playback position should use
577
- * `PlaylistEngine.getAudibleTime()`, which applies this (plus
584
+ * `EditorEngine.getAudibleTime()`, which applies this (plus
578
585
  * `audioContext.outputLatency`) only while playing. Returns 0 or undefined when
579
586
  * there's no lookahead. */
580
587
  readonly lookAhead?: number;
@@ -625,7 +632,7 @@ interface EngineState {
625
632
  /** Whether redo is available. */
626
633
  canRedo: boolean;
627
634
  }
628
- /** Options of `PlaylistEngine.dispose()`. */
635
+ /** Options of `EditorEngine.dispose()`. */
629
636
  interface EngineDisposeOptions {
630
637
  /**
631
638
  * Leave the adapter undisposed (#848), for a host that plays another
@@ -636,9 +643,9 @@ interface EngineDisposeOptions {
636
643
  keepAdapter?: boolean;
637
644
  }
638
645
  /**
639
- * Configuration options for PlaylistEngine constructor.
646
+ * Configuration options for EditorEngine constructor.
640
647
  */
641
- interface PlaylistEngineOptions {
648
+ interface EditorEngineOptions {
642
649
  adapter?: PlayoutAdapter;
643
650
  /**
644
651
  * The arrangement to play, from `createArrangement()`. It outlives the
@@ -669,7 +676,7 @@ interface PlaylistEngineOptions {
669
676
  ppqn?: number;
670
677
  }
671
678
  /**
672
- * Events emitted by PlaylistEngine.
679
+ * Events emitted by EditorEngine.
673
680
  */
674
681
  interface EngineEvents {
675
682
  statechange: (state: EngineState) => void;
@@ -679,7 +686,7 @@ interface EngineEvents {
679
686
  }
680
687
 
681
688
  /**
682
- * PlaylistEngine — Stateful, framework-agnostic timeline engine.
689
+ * EditorEngine — Stateful, framework-agnostic timeline engine.
683
690
  *
684
691
  * Composes an Arrangement (the tracks, the mix, the undo history and
685
692
  * transactions) with an event emitter and optional PlayoutAdapter for audio
@@ -689,7 +696,7 @@ interface EngineEvents {
689
696
  */
690
697
 
691
698
  type EventName = keyof EngineEvents;
692
- declare class PlaylistEngine {
699
+ declare class EditorEngine {
693
700
  private _arrangement;
694
701
  private _stopFollowingArrangement;
695
702
  private _detachFromArrangement;
@@ -714,7 +721,7 @@ declare class PlaylistEngine {
714
721
  private _disposed;
715
722
  private _listeners;
716
723
  readonly undoLimit: number;
717
- constructor(options?: PlaylistEngineOptions);
724
+ constructor(options?: EditorEngineOptions);
718
725
  get canUndo(): boolean;
719
726
  get canRedo(): boolean;
720
727
  undo(): void;
@@ -855,4 +862,4 @@ declare class PlaylistEngine {
855
862
  private _emitStateChange;
856
863
  }
857
864
 
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 };
865
+ export { type AddTrackOptions, type Arrangement, type ArrangementChangeInfo, type ArrangementChangeType, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, 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, 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
  *
@@ -302,7 +309,7 @@ interface ArrangementChangeInfo {
302
309
  /**
303
310
  * The owner of the tracks, of the mix and of the undo history. Everything
304
311
  * else reads it (`getTracks`, `getMixer`, `subscribe`) and changes it by
305
- * calling its methods. A `PlaylistEngine` built on it plays it.
312
+ * calling its methods. An `EditorEngine` built on it plays it.
306
313
  *
307
314
  * Nothing it returns is a copy: never write to a tracks array, a track, a
308
315
  * clip or the mixer Map. Outside production builds the tracks are frozen.
@@ -481,21 +488,21 @@ declare function isArrangement(value: unknown): boolean;
481
488
  * flight are aborted and start again at the next attach; what is loaded
482
489
  * stays. One context at a time: a second attach warns and replaces the first.
483
490
  *
484
- * A `PlaylistEngine` with an adapter does this itself with the adapter's
491
+ * An `EditorEngine` with an adapter does this itself with the adapter's
485
492
  * context (see its `attachDecodeContext` option).
486
493
  */
487
494
  declare function attachDecodeContext(arrangement: Arrangement, getContext: GetDecodeContext): () => void;
488
495
 
489
496
  /**
490
497
  * Make an arrangement: the owner of the tracks, the mix and the undo
491
- * history. It needs no engine; give it to `new PlaylistEngine({ arrangement })`
498
+ * history. It needs no engine; give it to `new EditorEngine({ arrangement })`
492
499
  * to play it, and to the next engine when that one is disposed.
493
500
  */
494
501
  declare function createArrangement(options?: CreateArrangementOptions): Arrangement;
495
502
 
496
503
  /**
497
504
  * Interface for pluggable audio playback adapters.
498
- * Implement this to connect PlaylistEngine to any audio backend
505
+ * Implement this to connect EditorEngine to any audio backend
499
506
  * (Tone.js, openDAW, HTMLAudioElement, etc.)
500
507
  */
501
508
  interface PlayoutAdapter {
@@ -574,7 +581,7 @@ interface PlayoutAdapter {
574
581
  * what the listener actually hears. Tone.js Transport reports a position that's
575
582
  * `lookAhead` ahead of audible (default 0.1s); native AudioContext-based adapters
576
583
  * have no lookahead. Consumers visualizing playback position should use
577
- * `PlaylistEngine.getAudibleTime()`, which applies this (plus
584
+ * `EditorEngine.getAudibleTime()`, which applies this (plus
578
585
  * `audioContext.outputLatency`) only while playing. Returns 0 or undefined when
579
586
  * there's no lookahead. */
580
587
  readonly lookAhead?: number;
@@ -625,7 +632,7 @@ interface EngineState {
625
632
  /** Whether redo is available. */
626
633
  canRedo: boolean;
627
634
  }
628
- /** Options of `PlaylistEngine.dispose()`. */
635
+ /** Options of `EditorEngine.dispose()`. */
629
636
  interface EngineDisposeOptions {
630
637
  /**
631
638
  * Leave the adapter undisposed (#848), for a host that plays another
@@ -636,9 +643,9 @@ interface EngineDisposeOptions {
636
643
  keepAdapter?: boolean;
637
644
  }
638
645
  /**
639
- * Configuration options for PlaylistEngine constructor.
646
+ * Configuration options for EditorEngine constructor.
640
647
  */
641
- interface PlaylistEngineOptions {
648
+ interface EditorEngineOptions {
642
649
  adapter?: PlayoutAdapter;
643
650
  /**
644
651
  * The arrangement to play, from `createArrangement()`. It outlives the
@@ -669,7 +676,7 @@ interface PlaylistEngineOptions {
669
676
  ppqn?: number;
670
677
  }
671
678
  /**
672
- * Events emitted by PlaylistEngine.
679
+ * Events emitted by EditorEngine.
673
680
  */
674
681
  interface EngineEvents {
675
682
  statechange: (state: EngineState) => void;
@@ -679,7 +686,7 @@ interface EngineEvents {
679
686
  }
680
687
 
681
688
  /**
682
- * PlaylistEngine — Stateful, framework-agnostic timeline engine.
689
+ * EditorEngine — Stateful, framework-agnostic timeline engine.
683
690
  *
684
691
  * Composes an Arrangement (the tracks, the mix, the undo history and
685
692
  * transactions) with an event emitter and optional PlayoutAdapter for audio
@@ -689,7 +696,7 @@ interface EngineEvents {
689
696
  */
690
697
 
691
698
  type EventName = keyof EngineEvents;
692
- declare class PlaylistEngine {
699
+ declare class EditorEngine {
693
700
  private _arrangement;
694
701
  private _stopFollowingArrangement;
695
702
  private _detachFromArrangement;
@@ -714,7 +721,7 @@ declare class PlaylistEngine {
714
721
  private _disposed;
715
722
  private _listeners;
716
723
  readonly undoLimit: number;
717
- constructor(options?: PlaylistEngineOptions);
724
+ constructor(options?: EditorEngineOptions);
718
725
  get canUndo(): boolean;
719
726
  get canRedo(): boolean;
720
727
  undo(): void;
@@ -855,4 +862,4 @@ declare class PlaylistEngine {
855
862
  private _emitStateChange;
856
863
  }
857
864
 
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 };
865
+ export { type AddTrackOptions, type Arrangement, type ArrangementChangeInfo, type ArrangementChangeType, type ArrangementSourceState, type ArrangementSourcesValue, type ClipBounds, 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, findClosestZoomIndex, getVisibleChunkIndices, isArrangement, shouldUpdateViewport, splitClip };
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- PlaylistEngine: () => PlaylistEngine,
23
+ EditorEngine: () => EditorEngine,
24
24
  attachDecodeContext: () => attachDecodeContext,
25
25
  calculateDuration: () => calculateDuration,
26
26
  calculateSplitPoint: () => calculateSplitPoint,
@@ -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
  }
@@ -2206,11 +2213,11 @@ var AdapterSync = class {
2206
2213
  }
2207
2214
  };
2208
2215
 
2209
- // src/PlaylistEngine.ts
2216
+ // src/EditorEngine.ts
2210
2217
  var DEFAULT_SAMPLE_RATE = 48e3;
2211
2218
  var DEFAULT_SAMPLES_PER_PIXEL = 1024;
2212
2219
  var DEFAULT_ZOOM_LEVELS = [256, 512, 1024, 2048, 4096, 8192];
2213
- var PlaylistEngine = class {
2220
+ var EditorEngine = class {
2214
2221
  constructor(options = {}) {
2215
2222
  this._detachDecodeContext = null;
2216
2223
  this._currentTime = 0;
@@ -2237,13 +2244,13 @@ var PlaylistEngine = class {
2237
2244
  });
2238
2245
  });
2239
2246
  if (this._zoomLevels.length === 0) {
2240
- throw new Error("PlaylistEngine: zoomLevels must not be empty");
2247
+ throw new Error("EditorEngine: zoomLevels must not be empty");
2241
2248
  }
2242
2249
  const initialSpp = options.samplesPerPixel ?? DEFAULT_SAMPLES_PER_PIXEL;
2243
2250
  const zoomIndex = this._zoomLevels.indexOf(initialSpp);
2244
2251
  if (zoomIndex === -1) {
2245
2252
  throw new Error(
2246
- `PlaylistEngine: samplesPerPixel ${initialSpp} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${initialSpp} in your zoomLevels array.`
2253
+ `EditorEngine: samplesPerPixel ${initialSpp} is not in zoomLevels [${this._zoomLevels.join(", ")}]. Either pass a samplesPerPixel value that exists in zoomLevels, or include ${initialSpp} in your zoomLevels array.`
2247
2254
  );
2248
2255
  }
2249
2256
  this._zoomIndex = zoomIndex;
@@ -2259,7 +2266,7 @@ var PlaylistEngine = class {
2259
2266
  this._arrangement = asArrangementImpl(options.arrangement);
2260
2267
  if (options.undoLimit !== void 0) {
2261
2268
  console.warn(
2262
- "[waveform-playlist] PlaylistEngine: undoLimit is ignored when an arrangement is passed. Set it on createArrangement({ undoLimit })."
2269
+ "[waveform-playlist] EditorEngine: undoLimit is ignored when an arrangement is passed. Set it on createArrangement({ undoLimit })."
2263
2270
  );
2264
2271
  }
2265
2272
  } else {
@@ -2808,12 +2815,12 @@ var PlaylistEngine = class {
2808
2815
  function asArrangementImpl(arrangement) {
2809
2816
  if (isArrangement(arrangement)) return arrangement;
2810
2817
  throw new Error(
2811
- "[waveform-playlist] PlaylistEngine: the `arrangement` option must be an arrangement made by createArrangement()."
2818
+ "[waveform-playlist] EditorEngine: the `arrangement` option must be an arrangement made by createArrangement()."
2812
2819
  );
2813
2820
  }
2814
2821
  // Annotate the CommonJS export names for ESM import in node:
2815
2822
  0 && (module.exports = {
2816
- PlaylistEngine,
2823
+ EditorEngine,
2817
2824
  attachDecodeContext,
2818
2825
  calculateDuration,
2819
2826
  calculateSplitPoint,