@dawcore/components 0.0.39-next.3 → 0.0.39-next.4

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
@@ -9,9 +9,9 @@ Framework-agnostic Web Components for multi-track audio editing. Drop `<daw-edit
9
9
  - **Canvas waveforms** — Chunked rendering with virtual scrolling for large timelines
10
10
  - **Drag interactions** — Move clips, trim boundaries, split at playhead
11
11
  - **Keyboard shortcuts** — Play/pause, split, undo/redo via `<daw-keyboard-shortcuts>`
12
- - **Undo/redo** — Full transaction-based undo with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z
12
+ - **Undo/redo** — Full transaction-based undo with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z; mixer moves are undo steps too (one per slider drag, click, attribute update or `updateTrack` call)
13
13
  - **File drop** — Drag audio files onto the editor to add tracks (enable with the `file-drop` attribute)
14
- - **Recording** — Live mic recording with waveform preview (full clip chrome incl. header while capturing), pause/resume, cancelable clip creation; takes land at the playhead and replace overlapped clip content (punch-in), the recorded-over track is transiently muted during the take, and the end-of-timeline auto-stop is suppressed so takes run past existing audio
14
+ - **Recording** — Live mic recording with waveform preview (full clip chrome incl. header while capturing), pause/resume, cancelable clip creation; takes land at the playhead and replace overlapped clip content (punch-in), the recorded-over track plays muted during the take, and the end-of-timeline auto-stop is suppressed so takes run past existing audio
15
15
  - **Pre-computed peaks** — Instant waveform rendering from `.dat` files before audio decodes
16
16
  - **MIDI tracks** — Declarative or programmatic MIDI clips render as piano-roll. Playback via the Tone.js adapter. See [MIDI Tracks](#midi-tracks).
17
17
  - **MIDI file loading** — `editor.loadMidi(urlOrFile)` parses a `.mid` file into piano-roll tracks via the optional `@dawcore/midi` peer
@@ -394,7 +394,7 @@ A recorded take has no `<daw-clip>` element; its engine clip id is the `clipId`
394
394
 
395
395
  `daw-recording-clip-add` is not guaranteed after every `daw-recording-complete`: it is skipped when you cancel the complete event, when peak generation for the take fails (`daw-error` with `operation: 'recording-peaks'`), and when the track was removed in the meantime.
396
396
 
397
- During a take the editor shows the live preview with full clip chrome (header label from `RecordingOptions.clipName`, default "Recording…"), transiently mutes the recorded track (punch-in replaces whatever the take overlaps, so the doomed material never plays under the overdub — the track's Mute control is untouched and the previous state is restored when the session ends), and suppresses the end-of-timeline auto-stop so the take can run past existing audio.
397
+ During a take the editor shows the live preview with full clip chrome (header label from `RecordingOptions.clipName`, default "Recording…"), mutes the recorded track for the take (punch-in replaces whatever the take overlaps, so the doomed material never plays under the overdub: the track plays muted, its controls and `editor.tracks` show it muted, and an `exportAudio()` during the take leaves it out; the take's mute is not an undo step and does not change the track's own mute, so a mute changed during the take stays after it), and suppresses the end-of-timeline auto-stop so the take can run past existing audio.
398
398
 
399
399
  ## Single-Track Player
400
400
 
@@ -508,7 +508,7 @@ Methods:
508
508
 
509
509
  ### `<daw-track>`
510
510
 
511
- Declarative track data. Attributes: `src`, `name`, `volume`, `pan`, `muted`, `soloed`, `kind` (`'audio' | 'midi'`, default `'audio'`: what the track holds; set it before the track is added), `render-mode` (`'waveform' | 'spectrogram'`, default `'waveform'`: how an audio track is drawn; a MIDI track is always a piano roll). JS property: `spectrogramConfig` (per-track spectrogram override). Also exposes the per-track effects API (see [Effects](#effects)).
511
+ Declarative track data. Attributes: `src`, `name`, `volume`, `pan`, `muted`, `soloed`, `kind` (`'audio' | 'midi'`, default `'audio'`: what the track holds; set it before the track is added), `render-mode` (`'waveform' | 'spectrogram'`, default `'waveform'`: how an audio track is drawn; a MIDI track is always a piano roll). JS property: `spectrogramConfig` (per-track spectrogram override). Also exposes the per-track effects API (see [Effects](#effects)). Fires `daw-track-update` `{ trackId, changed }` after a property changes (`changed` names them). A `volume`, `pan`, `muted` or `soloed` change after the track has loaded is one undo step per update; while it loads, the change sets the values it enters with. The editor does not write the element back after an Undo: read the restored mix from `editor.tracks`. Every track load clears the undo history (a known limit, #848), so steps made while a track is still loading cannot be undone once it has finished.
512
512
 
513
513
  ### `<daw-clip>`
514
514
 
@@ -524,7 +524,7 @@ Container that resolves target editor. Children: `<daw-play-button>`, `<daw-paus
524
524
 
525
525
  ### `<daw-track-controls>`
526
526
 
527
- Per-track UI for volume, pan, mute, solo. Receives state from editor, dispatches `daw-track-control` and `daw-track-remove` events.
527
+ Per-track UI for volume, pan, mute, solo. Draws the arrangement's mix (so it follows Undo and Redo), dispatches `daw-track-control` and `daw-track-remove` events. One slider drag or key press is one undo step, each Mute or Solo click is one. Keyboard Undo does not fire while a slider has focus.
528
528
 
529
529
  ### `<daw-keyboard-shortcuts>`
530
530
 
package/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
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
- import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
5
+ import { TrackMixerValues, PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
6
6
  import { MidiLoadOptions, MidiLoadResult } from '@dawcore/midi';
7
7
  import { ClipRegistration, CanvasRegistration, ViewportState } from '@dawcore/spectrogram';
8
8
 
@@ -555,6 +555,14 @@ interface TrackDescriptor {
555
555
  spectrogramConfig?: SpectrogramConfig | null;
556
556
  clips: ClipDescriptor[];
557
557
  }
558
+ /** The mixer fields of a `TrackDescriptor`. */
559
+ type TrackMixFields = 'volume' | 'pan' | 'muted' | 'soloed';
560
+ /**
561
+ * What `<daw-editor>` stores per track (internal, not exported from the
562
+ * package): a `TrackDescriptor` without its mix. The mix is the arrangement's
563
+ * (#843); `editor.tracks` fills the four fields in from it.
564
+ */
565
+ type StoredTrackDescriptor = Omit<TrackDescriptor, TrackMixFields>;
558
566
  /** A `TrackDescriptor` plus its `trackId` — the shape returned by `editor.tracks`
559
567
  * so consumers can map a track's name to the `trackId` the per-track APIs
560
568
  * (`addTrackEffect`, `removeTrack`, `updateTrack`, …) are keyed by. */
@@ -767,19 +775,35 @@ declare class DawTrackControlsElement extends LitElement {
767
775
  volume: number;
768
776
  pan: number;
769
777
  muted: boolean;
778
+ /** A take is recording onto the track: it plays muted, and the M button is disabled. */
779
+ recording: boolean;
770
780
  soloed: boolean;
771
781
  /** Show the reorder grip + move up/down buttons (set by the editor from
772
782
  * its track-reordering attribute). */
773
783
  reorderable: boolean;
774
784
  trackIndex: number;
775
785
  trackCount: number;
786
+ /**
787
+ * One gesture per slider (#843): the `daw-track-control` events of one
788
+ * drag, or of one key press (a held key included), carry the same
789
+ * `gesture` id, and the editor makes them one undo step. Each gesture is
790
+ * attached to its range input while the element is connected.
791
+ */
792
+ private readonly _volumeGesture;
793
+ private readonly _panGesture;
794
+ private _detachGestures;
776
795
  static styles: lit.CSSResult;
796
+ connectedCallback(): void;
797
+ disconnectedCallback(): void;
798
+ private _attachGestures;
799
+ private _detachAllGestures;
777
800
  protected firstUpdated(): void;
778
801
  private _onVolumeInput;
779
802
  private _onPanInput;
780
803
  private _onMuteClick;
781
804
  private _onSoloClick;
782
805
  private _onRemoveClick;
806
+ /** `gesture` for the sliders only: each mute or solo click is a step. */
783
807
  private _dispatchControl;
784
808
  private _dispatchReorder;
785
809
  private _onMoveUp;
@@ -880,9 +904,6 @@ interface RecordingSession {
880
904
  readonly latencySamples: number;
881
905
  /** Display name for the take (preview header + finalized clip name). */
882
906
  readonly clipName?: string;
883
- /** Pre-session mute state of the armed track — restored when the session
884
- * ends. null = mute never engaged (no engine on the host). */
885
- armedPrevMuted: boolean | null;
886
907
  readonly wasOverdub: boolean;
887
908
  /** Stored so it can be removed on stop/cleanup — not just when stream ends. */
888
909
  readonly _onTrackEnded: (() => void) | null;
@@ -921,18 +942,14 @@ interface RecordingHost extends ReactiveControllerHost {
921
942
  readonly shadowRoot: ShadowRoot | null;
922
943
  resolveAudioContextSampleRate(rate: number): void;
923
944
  _addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
924
- /** Structural view of the editor's engine for the armed-track transient
925
- * mute (punch-in replaces the overlapped content, so the recorded-over
926
- * track's existing material must not play under the take). Optional —
927
- * hosts without an engine skip the mute. */
945
+ /** Structural view of the editor's engine for the take's mute (#843):
946
+ * punch-in replaces the overlapped content, so the recorded-over track's
947
+ * existing material must not play under the take. The track a take is
948
+ * recording onto plays muted; that mute is outside the undo history and
949
+ * leaves the stored mute alone. Optional — hosts without an engine skip
950
+ * it. */
928
951
  _engine?: {
929
- setTrackMute(trackId: string, muted: boolean): void;
930
- getState(): {
931
- tracks: ReadonlyArray<{
932
- id: string;
933
- muted: boolean;
934
- }>;
935
- };
952
+ setTrackRecording(trackId: string, recording: boolean): void;
936
953
  } | null;
937
954
  play?(startTime?: number): Promise<void>;
938
955
  stop?(): void;
@@ -994,13 +1011,16 @@ declare class RecordingController implements ReactiveController {
994
1011
  private _removeTrackEndedListener;
995
1012
  private _dispatchRecordingError;
996
1013
  /** Shared teardown for finalize paths that end without a take (no data
997
- * captured / too short after latency compensation): restore the armed-track
998
- * mute, drop the session, and notify via daw-recording-error so record
999
- * buttons reset their state. */
1014
+ * captured / too short after latency compensation): clear the take's mute, drop
1015
+ * the session, and notify via daw-recording-error so record buttons reset
1016
+ * their state. */
1000
1017
  private _abandonFinalize;
1001
- /** Restore the armed track's pre-session mute state (idempotent — safe to
1002
- * call from both the finalize path and _cleanupSession). */
1003
- private _restoreArmedTrackMute;
1018
+ /** Clear the take's mute on the session's track, by its id. Each teardown
1019
+ * path calls this once, right before it drops the session from the map, so
1020
+ * a later path never reaches the same session; clearing an id that is not
1021
+ * set is a no-op in the engine. Another session's mute on another track is
1022
+ * left alone. */
1023
+ private _clearTakeMute;
1004
1024
  /** @param notifyError dispatch daw-recording-error after cleanup — used by
1005
1025
  * disposal paths that would otherwise discard the session silently. The
1006
1026
  * startRecording catch path passes false (it dispatches its own error). */
@@ -1167,6 +1187,17 @@ interface DawTrackConnectedDetail {
1167
1187
  interface DawTrackIdDetail {
1168
1188
  trackId: string;
1169
1189
  }
1190
+ interface DawTrackUpdateDetail {
1191
+ trackId: string;
1192
+ /**
1193
+ * The `<daw-track>` properties this update changed, by property name
1194
+ * (`'volume'`, `'pan'`, `'muted'`, `'soloed'`, `'src'`, `'name'`, `'kind'`,
1195
+ * `'renderMode'`, `'spectrogramConfig'`). The editor sends a mixer property
1196
+ * to the engine only when it is in this list, and one update is one undo
1197
+ * step (#843).
1198
+ */
1199
+ changed: readonly string[];
1200
+ }
1170
1201
  interface DawTrackErrorDetail {
1171
1202
  trackId: string;
1172
1203
  error: unknown;
@@ -1188,6 +1219,12 @@ interface DawTrackControlDetail {
1188
1219
  trackId: string;
1189
1220
  prop: string;
1190
1221
  value: number | boolean;
1222
+ /**
1223
+ * The slider's gesture id (#843): events of one volume or pan drag, or of
1224
+ * one key press, carry the same id and are one undo step. Mute and solo
1225
+ * send none: each click is a step.
1226
+ */
1227
+ gesture?: string;
1191
1228
  }
1192
1229
  interface DawTrackRemoveDetail {
1193
1230
  trackId: string;
@@ -1343,7 +1380,7 @@ interface DawEventMap {
1343
1380
  'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
1344
1381
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
1345
1382
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
1346
- 'daw-track-update': CustomEvent<DawTrackIdDetail>;
1383
+ 'daw-track-update': CustomEvent<DawTrackUpdateDetail>;
1347
1384
  'daw-track-ready': CustomEvent<DawTrackIdDetail>;
1348
1385
  'daw-track-removed': CustomEvent<DawTrackIdDetail>;
1349
1386
  'daw-track-error': CustomEvent<DawTrackErrorDetail>;
@@ -1586,7 +1623,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1586
1623
  get sampleRate(): number;
1587
1624
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
1588
1625
  _resolvedSampleRate: number | null;
1589
- _tracks: Map<string, TrackDescriptor>;
1626
+ /** Per-track descriptors, without the mix: the arrangement owns that (#843). */
1627
+ _tracks: Map<string, StoredTrackDescriptor>;
1628
+ /**
1629
+ * The mix of a track the engine does not hold yet: what it will enter the
1630
+ * arrangement with (from the `<daw-track>` element or the `addTrack` config,
1631
+ * changed by a control or `updateTrack` while it loads). Deleted once
1632
+ * `engine.getState().tracks` holds the id; read only through `_mixOf`.
1633
+ */
1634
+ _seedMix: Map<string, TrackMixerValues>;
1590
1635
  _engineTracks: Map<string, ClipTrack>;
1591
1636
  _peaksData: Map<string, PeakData>;
1592
1637
  _isPlaying: boolean;
@@ -1765,6 +1810,28 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1765
1810
  private get _emptyGridHeight();
1766
1811
  _setSelectedTrackId(trackId: string | null): void;
1767
1812
  get tracks(): TrackWithId[];
1813
+ /**
1814
+ * A track's mix, from its one owner: the arrangement (through
1815
+ * `_engineTracks`, which follows `mixerVersion`) for a track the engine
1816
+ * holds, the seed for one still on its way in (#843).
1817
+ */
1818
+ _mixOf(trackId: string): TrackMixerValues;
1819
+ /** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
1820
+ private _setSeedMix;
1821
+ private _deleteSeedMix;
1822
+ /**
1823
+ * Change one mixer field of a track: the seed while the track is loading
1824
+ * (not an undo step, nothing sent), else the engine's setter with
1825
+ * `options` (an undo step; changes with one `gesture` id are one step).
1826
+ */
1827
+ private _writeMix;
1828
+ /**
1829
+ * Change the given mixer fields of a track as ONE undo step (#843): all
1830
+ * of them carry one fresh gesture id. A field left out is not sent.
1831
+ */
1832
+ private _writeMixFields;
1833
+ /** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
1834
+ private _tracksForEngine;
1768
1835
  get selectedTrackId(): string | null;
1769
1836
  get selection(): {
1770
1837
  start: number;
@@ -1937,10 +2004,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1937
2004
  private _onTrackReorder;
1938
2005
  private _onTrackReorderGrab;
1939
2006
  /**
1940
- * Update reflected attributes on a track. For DOM-element tracks the changes
1941
- * are written to the `<daw-track>` element (which fires `daw-track-update`);
1942
- * for tracks without a DOM element (file drops) the descriptor and engine
1943
- * state are updated in place.
2007
+ * Update reflected attributes on a track. The mixer fields go to their
2008
+ * owner as one undo step (#843): the engine, or while the track is loading
2009
+ * the values it will enter with (not a step). For DOM-element tracks the
2010
+ * changes are also written to the `<daw-track>` element; for tracks
2011
+ * without a DOM element (file drops) the descriptor is updated in place.
1944
2012
  */
1945
2013
  updateTrack(trackId: string, partial: Partial<TrackConfig>): void;
1946
2014
  /**
@@ -2527,4 +2595,4 @@ interface SplitHost {
2527
2595
  */
2528
2596
  declare function splitAtPlayhead(host: SplitHost): boolean;
2529
2597
 
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 };
2598
+ 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, type DawTrackUpdateDetail, 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 };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues, ReactiveController, ReactiveControllerHost } from 'lit';
3
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
- import { PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
5
+ import { TrackMixerValues, PlayoutAdapter, PlaylistEngine } from '@waveform-playlist/engine';
6
6
  import { MidiLoadOptions, MidiLoadResult } from '@dawcore/midi';
7
7
  import { ClipRegistration, CanvasRegistration, ViewportState } from '@dawcore/spectrogram';
8
8
 
@@ -555,6 +555,14 @@ interface TrackDescriptor {
555
555
  spectrogramConfig?: SpectrogramConfig | null;
556
556
  clips: ClipDescriptor[];
557
557
  }
558
+ /** The mixer fields of a `TrackDescriptor`. */
559
+ type TrackMixFields = 'volume' | 'pan' | 'muted' | 'soloed';
560
+ /**
561
+ * What `<daw-editor>` stores per track (internal, not exported from the
562
+ * package): a `TrackDescriptor` without its mix. The mix is the arrangement's
563
+ * (#843); `editor.tracks` fills the four fields in from it.
564
+ */
565
+ type StoredTrackDescriptor = Omit<TrackDescriptor, TrackMixFields>;
558
566
  /** A `TrackDescriptor` plus its `trackId` — the shape returned by `editor.tracks`
559
567
  * so consumers can map a track's name to the `trackId` the per-track APIs
560
568
  * (`addTrackEffect`, `removeTrack`, `updateTrack`, …) are keyed by. */
@@ -767,19 +775,35 @@ declare class DawTrackControlsElement extends LitElement {
767
775
  volume: number;
768
776
  pan: number;
769
777
  muted: boolean;
778
+ /** A take is recording onto the track: it plays muted, and the M button is disabled. */
779
+ recording: boolean;
770
780
  soloed: boolean;
771
781
  /** Show the reorder grip + move up/down buttons (set by the editor from
772
782
  * its track-reordering attribute). */
773
783
  reorderable: boolean;
774
784
  trackIndex: number;
775
785
  trackCount: number;
786
+ /**
787
+ * One gesture per slider (#843): the `daw-track-control` events of one
788
+ * drag, or of one key press (a held key included), carry the same
789
+ * `gesture` id, and the editor makes them one undo step. Each gesture is
790
+ * attached to its range input while the element is connected.
791
+ */
792
+ private readonly _volumeGesture;
793
+ private readonly _panGesture;
794
+ private _detachGestures;
776
795
  static styles: lit.CSSResult;
796
+ connectedCallback(): void;
797
+ disconnectedCallback(): void;
798
+ private _attachGestures;
799
+ private _detachAllGestures;
777
800
  protected firstUpdated(): void;
778
801
  private _onVolumeInput;
779
802
  private _onPanInput;
780
803
  private _onMuteClick;
781
804
  private _onSoloClick;
782
805
  private _onRemoveClick;
806
+ /** `gesture` for the sliders only: each mute or solo click is a step. */
783
807
  private _dispatchControl;
784
808
  private _dispatchReorder;
785
809
  private _onMoveUp;
@@ -880,9 +904,6 @@ interface RecordingSession {
880
904
  readonly latencySamples: number;
881
905
  /** Display name for the take (preview header + finalized clip name). */
882
906
  readonly clipName?: string;
883
- /** Pre-session mute state of the armed track — restored when the session
884
- * ends. null = mute never engaged (no engine on the host). */
885
- armedPrevMuted: boolean | null;
886
907
  readonly wasOverdub: boolean;
887
908
  /** Stored so it can be removed on stop/cleanup — not just when stream ends. */
888
909
  readonly _onTrackEnded: (() => void) | null;
@@ -921,18 +942,14 @@ interface RecordingHost extends ReactiveControllerHost {
921
942
  readonly shadowRoot: ShadowRoot | null;
922
943
  resolveAudioContextSampleRate(rate: number): void;
923
944
  _addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
924
- /** Structural view of the editor's engine for the armed-track transient
925
- * mute (punch-in replaces the overlapped content, so the recorded-over
926
- * track's existing material must not play under the take). Optional —
927
- * hosts without an engine skip the mute. */
945
+ /** Structural view of the editor's engine for the take's mute (#843):
946
+ * punch-in replaces the overlapped content, so the recorded-over track's
947
+ * existing material must not play under the take. The track a take is
948
+ * recording onto plays muted; that mute is outside the undo history and
949
+ * leaves the stored mute alone. Optional — hosts without an engine skip
950
+ * it. */
928
951
  _engine?: {
929
- setTrackMute(trackId: string, muted: boolean): void;
930
- getState(): {
931
- tracks: ReadonlyArray<{
932
- id: string;
933
- muted: boolean;
934
- }>;
935
- };
952
+ setTrackRecording(trackId: string, recording: boolean): void;
936
953
  } | null;
937
954
  play?(startTime?: number): Promise<void>;
938
955
  stop?(): void;
@@ -994,13 +1011,16 @@ declare class RecordingController implements ReactiveController {
994
1011
  private _removeTrackEndedListener;
995
1012
  private _dispatchRecordingError;
996
1013
  /** Shared teardown for finalize paths that end without a take (no data
997
- * captured / too short after latency compensation): restore the armed-track
998
- * mute, drop the session, and notify via daw-recording-error so record
999
- * buttons reset their state. */
1014
+ * captured / too short after latency compensation): clear the take's mute, drop
1015
+ * the session, and notify via daw-recording-error so record buttons reset
1016
+ * their state. */
1000
1017
  private _abandonFinalize;
1001
- /** Restore the armed track's pre-session mute state (idempotent — safe to
1002
- * call from both the finalize path and _cleanupSession). */
1003
- private _restoreArmedTrackMute;
1018
+ /** Clear the take's mute on the session's track, by its id. Each teardown
1019
+ * path calls this once, right before it drops the session from the map, so
1020
+ * a later path never reaches the same session; clearing an id that is not
1021
+ * set is a no-op in the engine. Another session's mute on another track is
1022
+ * left alone. */
1023
+ private _clearTakeMute;
1004
1024
  /** @param notifyError dispatch daw-recording-error after cleanup — used by
1005
1025
  * disposal paths that would otherwise discard the session silently. The
1006
1026
  * startRecording catch path passes false (it dispatches its own error). */
@@ -1167,6 +1187,17 @@ interface DawTrackConnectedDetail {
1167
1187
  interface DawTrackIdDetail {
1168
1188
  trackId: string;
1169
1189
  }
1190
+ interface DawTrackUpdateDetail {
1191
+ trackId: string;
1192
+ /**
1193
+ * The `<daw-track>` properties this update changed, by property name
1194
+ * (`'volume'`, `'pan'`, `'muted'`, `'soloed'`, `'src'`, `'name'`, `'kind'`,
1195
+ * `'renderMode'`, `'spectrogramConfig'`). The editor sends a mixer property
1196
+ * to the engine only when it is in this list, and one update is one undo
1197
+ * step (#843).
1198
+ */
1199
+ changed: readonly string[];
1200
+ }
1170
1201
  interface DawTrackErrorDetail {
1171
1202
  trackId: string;
1172
1203
  error: unknown;
@@ -1188,6 +1219,12 @@ interface DawTrackControlDetail {
1188
1219
  trackId: string;
1189
1220
  prop: string;
1190
1221
  value: number | boolean;
1222
+ /**
1223
+ * The slider's gesture id (#843): events of one volume or pan drag, or of
1224
+ * one key press, carry the same id and are one undo step. Mute and solo
1225
+ * send none: each click is a step.
1226
+ */
1227
+ gesture?: string;
1191
1228
  }
1192
1229
  interface DawTrackRemoveDetail {
1193
1230
  trackId: string;
@@ -1343,7 +1380,7 @@ interface DawEventMap {
1343
1380
  'daw-time-format-change': CustomEvent<DawTimeFormatChangeDetail>;
1344
1381
  'daw-track-select': CustomEvent<DawTrackSelectDetail>;
1345
1382
  'daw-track-connected': CustomEvent<DawTrackConnectedDetail>;
1346
- 'daw-track-update': CustomEvent<DawTrackIdDetail>;
1383
+ 'daw-track-update': CustomEvent<DawTrackUpdateDetail>;
1347
1384
  'daw-track-ready': CustomEvent<DawTrackIdDetail>;
1348
1385
  'daw-track-removed': CustomEvent<DawTrackIdDetail>;
1349
1386
  'daw-track-error': CustomEvent<DawTrackErrorDetail>;
@@ -1586,7 +1623,15 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1586
1623
  get sampleRate(): number;
1587
1624
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
1588
1625
  _resolvedSampleRate: number | null;
1589
- _tracks: Map<string, TrackDescriptor>;
1626
+ /** Per-track descriptors, without the mix: the arrangement owns that (#843). */
1627
+ _tracks: Map<string, StoredTrackDescriptor>;
1628
+ /**
1629
+ * The mix of a track the engine does not hold yet: what it will enter the
1630
+ * arrangement with (from the `<daw-track>` element or the `addTrack` config,
1631
+ * changed by a control or `updateTrack` while it loads). Deleted once
1632
+ * `engine.getState().tracks` holds the id; read only through `_mixOf`.
1633
+ */
1634
+ _seedMix: Map<string, TrackMixerValues>;
1590
1635
  _engineTracks: Map<string, ClipTrack>;
1591
1636
  _peaksData: Map<string, PeakData>;
1592
1637
  _isPlaying: boolean;
@@ -1765,6 +1810,28 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1765
1810
  private get _emptyGridHeight();
1766
1811
  _setSelectedTrackId(trackId: string | null): void;
1767
1812
  get tracks(): TrackWithId[];
1813
+ /**
1814
+ * A track's mix, from its one owner: the arrangement (through
1815
+ * `_engineTracks`, which follows `mixerVersion`) for a track the engine
1816
+ * holds, the seed for one still on its way in (#843).
1817
+ */
1818
+ _mixOf(trackId: string): TrackMixerValues;
1819
+ /** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
1820
+ private _setSeedMix;
1821
+ private _deleteSeedMix;
1822
+ /**
1823
+ * Change one mixer field of a track: the seed while the track is loading
1824
+ * (not an undo step, nothing sent), else the engine's setter with
1825
+ * `options` (an undo step; changes with one `gesture` id are one step).
1826
+ */
1827
+ private _writeMix;
1828
+ /**
1829
+ * Change the given mixer fields of a track as ONE undo step (#843): all
1830
+ * of them carry one fresh gesture id. A field left out is not sent.
1831
+ */
1832
+ private _writeMixFields;
1833
+ /** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
1834
+ private _tracksForEngine;
1768
1835
  get selectedTrackId(): string | null;
1769
1836
  get selection(): {
1770
1837
  start: number;
@@ -1937,10 +2004,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
1937
2004
  private _onTrackReorder;
1938
2005
  private _onTrackReorderGrab;
1939
2006
  /**
1940
- * Update reflected attributes on a track. For DOM-element tracks the changes
1941
- * are written to the `<daw-track>` element (which fires `daw-track-update`);
1942
- * for tracks without a DOM element (file drops) the descriptor and engine
1943
- * state are updated in place.
2007
+ * Update reflected attributes on a track. The mixer fields go to their
2008
+ * owner as one undo step (#843): the engine, or while the track is loading
2009
+ * the values it will enter with (not a step). For DOM-element tracks the
2010
+ * changes are also written to the `<daw-track>` element; for tracks
2011
+ * without a DOM element (file drops) the descriptor is updated in place.
1944
2012
  */
1945
2013
  updateTrack(trackId: string, partial: Partial<TrackConfig>): void;
1946
2014
  /**
@@ -2527,4 +2595,4 @@ interface SplitHost {
2527
2595
  */
2528
2596
  declare function splitAtPlayhead(host: SplitHost): boolean;
2529
2597
 
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 };
2598
+ 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, type DawTrackUpdateDetail, 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 };