@dawcore/components 0.0.38 → 0.0.39-next.0

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/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
- import { AnnotationData, AnnotationShortcutMap, MidiNoteData, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
3
+ import { AnnotationData, AnnotationShortcutMap, MidiNoteData, TrackKind, RenderMode, SpectrogramConfig, Peaks, Bits, FadeType, PeakData, MeterEntry, SnapTo, ColorMapValue, ClipTrack, KeyboardShortcut } from '@waveform-playlist/core';
4
4
  import WaveformData from 'waveform-data';
5
5
  import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
6
6
  import { MidiLoadOptions, MidiLoadResult } from '@dawcore/midi';
@@ -222,47 +222,6 @@ declare global {
222
222
  }
223
223
  }
224
224
 
225
- /** Range/display metadata for one effect parameter. */
226
- interface EffectParamDef {
227
- min: number;
228
- max: number;
229
- step?: number;
230
- /** 's', 'ms', 'Hz', 'dB', '%' … */
231
- unit?: string;
232
- }
233
- /**
234
- * A live, wired effect. `input`/`output` are the chain attachment points
235
- * (the same node for single-node effects). `applyParams` updates AudioParams
236
- * in place — the chain never rebuilds for parameter changes.
237
- */
238
- interface EffectInstance {
239
- input: AudioNode;
240
- output: AudioNode;
241
- applyParams: (params: Record<string, number>) => void;
242
- dispose?: () => void;
243
- /** Serializable snapshot of plugin-internal state (WAM getState). */
244
- getState?: () => Promise<unknown>;
245
- /** Builds the plugin's own GUI element (WAM createGui). GUI lifecycle is
246
- * independent of audio — hiding/destroying a GUI never stops processing. */
247
- createGui?: () => Promise<HTMLElement>;
248
- /** Releases a GUI element previously built by `createGui` (WAM destroyGui). */
249
- destroyGui?: (gui: HTMLElement) => void;
250
- /** Parameter metadata for the generic fallback panel (WAM getParameterInfo). */
251
- getParameterInfo?: () => Promise<unknown>;
252
- }
253
- /** A registered effect type. `create` must work on any BaseAudioContext so
254
- * the same definitions serve offline rendering. */
255
- interface EffectDefinition {
256
- label: string;
257
- category: string;
258
- defaults: Record<string, number>;
259
- params: Record<string, EffectParamDef>;
260
- /** Name of the wet/dry param, when the effect has one. Bypass zeroes it
261
- * (storing the original); effects without one are bypassed by
262
- * disconnection. */
263
- wetParam?: string;
264
- create: (audioContext: BaseAudioContext, params: Record<string, number>) => EffectInstance;
265
- }
266
225
  /** Public, serializable view of one chain entry. */
267
226
  interface EffectState {
268
227
  id: string;
@@ -304,12 +263,6 @@ type SerializedEffectEntry = {
304
263
  * playback; restore ignores the flag and retries the URL/DSP. */
305
264
  placeholder?: true;
306
265
  };
307
- /** Result of creating an effect via the registry. */
308
- interface CreatedEffect {
309
- instance: EffectInstance;
310
- params: Record<string, number>;
311
- wetParam?: string;
312
- }
313
266
 
314
267
  declare class DawTrackElement extends LitElement {
315
268
  src: string;
@@ -318,6 +271,14 @@ declare class DawTrackElement extends LitElement {
318
271
  pan: number;
319
272
  muted: boolean;
320
273
  soloed: boolean;
274
+ /**
275
+ * What the track holds: `'audio'` (default) or `'midi'`. Every `<daw-clip>`
276
+ * child must be of this kind (#756). Set it before the track connects:
277
+ * the editor reads it when it loads the track.
278
+ */
279
+ get kind(): TrackKind;
280
+ set kind(value: TrackKind);
281
+ private _kind;
321
282
  get renderMode(): RenderMode;
322
283
  set renderMode(value: RenderMode);
323
284
  private _renderMode;
@@ -396,6 +357,10 @@ declare class DawWaveformElement extends LitElement {
396
357
  barGap: number;
397
358
  /** Draw bars with pill-shaped rounded caps (radius barWidth/2). */
398
359
  roundedBars: boolean;
360
+ /** Linear gain applied to the DRAWN bars (clamped to the channel height).
361
+ * Display-only — peaks are untouched, so changing it never regenerates
362
+ * them. The editor feeds it a clip's gain under `gain-scaled-waveforms`. */
363
+ gain: number;
399
364
  /** Visible viewport start in pixels (relative to timeline origin). */
400
365
  visibleStart: number;
401
366
  /** Visible viewport end in pixels (relative to timeline origin). */
@@ -582,6 +547,10 @@ interface TrackDescriptor {
582
547
  pan: number;
583
548
  muted: boolean;
584
549
  soloed: boolean;
550
+ /** What the track holds: audio clips or MIDI clips, never both (#756). */
551
+ kind: TrackKind;
552
+ /** How an audio track is drawn. A MIDI track is drawn as a piano roll from
553
+ * its `kind`; its `renderMode` is always `'waveform'` and means nothing. */
585
554
  renderMode: TrackRenderMode;
586
555
  spectrogramConfig?: SpectrogramConfig | null;
587
556
  clips: ClipDescriptor[];
@@ -622,12 +591,17 @@ interface DomClipDescriptor extends BaseClipDescriptor {
622
591
  }
623
592
  /**
624
593
  * A clip descriptor synthesized from a non-DOM source — file drops, the
625
- * `<daw-track src>` shorthand fallback, or recording-clip insertion. No
626
- * `clipId` because there's no DOM element to align with; the engine
627
- * generates its own id at clip-creation time.
594
+ * `<daw-track src>` shorthand fallback, or recording-clip insertion. There
595
+ * is no DOM element to align with; the engine generates its own id at
596
+ * clip-creation time.
597
+ *
598
+ * `clipId` is that engine clip id when the editor knows it at descriptor
599
+ * creation — currently recorded takes (#659). Pass it to
600
+ * `editor.updateClip()` / `removeClip()` to address the clip.
628
601
  */
629
602
  interface DropClipDescriptor extends BaseClipDescriptor {
630
603
  kind: 'drop';
604
+ clipId?: string;
631
605
  }
632
606
  type ClipDescriptor = DomClipDescriptor | DropClipDescriptor;
633
607
  /**
@@ -646,14 +620,20 @@ interface TrackConfig {
646
620
  pan?: number;
647
621
  muted?: boolean;
648
622
  soloed?: boolean;
623
+ /**
624
+ * What the track holds. Default `'audio'`, or `'midi'` when `midi` is given.
625
+ * Every clip must be of this kind: a clip of the other kind is not added and
626
+ * is reported through `daw-clip-error`. Creation-only: ignored by `updateTrack`.
627
+ */
628
+ kind?: TrackKind;
629
+ /** How an audio track is drawn. Ignored for a MIDI track (a piano roll). */
649
630
  renderMode?: TrackRenderMode;
650
631
  spectrogramConfig?: SpectrogramConfig | null;
651
632
  clips?: ClipConfig[];
652
633
  /**
653
- * Convenience: creates a single piano-roll `<daw-clip>` child with these
654
- * notes and sets `render-mode="piano-roll"` on the track. Equivalent to
655
- * passing `{ renderMode: 'piano-roll', clips: [{ midiNotes, midiChannel, midiProgram }] }`.
656
- * An explicit `renderMode` takes precedence over the inferred `'piano-roll'`.
634
+ * Convenience: makes the track a MIDI track (`kind: 'midi'`) with a single
635
+ * `<daw-clip>` child holding these notes. Equivalent to passing
636
+ * `{ kind: 'midi', clips: [{ midiNotes, midiChannel, midiProgram }] }`.
657
637
  *
658
638
  * Creation-only — ignored by `updateTrack`. To modify notes after the
659
639
  * track is built, use `editor.updateClip(trackId, clipId, { midiNotes })` or
@@ -948,7 +928,7 @@ interface RecordingHost extends ReactiveControllerHost {
948
928
  _engine?: {
949
929
  setTrackMute(trackId: string, muted: boolean): void;
950
930
  getState(): {
951
- tracks: Array<{
931
+ tracks: ReadonlyArray<{
952
932
  id: string;
953
933
  muted: boolean;
954
934
  }>;
@@ -1223,6 +1203,17 @@ interface DawRecordingCompleteDetail {
1223
1203
  durationSamples: number;
1224
1204
  offsetSamples: number;
1225
1205
  }
1206
+ /** Follows `daw-recording-complete` once the take's clip is in the engine.
1207
+ * NOT guaranteed after every complete — it is skipped when the consumer
1208
+ * cancelled `daw-recording-complete`, when peak generation for the take
1209
+ * failed (`daw-error` with `operation: 'recording-peaks'` fires instead),
1210
+ * when the track was removed meanwhile, and on a disconnected editor.
1211
+ * Don't await it without a fallback. */
1212
+ interface DawRecordingClipAddDetail {
1213
+ trackId: string;
1214
+ /** Engine clip id — pass to `editor.updateClip()` / `removeClip()`. */
1215
+ clipId: string;
1216
+ }
1226
1217
  interface DawRecordingErrorDetail {
1227
1218
  trackId: string;
1228
1219
  error: unknown;
@@ -1367,6 +1358,7 @@ interface DawEventMap {
1367
1358
  'daw-track-remove': CustomEvent<DawTrackRemoveDetail>;
1368
1359
  'daw-recording-start': CustomEvent<DawRecordingStartDetail>;
1369
1360
  'daw-recording-complete': CustomEvent<DawRecordingCompleteDetail>;
1361
+ 'daw-recording-clip-add': CustomEvent<DawRecordingClipAddDetail>;
1370
1362
  'daw-recording-error': CustomEvent<DawRecordingErrorDetail>;
1371
1363
  'daw-recording-pause': CustomEvent<DawRecordingPauseDetail>;
1372
1364
  'daw-recording-resume': CustomEvent<DawRecordingResumeDetail>;
@@ -1497,6 +1489,10 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1497
1489
  roundedBars: boolean;
1498
1490
  fileDrop: boolean;
1499
1491
  clipHeaders: boolean;
1492
+ /** Scale each clip's drawn waveform by its `gain` (clamped to the channel
1493
+ * height), so levelled clips look the way they sound. Off by default:
1494
+ * waveforms show source level. Draw-time only — no peak regeneration. */
1495
+ gainScaledWaveforms: boolean;
1500
1496
  clipHeaderHeight: number;
1501
1497
  interactiveClips: boolean;
1502
1498
  /**
@@ -1609,6 +1605,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1609
1605
  private _adapterConsumedByDispose;
1610
1606
  private _effectsManager;
1611
1607
  private get _effects();
1608
+ /**
1609
+ * Run a registered effect type's async `prepare` hook (e.g. an
1610
+ * `audioWorklet.addModule`) on this editor's audio context. Await it before
1611
+ * the synchronous `addEffect`/`addTrackEffect` for effect types that define
1612
+ * one; `setEffectsState()` and `exportAudio()` run it themselves. Idempotent
1613
+ * per context, and a no-op for types without a hook.
1614
+ */
1615
+ prepareEffect(type: string): Promise<void>;
1612
1616
  /** Master effects chain — inserted between the master bus and the destination. */
1613
1617
  addEffect(type: string, params?: Record<string, number>): string;
1614
1618
  removeEffect(effectId: string): void;
@@ -1800,7 +1804,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1800
1804
  * ghost that even removeTrack() can't clean (no element, no engine
1801
1805
  * entry). Never prunes tracks that are mid-load or element-backed —
1802
1806
  * their descriptors legitimately precede their engine entries. */
1803
- _reconcileDescriptorsWithEngineTracks(tracks: ClipTrack[]): void;
1807
+ _reconcileDescriptorsWithEngineTracks(tracks: readonly ClipTrack[]): void;
1808
+ /** Prune id-bearing drop descriptors the engine no longer has, and refresh
1809
+ * the rest from their engine clip. Returns the SAME array when nothing
1810
+ * changed, so an unchanged track never triggers a re-render. */
1811
+ private _reconcileIdentifiedDropClips;
1804
1812
  private static _CONTROL_PROPS;
1805
1813
  private _onTrackControl;
1806
1814
  private _onTrackRemoveRequest;
@@ -1862,6 +1870,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1862
1870
  private _applyClipUpdate;
1863
1871
  private _removeClipFromTrack;
1864
1872
  private _readTrackDescriptor;
1873
+ /**
1874
+ * The error for a clip whose kind is not its track's (#756), or null. A clip
1875
+ * with no `src` is a MIDI clip (see _isMidiDescriptor).
1876
+ */
1877
+ private _clipKindError;
1865
1878
  private _loadTrack;
1866
1879
  _fetchAndDecode(src: string): Promise<AudioBuffer>;
1867
1880
  private _fetchPeaks;
@@ -2047,7 +2060,7 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
2047
2060
  * the observer's _syncEngineOrderToDom, which finds the orders equal and
2048
2061
  * no-ops — converges in one pass (write-only-on-change).
2049
2062
  */
2050
- _syncDomToEngineOrder(tracks: ClipTrack[]): void;
2063
+ _syncDomToEngineOrder(tracks: readonly ClipTrack[]): void;
2051
2064
  private _getOrderedTracks;
2052
2065
  render(): lit.TemplateResult<1>;
2053
2066
  }
@@ -2490,7 +2503,7 @@ interface PointerEngineContract {
2490
2503
  interface SplitEngineContract {
2491
2504
  getState(): {
2492
2505
  selectedTrackId: string | null;
2493
- tracks: ClipTrack[];
2506
+ tracks: readonly ClipTrack[];
2494
2507
  };
2495
2508
  splitClip(trackId: string, clipId: string, atSample: number): void;
2496
2509
  }
@@ -2514,9 +2527,4 @@ interface SplitHost {
2514
2527
  */
2515
2528
  declare function splitAtPlayhead(host: SplitHost): boolean;
2516
2529
 
2517
- declare function registerEffect(type: string, definition: EffectDefinition): void;
2518
- /** A copy — mutating the returned map does not affect the registry. */
2519
- declare function getEffectDefinitions(): Map<string, EffectDefinition>;
2520
- declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
2521
-
2522
- export { ANNOTATION_LANE_HEIGHT, AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawAnnotationConnectedDetail, DawAnnotationElement, DawAnnotationListElement, type DawAnnotationSelectDetail, type DawAnnotationTrackConnectedDetail, DawAnnotationTrackElement, type DawAnnotationUpdateDetail, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayerElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
2530
+ export { ANNOTATION_LANE_HEIGHT, AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawAnnotationConnectedDetail, DawAnnotationElement, DawAnnotationListElement, type DawAnnotationSelectDetail, type DawAnnotationTrackConnectedDetail, DawAnnotationTrackElement, type DawAnnotationUpdateDetail, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayerElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingClipAddDetail, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, formatDisplayTime, isDomClip, isTimeDisplayFormat, parseDisplayTime, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };