@dawcore/components 0.0.32 → 0.0.34
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 +63 -8
- package/dist/index.d.mts +191 -13
- package/dist/index.d.ts +191 -13
- package/dist/index.js +811 -182
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +812 -183
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Framework-agnostic Web Components for multi-track audio editing. Drop `<daw-edit
|
|
|
11
11
|
- **Keyboard shortcuts** — Play/pause, split, undo/redo via `<daw-keyboard-shortcuts>`
|
|
12
12
|
- **Undo/redo** — Full transaction-based undo with Cmd/Ctrl+Z and Cmd/Ctrl+Shift+Z
|
|
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, pause/resume, cancelable clip creation
|
|
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
|
|
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
|
|
@@ -21,6 +21,8 @@ Framework-agnostic Web Components for multi-track audio editing. Drop `<daw-edit
|
|
|
21
21
|
- **Effect GUIs and persistence** — Mount plugin GUIs into your own panels; snapshot and restore whole chains. See [Effect GUIs](#effect-guis) and [Effects Persistence](#effects-persistence).
|
|
22
22
|
- **Offline export** — `editor.exportAudio()` renders the session (clips, mix, all effect chains) to an `AudioBuffer`. See [Offline Export](#offline-export).
|
|
23
23
|
- **Transport access** — Tempo, metronome, count-in, meter, effects via `@dawcore/transport`
|
|
24
|
+
- **Lightweight single-track player** — `<daw-player>` wraps `@waveform-playlist/media-element-playout` (`HTMLMediaElement`, no adapter/AudioContext/PlaylistEngine) for podcast/audiobook-style playback with pitch-preserving rate control (0.25×–4×). See [Single-Track Player](#single-track-player).
|
|
25
|
+
- **Time display & format** — `<daw-time-display>` / `<daw-time-format>` show and switch the playback clock (`hh:mm:ss.sss`, `hh:mm:ss`, `seconds`) for any transport target.
|
|
24
26
|
- **CSS theming** — Dark mode by default, fully customizable via CSS custom properties
|
|
25
27
|
- **Native Web Audio** — Uses `@dawcore/transport` for playback scheduling. No Tone.js dependency.
|
|
26
28
|
|
|
@@ -211,7 +213,7 @@ localStorage.setItem('master-fx', JSON.stringify(saved));
|
|
|
211
213
|
await editor.setEffectsState(JSON.parse(localStorage.getItem('master-fx')));
|
|
212
214
|
```
|
|
213
215
|
|
|
214
|
-
WAM entries carry the plugin's own `getState()` snapshot, reapplied on restore. Faust entries (added with `addFaustEffect`) persist their DSP source instead of a URL — `{ kind: 'wam', faustDsp, faustName, bypassed, state }` — and are recompiled in the browser on restore. If a saved plugin URL is unreachable (or a saved Faust source no longer compiles), the restore **continues**: the entry becomes a bypassed passthrough placeholder at its saved position (a `daw-effect-error` event fires with `{effectId, url?, source?, message}`), and its saved state is retained so re-serializing round-trips it for a later retry.
|
|
216
|
+
WAM entries carry the plugin's own `getState()` snapshot, reapplied on restore. Faust entries (added with `addFaustEffect`) persist their DSP source instead of a URL — `{ kind: 'wam', faustDsp, faustName, bypassed, state }` — and are recompiled in the browser on restore. If a saved plugin URL is unreachable (or a saved Faust source no longer compiles), the restore **continues**: the entry becomes a bypassed passthrough placeholder at its saved position (a `daw-effect-error` event fires with `{effectId, url?, source?, type?, message}`), and its saved state is retained so re-serializing round-trips it for a later retry. Failed **native** entries get the same treatment — a saved `registerEffect()` type that isn't re-registered on this page becomes a placeholder carrying its saved params instead of rejecting the whole restore. Placeholder entries re-serialize with `placeholder: true`; `exportAudio()` skips them (parity with live playback, which passes audio through them silently), and `setEffectsState` ignores the flag and retries normally.
|
|
215
217
|
|
|
216
218
|
## Transport Access
|
|
217
219
|
|
|
@@ -299,11 +301,11 @@ track.closeEffectGui(wamId); // hides — audio keeps processing, element stays
|
|
|
299
301
|
await track.openEffectGui(wamId, panel); // instant reopen, same element
|
|
300
302
|
```
|
|
301
303
|
|
|
302
|
-
The GUI is created lazily on first open and only destroyed (`destroyGui`) when the effect — or its track — is removed from the chain. Plugins without a GUI, and `native-*` effects, get a generic parameter panel (labeled sliders from the plugin's `getParameterInfo()` or the registry's params metadata) rendered by `@dawcore/wam`; slider edits apply live and dispatch `daw-effect-change` like any other parameter edit.
|
|
304
|
+
The GUI is created lazily on first open and only destroyed (`destroyGui`) when the effect — or its track — is removed from the chain. Plugins without a GUI, and `native-*` effects, get a generic parameter panel (labeled sliders from the plugin's `getParameterInfo()` or the registry's params metadata) rendered by `@dawcore/wam`; slider edits apply live and dispatch `daw-effect-change` like any other parameter edit. Generic panels are rebuilt on reopen so they always show the current parameter values (plugin-provided GUIs stay cached across close/reopen).
|
|
303
305
|
|
|
304
306
|
### Offline Export
|
|
305
307
|
|
|
306
|
-
`editor.exportAudio(options?)` renders the whole session — clips, volume/pan, mute/solo, per-track and master effect chains — on an `OfflineAudioContext` and resolves to an `AudioBuffer` (encode it to WAV/FLAC however you like):
|
|
308
|
+
`editor.exportAudio(options?)` renders the whole session — clips, volume/pan, mute/solo, master volume, per-track and master effect chains — on an `OfflineAudioContext` and resolves to an `AudioBuffer` (encode it to WAV/FLAC however you like):
|
|
307
309
|
|
|
308
310
|
```javascript
|
|
309
311
|
const buffer = await editor.exportAudio();
|
|
@@ -351,6 +353,35 @@ const result = await editor.loadFiles(fileList);
|
|
|
351
353
|
</script>
|
|
352
354
|
```
|
|
353
355
|
|
|
356
|
+
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.
|
|
357
|
+
|
|
358
|
+
## Single-Track Player
|
|
359
|
+
|
|
360
|
+
`<daw-player>` is a standalone element for single-track playback (podcasts, audiobooks, previewing one file) — it wraps `@waveform-playlist/media-element-playout` and needs no `adapter`, `AudioContext`, or `PlaylistEngine`. `@waveform-playlist/media-element-playout` ships as a direct dependency of `@dawcore/components`, so there's nothing extra to install:
|
|
361
|
+
|
|
362
|
+
```html
|
|
363
|
+
<daw-player
|
|
364
|
+
id="player"
|
|
365
|
+
src="/audio/episode.mp3"
|
|
366
|
+
peaks-src="/audio/episode.dat"
|
|
367
|
+
wave-height="96"
|
|
368
|
+
timescale
|
|
369
|
+
></daw-player>
|
|
370
|
+
|
|
371
|
+
<script type="module">
|
|
372
|
+
import '@dawcore/components';
|
|
373
|
+
|
|
374
|
+
const player = document.getElementById('player');
|
|
375
|
+
player.addEventListener('daw-ready', () => console.log('duration:', player.duration));
|
|
376
|
+
player.addEventListener('daw-timeupdate', (e) => console.log(e.detail.time));
|
|
377
|
+
|
|
378
|
+
player.play();
|
|
379
|
+
player.setPlaybackRate(1.5); // pitch-preserving, 0.25x-4x
|
|
380
|
+
</script>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Click the waveform to seek. Omit `peaks-src` for a scrubber-only fallback (no waveform, still playable). See `examples/dawcore-native/player.html` for a runnable demo with both modes.
|
|
384
|
+
|
|
354
385
|
## Keyboard Shortcuts
|
|
355
386
|
|
|
356
387
|
Add `<daw-keyboard-shortcuts>` as a child of `<daw-editor>`:
|
|
@@ -412,11 +443,14 @@ Core orchestrator. Attributes:
|
|
|
412
443
|
| `file-drop` | boolean | `false` | Accept audio files dropped onto the editor |
|
|
413
444
|
| `mono` | boolean | `false` | Merge stereo to mono display |
|
|
414
445
|
| `bar-width` / `bar-gap` | number | `1` / `0` | Waveform bar rendering style |
|
|
415
|
-
| `
|
|
446
|
+
| `rounded-bars` | boolean | `false` | Pill-shaped bar caps (radius `bar-width / 2`) |
|
|
447
|
+
| `indefinite-playback` | boolean | `false` | Disable the end-of-timeline auto-stop — roll until explicit stop (DAW style). Implies `fill-viewport` |
|
|
448
|
+
| `fill-viewport` | boolean | `false` | Keep ruler/timeline filling the viewport even when audio is shorter (layout only) |
|
|
416
449
|
| `scale-mode` | string | `'temporal'` | `'temporal'` (seconds) or `'beats'` (tick-linear grid) |
|
|
417
450
|
| `ticks-per-pixel` | number | `24` | Zoom level in beats mode |
|
|
418
451
|
| `snap-to` | string | `'off'` | Grid snapping in beats mode (`'bar'`, `'beat'`, `'1/2'`…`'1/16'`, `'off'`) |
|
|
419
452
|
| `eager-resume` | string | — | Resume AudioContext on first gesture; bare attribute targets the editor, or pass `"document"` / a CSS selector |
|
|
453
|
+
| `time-format` | string | `'hh:mm:ss.sss'` | Clock format read by `<daw-time-display>` / `<daw-time-format>`: `'hh:mm:ss.sss'`, `'hh:mm:ss'`, or `'seconds'` |
|
|
420
454
|
|
|
421
455
|
JS properties: `adapter` (required `PlayoutAdapter`), `recordingStream`, `bpm`, `ppqn`, `timeSignature`, `meterEntries`, `secondsToTicks` / `ticksToSeconds` (variable-tempo callbacks), `spectrogramConfig`, `spectrogramColorMap`. Read-only: `engine`, `audioContext` (from the adapter), `tracks`, `selection`, `selectedTrackId`, `currentTime`, `canUndo` / `canRedo`, `isRecording`.
|
|
422
456
|
|
|
@@ -424,9 +458,10 @@ Methods:
|
|
|
424
458
|
|
|
425
459
|
- Playback: `play(startTime?)`, `pause()`, `stop()`, `togglePlayPause()`, `seekTo(time)`
|
|
426
460
|
- Loading: `loadFiles(files)`, `loadMidi(urlOrFile, options?)`, `ready()`
|
|
461
|
+
- Display: `setTimeFormat(format)` — sugar over the `timeFormat` property, fires `daw-time-format-change`
|
|
427
462
|
- Tracks & clips: `addTrack(config)`, `removeTrack(id)`, `updateTrack(id, partial)`, `addClip(trackId, config)`, `removeClip(trackId, clipId)`, `updateClip(trackId, clipId, partial)`
|
|
428
463
|
- Editing: `splitAtPlayhead()`, `undo()`, `redo()`, `setSelection(start, end)`
|
|
429
|
-
- Recording: `startRecording(stream?, options?)`, `stopRecording()`, `pauseRecording()`, `resumeRecording()`, `togglePauseRecording()`
|
|
464
|
+
- Recording: `startRecording(stream?, options?)`, `stopRecording()`, `pauseRecording()`, `resumeRecording()`, `togglePauseRecording()`. Options include `overdub` (start playback with the take), `latencyOffset` (seconds), and `clipName` (live-preview header + finalized clip name, default `"Recording"`)
|
|
430
465
|
- Effects & export: the master-chain effects API (see [Effects](#effects)), `getEffectsState()` / `setEffectsState(entries)`, `openEffectGui()` / `closeEffectGui()`, `exportAudio(options?)`
|
|
431
466
|
|
|
432
467
|
### `<daw-track>`
|
|
@@ -443,7 +478,7 @@ Visual element for MIDI note rendering. Mounted automatically when the parent tr
|
|
|
443
478
|
|
|
444
479
|
### `<daw-transport for="editor-id">`
|
|
445
480
|
|
|
446
|
-
Container that resolves target editor. Children: `<daw-play-button>`, `<daw-pause-button>`, `<daw-stop-button>`, `<daw-record-button>`.
|
|
481
|
+
Container that resolves target editor. Children: `<daw-play-button>`, `<daw-pause-button>`, `<daw-stop-button>`, `<daw-record-button>`, `<daw-time-display>`, `<daw-time-format>`.
|
|
447
482
|
|
|
448
483
|
### `<daw-track-controls>`
|
|
449
484
|
|
|
@@ -453,6 +488,26 @@ Per-track UI for volume, pan, mute, solo. Receives state from editor, dispatches
|
|
|
453
488
|
|
|
454
489
|
Render-less child of `<daw-editor>`. Boolean attributes: `playback`, `splitting`, `undo`.
|
|
455
490
|
|
|
491
|
+
### `<daw-time-display>`
|
|
492
|
+
|
|
493
|
+
Formatted playback-time readout. Must be inside a `<daw-transport for="editor-id">` (resolves its target the same way the transport buttons do). Reads the target's `currentTime` / `timeFormat` and stays in sync via bubbled `daw-timeupdate` / `daw-time-format-change` events. `role="status"`, `aria-live="off"`.
|
|
494
|
+
|
|
495
|
+
### `<daw-time-format>`
|
|
496
|
+
|
|
497
|
+
`<select>` that sets the time format on the transport target (`target.setTimeFormat(...)`) — the target owns the state, every display/select syncs via `daw-time-format-change`. Renders disabled when the target doesn't implement `setTimeFormat`.
|
|
498
|
+
|
|
499
|
+
### `<daw-player>`
|
|
500
|
+
|
|
501
|
+
Standalone single-track player — see [Single-Track Player](#single-track-player). No `adapter`/`AudioContext`/`PlaylistEngine`; wraps `@waveform-playlist/media-element-playout`.
|
|
502
|
+
|
|
503
|
+
Attributes: `src`, `peaks-src`, `wave-height` (default `128`), `timescale`, `mono`, `bar-width` (default `1`), `bar-gap` (default `0`), `rounded-bars`, `playback-rate` (default `1`, clamped `0.25`–`4`).
|
|
504
|
+
|
|
505
|
+
Properties: `isPlaying`, `duration`, `currentTime` (get/set), `volume` (get/set), `audioElement` (underlying `HTMLAudioElement | null`).
|
|
506
|
+
|
|
507
|
+
Methods: `play()`, `pause()`, `stop()`, `seekTo(time)`, `setPlaybackRate(rate)`, `setVolume(volume)`.
|
|
508
|
+
|
|
509
|
+
Events: `daw-ready`, `daw-play`, `daw-pause`, `daw-stop`, `daw-timeupdate` (`{ time }`), `daw-ended`, `daw-error` (`{ operation, error }`).
|
|
510
|
+
|
|
456
511
|
## Events
|
|
457
512
|
|
|
458
513
|
```javascript
|
|
@@ -508,7 +563,7 @@ Set the adapter before tracks load. The provided context is used for decoding, p
|
|
|
508
563
|
|
|
509
564
|
## Examples & Documentation
|
|
510
565
|
|
|
511
|
-
- [`examples/dawcore-native/`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-native) — native transport: basics, multi-clip, metronome, beats grid, beat maps, effects, spectrogram, recording (`pnpm example:dawcore-native`)
|
|
566
|
+
- [`examples/dawcore-native/`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-native) — native transport: basics, multi-clip, metronome, beats grid, beat maps, effects, spectrogram, recording, `<daw-player>` (`pnpm example:dawcore-native`)
|
|
512
567
|
- [`examples/dawcore-tone/`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-tone) — Tone.js adapter: MIDI, SoundFont playback (`pnpm example:dawcore-tone`)
|
|
513
568
|
- [`examples/dawcore-wam/`](https://github.com/naomiaro/waveform-playlist/tree/main/examples/dawcore-wam) — WAM plugins end-to-end + in-browser Faust compilation (`pnpm example:dawcore-wam`)
|
|
514
569
|
- Guides: [naomiaro.github.io/waveform-playlist](https://naomiaro.github.io/waveform-playlist/docs/web-components/getting-started)
|
package/dist/index.d.mts
CHANGED
|
@@ -108,6 +108,10 @@ type SerializedEffectEntry = {
|
|
|
108
108
|
type: string;
|
|
109
109
|
params: Record<string, number>;
|
|
110
110
|
bypassed: boolean;
|
|
111
|
+
/** Present when the live entry was a failed-plugin placeholder (silent
|
|
112
|
+
* passthrough). Offline export skips these for parity with live
|
|
113
|
+
* playback; restore ignores the flag and retries normally. */
|
|
114
|
+
placeholder?: true;
|
|
111
115
|
} | {
|
|
112
116
|
kind: 'wam';
|
|
113
117
|
/** Module URL for url-loaded plugins. Absent for Faust entries. */
|
|
@@ -119,6 +123,10 @@ type SerializedEffectEntry = {
|
|
|
119
123
|
faustDsp?: string;
|
|
120
124
|
/** Name the Faust entry was compiled under (restores the same label). */
|
|
121
125
|
faustName?: string;
|
|
126
|
+
/** Present when the live entry was a failed-plugin placeholder (silent
|
|
127
|
+
* passthrough). Offline export skips these for parity with live
|
|
128
|
+
* playback; restore ignores the flag and retries the URL/DSP. */
|
|
129
|
+
placeholder?: true;
|
|
122
130
|
};
|
|
123
131
|
/** Result of creating an effect via the registry. */
|
|
124
132
|
interface CreatedEffect {
|
|
@@ -345,6 +353,9 @@ declare class DawPlayButtonElement extends DawTransportButton {
|
|
|
345
353
|
private _onRecEnd;
|
|
346
354
|
connectedCallback(): void;
|
|
347
355
|
disconnectedCallback(): void;
|
|
356
|
+
protected updated(): void;
|
|
357
|
+
private _ensureTargetListeners;
|
|
358
|
+
private _cleanupListeners;
|
|
348
359
|
render(): lit.TemplateResult<1>;
|
|
349
360
|
private _onClick;
|
|
350
361
|
}
|
|
@@ -365,6 +376,9 @@ declare class DawPauseButtonElement extends DawTransportButton {
|
|
|
365
376
|
static styles: lit.CSSResultGroup[];
|
|
366
377
|
connectedCallback(): void;
|
|
367
378
|
disconnectedCallback(): void;
|
|
379
|
+
protected updated(): void;
|
|
380
|
+
private _ensureTargetListeners;
|
|
381
|
+
private _cleanupListeners;
|
|
368
382
|
render(): lit.TemplateResult<1>;
|
|
369
383
|
private _onClick;
|
|
370
384
|
}
|
|
@@ -553,6 +567,10 @@ declare class PeakPipeline {
|
|
|
553
567
|
peaks: PeakData;
|
|
554
568
|
scale: number;
|
|
555
569
|
} | null;
|
|
570
|
+
/** Scale of the cached WaveformData for this buffer — 0 when not cached.
|
|
571
|
+
* Worker generation caches at baseScale; injected .dat data at its own
|
|
572
|
+
* scale. This is the finest zoom the buffer's peaks can render at. */
|
|
573
|
+
getCachedScale(audioBuffer: AudioBuffer): number;
|
|
556
574
|
/**
|
|
557
575
|
* Return the coarsest (largest) scale among cached WaveformData entries
|
|
558
576
|
* that correspond to the given clip buffers. Returns 0 if none are cached.
|
|
@@ -663,6 +681,12 @@ interface RecordingOptions {
|
|
|
663
681
|
* Negative or non-finite values are treated as 0.
|
|
664
682
|
*/
|
|
665
683
|
latencyOffset?: number;
|
|
684
|
+
/**
|
|
685
|
+
* Display name for the take: shown in the live-preview clip header while
|
|
686
|
+
* recording (falls back to "Recording…") and used as the finalized clip's
|
|
687
|
+
* name (falls back to "Recording").
|
|
688
|
+
*/
|
|
689
|
+
clipName?: string;
|
|
666
690
|
}
|
|
667
691
|
interface RecordingSession {
|
|
668
692
|
readonly trackId: string;
|
|
@@ -680,16 +704,29 @@ interface RecordingSession {
|
|
|
680
704
|
readonly peaks: (Int8Array | Int16Array)[];
|
|
681
705
|
readonly startSample: number;
|
|
682
706
|
readonly channelCount: number;
|
|
707
|
+
/** Sample rate of the AudioContext the worklet captured at. The finalized
|
|
708
|
+
* AudioBuffer must be labeled with THIS rate — the host's sticky
|
|
709
|
+
* effectiveSampleRate can lag after a context swap, mislabeling the take
|
|
710
|
+
* (~8.9% off-speed for 44.1k vs 48k). */
|
|
711
|
+
readonly captureSampleRate: number;
|
|
683
712
|
readonly bits: Bits;
|
|
684
713
|
isFirstMessage: boolean;
|
|
685
714
|
/** Latency samples to skip in live preview (outputLatency only). */
|
|
686
715
|
readonly latencySamples: number;
|
|
716
|
+
/** Display name for the take (preview header + finalized clip name). */
|
|
717
|
+
readonly clipName?: string;
|
|
718
|
+
/** Pre-session mute state of the armed track — restored when the session
|
|
719
|
+
* ends. null = mute never engaged (no engine on the host). */
|
|
720
|
+
armedPrevMuted: boolean | null;
|
|
687
721
|
readonly wasOverdub: boolean;
|
|
688
722
|
/** Stored so it can be removed on stop/cleanup — not just when stream ends. */
|
|
689
723
|
readonly _onTrackEnded: (() => void) | null;
|
|
690
724
|
readonly _audioTrack: MediaStreamTrack | null;
|
|
691
725
|
/** Set during stopRecording, cleared by the done message from the worklet. */
|
|
692
726
|
stopAckResolve: (() => void) | null;
|
|
727
|
+
/** In-flight stop completion — re-entrant stopRecording calls await this
|
|
728
|
+
* instead of running a second handshake. */
|
|
729
|
+
stopPromise: Promise<void> | null;
|
|
693
730
|
/** True from the start of stopRecording until the session is deleted.
|
|
694
731
|
* Guards pauseRecording / resumeRecording so a mid-drain pause toggle
|
|
695
732
|
* can't dispatch events for a session that's already terminating. */
|
|
@@ -705,12 +742,33 @@ type ReadonlyRecordingSession = Readonly<Omit<RecordingSession, 'chunks' | 'peak
|
|
|
705
742
|
interface RecordingHost extends ReactiveControllerHost {
|
|
706
743
|
readonly audioContext: AudioContext;
|
|
707
744
|
readonly samplesPerPixel: number;
|
|
745
|
+
/** Render-space samples-per-pixel. In beats mode this is derived from
|
|
746
|
+
* ticksPerPixel/bpm and differs from samplesPerPixel — live-preview peaks
|
|
747
|
+
* must be generated at THIS scale or the drawn waveform disagrees with the
|
|
748
|
+
* preview container's width/position. */
|
|
749
|
+
readonly renderSamplesPerPixel: number;
|
|
708
750
|
readonly effectiveSampleRate: number;
|
|
709
751
|
readonly _selectedTrackId: string | null;
|
|
710
|
-
|
|
752
|
+
/** Live playhead position in seconds. Must read from the engine during
|
|
753
|
+
* playback — a cached field only written on pause/stop/seek lags the real
|
|
754
|
+
* position and misplaces punch-in (record-during-playback) clips. */
|
|
755
|
+
readonly currentTime: number;
|
|
711
756
|
readonly shadowRoot: ShadowRoot | null;
|
|
712
757
|
resolveAudioContextSampleRate(rate: number): void;
|
|
713
|
-
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
758
|
+
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
759
|
+
/** Structural view of the editor's engine for the armed-track transient
|
|
760
|
+
* mute (punch-in replaces the overlapped content, so the recorded-over
|
|
761
|
+
* track's existing material must not play under the take). Optional —
|
|
762
|
+
* hosts without an engine skip the mute. */
|
|
763
|
+
_engine?: {
|
|
764
|
+
setTrackMute(trackId: string, muted: boolean): void;
|
|
765
|
+
getState(): {
|
|
766
|
+
tracks: Array<{
|
|
767
|
+
id: string;
|
|
768
|
+
muted: boolean;
|
|
769
|
+
}>;
|
|
770
|
+
};
|
|
771
|
+
} | null;
|
|
714
772
|
play?(startTime?: number): Promise<void>;
|
|
715
773
|
stop?(): void;
|
|
716
774
|
dispatchEvent(event: Event): boolean;
|
|
@@ -734,6 +792,15 @@ interface RecordingHost extends ReactiveControllerHost {
|
|
|
734
792
|
declare class RecordingController implements ReactiveController {
|
|
735
793
|
private _host;
|
|
736
794
|
private _sessions;
|
|
795
|
+
/** Track IDs with a startRecording in flight (session not yet in _sessions).
|
|
796
|
+
* The session is only set after several awaits — without this, two rapid
|
|
797
|
+
* start calls both pass the _sessions guard and build two capture
|
|
798
|
+
* pipelines feeding one session (garbled audio + a leaked worklet). */
|
|
799
|
+
private _starting;
|
|
800
|
+
/** True between hostDisconnected and hostConnected. An in-flight
|
|
801
|
+
* startRecording consults this after its awaits so a teardown mid-setup
|
|
802
|
+
* doesn't leak a live capture session on a detached editor. */
|
|
803
|
+
private _hostDisconnected;
|
|
737
804
|
private _workletLoadedCtx;
|
|
738
805
|
/** Tracks worklet pause state explicitly so external consumers (editor,
|
|
739
806
|
* pause button, spacebar) can share one source of truth. */
|
|
@@ -748,10 +815,30 @@ declare class RecordingController implements ReactiveController {
|
|
|
748
815
|
pauseRecording(trackId?: string): void;
|
|
749
816
|
resumeRecording(trackId?: string): void;
|
|
750
817
|
stopRecording(trackId?: string): Promise<void>;
|
|
818
|
+
private _finishStopRecording;
|
|
819
|
+
private _finalizeRecording;
|
|
820
|
+
/** Drain the event-loop queue of pending worklet flush messages. During
|
|
821
|
+
* recording the worklet posts a flush every ~16ms; if main was slower,
|
|
822
|
+
* messages back up. Yield repeatedly until session.totalSamples stabilizes
|
|
823
|
+
* (no new messages processed) for several consecutive ticks — at that
|
|
824
|
+
* point the queue is empty and chunks are complete. */
|
|
825
|
+
private _drainWorkletQueue;
|
|
751
826
|
private _onWorkletMessage;
|
|
752
827
|
private _processWorkletSamples;
|
|
753
828
|
private _createClipFromRecording;
|
|
754
829
|
private _removeTrackEndedListener;
|
|
830
|
+
private _dispatchRecordingError;
|
|
831
|
+
/** Shared teardown for finalize paths that end without a take (no data
|
|
832
|
+
* captured / too short after latency compensation): restore the armed-track
|
|
833
|
+
* mute, drop the session, and notify via daw-recording-error so record
|
|
834
|
+
* buttons reset their state. */
|
|
835
|
+
private _abandonFinalize;
|
|
836
|
+
/** Restore the armed track's pre-session mute state (idempotent — safe to
|
|
837
|
+
* call from both the finalize path and _cleanupSession). */
|
|
838
|
+
private _restoreArmedTrackMute;
|
|
839
|
+
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
840
|
+
* disposal paths that would otherwise discard the session silently. The
|
|
841
|
+
* startRecording catch path passes false (it dispatches its own error). */
|
|
755
842
|
private _cleanupSession;
|
|
756
843
|
}
|
|
757
844
|
|
|
@@ -856,10 +943,23 @@ declare class ClipPointerHandler {
|
|
|
856
943
|
onPointerMove(e: PointerEvent): void;
|
|
857
944
|
/** Processes pointerup events to finalize and dispatch result events. */
|
|
858
945
|
onPointerUp(_e: PointerEvent): void;
|
|
946
|
+
/** Processes pointercancel — reverts the in-progress drag.
|
|
947
|
+
*
|
|
948
|
+
* pointercancel fires INSTEAD of pointerup on touch interruption, pen
|
|
949
|
+
* leaving hover range, or OS gestures. Without this handler the drag stays
|
|
950
|
+
* armed (hover keeps moving the clip), the engine transaction stays open
|
|
951
|
+
* (every later edit becomes un-undoable until some drag commits), and the
|
|
952
|
+
* per-frame skipAdapter moveClip mutations are never synced or rolled back
|
|
953
|
+
* (waveform and audio permanently disagree). */
|
|
954
|
+
onPointerCancel(_e: PointerEvent): void;
|
|
859
955
|
/** Re-extract peaks from cache and set on waveform elements during trim drag.
|
|
860
956
|
* Returns true if peaks were successfully updated. */
|
|
861
957
|
private _updateWaveformPeaks;
|
|
862
|
-
/** Restore clip container CSS to original values after
|
|
958
|
+
/** Restore clip container CSS AND waveform peaks to original values after
|
|
959
|
+
* a trim visual preview. Peaks matter: the drag wrote re-extracted peak
|
|
960
|
+
* arrays imperatively onto the <daw-waveform> elements (bypassing Lit), and
|
|
961
|
+
* a cancelled/zero-delta trim makes no engine mutation — so no statechange
|
|
962
|
+
* re-render will ever repair them. */
|
|
863
963
|
private _restoreTrimVisual;
|
|
864
964
|
private _reset;
|
|
865
965
|
}
|
|
@@ -905,6 +1005,11 @@ interface DawTrackIdDetail {
|
|
|
905
1005
|
interface DawTrackErrorDetail {
|
|
906
1006
|
trackId: string;
|
|
907
1007
|
error: unknown;
|
|
1008
|
+
/** Present when the load was CANCELLED rather than failed: the track was
|
|
1009
|
+
* removed (or the editor disconnected) while its clips were still loading.
|
|
1010
|
+
* Consumer error UIs should filter these — nothing actually failed; the
|
|
1011
|
+
* event exists so addTrack()/loadMidi() awaiters settle. */
|
|
1012
|
+
reason?: 'removed' | 'disconnected';
|
|
908
1013
|
}
|
|
909
1014
|
interface DawFilesLoadErrorDetail {
|
|
910
1015
|
file: File;
|
|
@@ -1027,6 +1132,9 @@ interface DawEffectErrorDetail {
|
|
|
1027
1132
|
source?: {
|
|
1028
1133
|
faust: string;
|
|
1029
1134
|
};
|
|
1135
|
+
/** Native effect type of the failed entry (restore of an unregistered
|
|
1136
|
+
* custom type), when applicable. */
|
|
1137
|
+
type?: string;
|
|
1030
1138
|
message: string;
|
|
1031
1139
|
}
|
|
1032
1140
|
interface DawEventMap {
|
|
@@ -1133,6 +1241,9 @@ interface ExportAudioHost {
|
|
|
1133
1241
|
/** Natural session duration in seconds. */
|
|
1134
1242
|
duration: number;
|
|
1135
1243
|
tracks: ExportTrack[];
|
|
1244
|
+
/** Master output gain (engine setMasterVolume). Default 1. Without it the
|
|
1245
|
+
* export renders louder/quieter than what the user mixed against. */
|
|
1246
|
+
masterVolume?: number;
|
|
1136
1247
|
getMasterEffectsState(): Promise<SerializedEffectEntry[]>;
|
|
1137
1248
|
getTrackEffectsState(trackId: string): Promise<SerializedEffectEntry[]>;
|
|
1138
1249
|
}
|
|
@@ -1141,6 +1252,19 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1141
1252
|
get samplesPerPixel(): number;
|
|
1142
1253
|
set samplesPerPixel(value: number);
|
|
1143
1254
|
private _samplesPerPixel;
|
|
1255
|
+
/** Raise the zoom floor and re-clamp the LIVE samplesPerPixel when it's
|
|
1256
|
+
* now below the floor. Peaks can only be extracted at >= the floor scale —
|
|
1257
|
+
* the setter alone clamps only FUTURE sets, so without the re-clamp an
|
|
1258
|
+
* already-finer spp keeps sizing clip containers while the waveforms
|
|
1259
|
+
* render at the coarser scale: half/quarter width, misaligned against the
|
|
1260
|
+
* ruler and playhead. */
|
|
1261
|
+
_raiseZoomFloor(scale: number): void;
|
|
1262
|
+
/** Recompute the floor from the surviving cached scales (track removal /
|
|
1263
|
+
* load cancellation / preview cleanup). Usually LOWERS the floor, freeing
|
|
1264
|
+
* finer zoom — but a buffer whose scale never raised the floor (or a mix
|
|
1265
|
+
* of scales) can raise it above the live spp, so re-clamp like
|
|
1266
|
+
* _raiseZoomFloor. Never mutate _minSamplesPerPixel directly. */
|
|
1267
|
+
private _recomputeZoomFloor;
|
|
1144
1268
|
private _timeFormat;
|
|
1145
1269
|
/**
|
|
1146
1270
|
* Time display format used by <daw-time-display> and (future, #463) the
|
|
@@ -1162,12 +1286,22 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1162
1286
|
clipHeaderHeight: number;
|
|
1163
1287
|
interactiveClips: boolean;
|
|
1164
1288
|
/**
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1289
|
+
* Disable the end-of-timeline auto-stop — the transport rolls until an
|
|
1290
|
+
* explicit stop/pause (DAW style). Implies the fill-viewport layout.
|
|
1291
|
+
* Recording sessions suppress the auto-stop automatically, so recording
|
|
1292
|
+
* UIs usually want `fill-viewport` instead. Parity with the React
|
|
1293
|
+
* provider's `indefinitePlayback` prop.
|
|
1169
1294
|
*/
|
|
1170
1295
|
indefinitePlayback: boolean;
|
|
1296
|
+
/**
|
|
1297
|
+
* When true, the timeline fills the visible viewport even if total clip
|
|
1298
|
+
* duration is less (layout only — playback still auto-stops at the end).
|
|
1299
|
+
* Lets the ruler render before any audio is loaded — useful for empty
|
|
1300
|
+
* editors and recording UIs. In beats mode the 32-bar floor already
|
|
1301
|
+
* provides this; this attribute controls the temporal mode. Parity with
|
|
1302
|
+
* the React provider's `fillViewport` prop.
|
|
1303
|
+
*/
|
|
1304
|
+
fillViewport: boolean;
|
|
1171
1305
|
/**
|
|
1172
1306
|
* Default spectrogram FFT/render config inherited by tracks with
|
|
1173
1307
|
* `render-mode="spectrogram"` that do not set their own. Wired into the
|
|
@@ -1250,6 +1384,9 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1250
1384
|
set adapter(value: PlayoutAdapter | null);
|
|
1251
1385
|
get adapter(): PlayoutAdapter | null;
|
|
1252
1386
|
private _externalAdapter;
|
|
1387
|
+
/** True after a disconnect disposed the consumer's adapter via the engine
|
|
1388
|
+
* — rebuild attempts fail loudly until a fresh adapter is set. */
|
|
1389
|
+
private _adapterConsumedByDispose;
|
|
1253
1390
|
private _effectsManager;
|
|
1254
1391
|
private get _effects();
|
|
1255
1392
|
/** Master effects chain — inserted between the master bus and the destination. */
|
|
@@ -1336,6 +1473,11 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1336
1473
|
/** Coarsest scale from pre-computed peaks — zoom cannot go finer than this. 0 = no limit. */
|
|
1337
1474
|
private _minSamplesPerPixel;
|
|
1338
1475
|
private _trackElements;
|
|
1476
|
+
/** Track ids with a _loadTrack in flight. Distinct from `_engineTracks`
|
|
1477
|
+
* membership: the peaks-first path inserts a render-only PREVIEW track
|
|
1478
|
+
* into _engineTracks mid-load, so `has()` alone cannot answer "is this
|
|
1479
|
+
* track still loading?". */
|
|
1480
|
+
private _loadingTracks;
|
|
1339
1481
|
private _childObserver;
|
|
1340
1482
|
private _audioResume;
|
|
1341
1483
|
eagerResume?: string;
|
|
@@ -1408,6 +1550,17 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1408
1550
|
private _onTrackUpdate;
|
|
1409
1551
|
/** Drop the controller when no spectrogram tracks remain. */
|
|
1410
1552
|
private _disposeSpectrogramControllerIfEmpty;
|
|
1553
|
+
/** Reconcile `_tracks` descriptors with the engine's track list.
|
|
1554
|
+
*
|
|
1555
|
+
* ADD: engine.undo() restores removed tracks in ENGINE state only —
|
|
1556
|
+
* without a synthesized descriptor the track plays and renders but shows
|
|
1557
|
+
* "Untitled" controls and is missing from `editor.tracks`.
|
|
1558
|
+
* PRUNE (the symmetric half): redo removes the track from engine state
|
|
1559
|
+
* again — without pruning, the synthesized descriptor is a permanent
|
|
1560
|
+
* ghost that even removeTrack() can't clean (no element, no engine
|
|
1561
|
+
* entry). Never prunes tracks that are mid-load or element-backed —
|
|
1562
|
+
* their descriptors legitimately precede their engine entries. */
|
|
1563
|
+
_reconcileDescriptorsWithEngineTracks(tracks: ClipTrack[]): void;
|
|
1411
1564
|
private static _CONTROL_PROPS;
|
|
1412
1565
|
private _onTrackControl;
|
|
1413
1566
|
private _onTrackRemoveRequest;
|
|
@@ -1560,6 +1713,14 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1560
1713
|
stop(): void;
|
|
1561
1714
|
/** Toggle between play and pause. */
|
|
1562
1715
|
togglePlayPause(): void;
|
|
1716
|
+
/** Run `fn` with the stop-settle daw-timeupdate suppressed. Every
|
|
1717
|
+
* stop-adjacent code path that immediately re-positions (seek, split,
|
|
1718
|
+
* empty-timeline rewind) must use this — engine.stop() rewinds to the
|
|
1719
|
+
* play-start position and the settle would leak a backward-jumping
|
|
1720
|
+
* daw-timeupdate to consumers (CLAUDE.md seek-while-playing invariant).
|
|
1721
|
+
* The `finally` is load-bearing: a wedged true silently drops every
|
|
1722
|
+
* subsequent stop-settle dispatch. */
|
|
1723
|
+
private _withSeekSuppression;
|
|
1563
1724
|
seekTo(time: number): void;
|
|
1564
1725
|
/** Undo the last structural edit. */
|
|
1565
1726
|
undo(): void;
|
|
@@ -1592,11 +1753,16 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1592
1753
|
* worklet, so resume can restart it. Cleared on resume and on stop. */
|
|
1593
1754
|
private _wasPlayingDuringRecording;
|
|
1594
1755
|
stopRecording(): Promise<void>;
|
|
1595
|
-
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
1756
|
+
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
1596
1757
|
addWorkletModule(url: string): Promise<void>;
|
|
1597
1758
|
createAudioWorkletNode(name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1598
1759
|
createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
|
|
1599
1760
|
startRecording(stream?: MediaStream, options?: RecordingOptions): Promise<void>;
|
|
1761
|
+
/** Live-recording preview left/width. Beats mode uses the same tick-space
|
|
1762
|
+
* math as finalized clips — the sample÷renderSpp path is ceil-quantized,
|
|
1763
|
+
* so the take would visibly jump sideways on finalization (drift grows
|
|
1764
|
+
* with distance from t=0; CLAUDE.md live-preview parity invariant). */
|
|
1765
|
+
private _previewPosition;
|
|
1600
1766
|
private _renderRecordingPreview;
|
|
1601
1767
|
/** Convert playback seconds to a timeline pixel offset for the active mode. */
|
|
1602
1768
|
private _timeToPixels;
|
|
@@ -1638,7 +1804,8 @@ declare class DawRecordButtonElement extends DawTransportButton {
|
|
|
1638
1804
|
static styles: lit.CSSResultGroup[];
|
|
1639
1805
|
connectedCallback(): void;
|
|
1640
1806
|
disconnectedCallback(): void;
|
|
1641
|
-
|
|
1807
|
+
protected updated(): void;
|
|
1808
|
+
private _ensureTargetListeners;
|
|
1642
1809
|
private _cleanupListeners;
|
|
1643
1810
|
render(): lit.TemplateResult<1>;
|
|
1644
1811
|
private _onClick;
|
|
@@ -1678,11 +1845,19 @@ declare class DawKeyboardShortcutsElement extends LitElement {
|
|
|
1678
1845
|
playback: boolean;
|
|
1679
1846
|
splitting: boolean;
|
|
1680
1847
|
undo: boolean;
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1848
|
+
private _playbackShortcuts;
|
|
1849
|
+
get playbackShortcuts(): PlaybackShortcutMap | null;
|
|
1850
|
+
set playbackShortcuts(value: PlaybackShortcutMap | null);
|
|
1851
|
+
private _splittingShortcuts;
|
|
1852
|
+
get splittingShortcuts(): SplittingShortcutMap | null;
|
|
1853
|
+
set splittingShortcuts(value: SplittingShortcutMap | null);
|
|
1854
|
+
private _undoShortcuts;
|
|
1855
|
+
get undoShortcuts(): UndoShortcutMap | null;
|
|
1856
|
+
set undoShortcuts(value: UndoShortcutMap | null);
|
|
1684
1857
|
/** Additional custom shortcuts. */
|
|
1685
|
-
|
|
1858
|
+
private _customShortcuts;
|
|
1859
|
+
get customShortcuts(): KeyboardShortcut[];
|
|
1860
|
+
set customShortcuts(value: KeyboardShortcut[]);
|
|
1686
1861
|
private _editor;
|
|
1687
1862
|
private _cachedShortcuts;
|
|
1688
1863
|
/** All active shortcuts (read-only, cached). */
|
|
@@ -1824,6 +1999,9 @@ declare class DawPlayerElement extends LitElement {
|
|
|
1824
1999
|
set playbackRate(value: number);
|
|
1825
2000
|
private _playbackRate;
|
|
1826
2001
|
private _engine;
|
|
2002
|
+
/** Set by disconnectedCallback — a reconnect (DOM reparent, framework
|
|
2003
|
+
* re-render) must rebuild the engine + track or the player is dead. */
|
|
2004
|
+
private _engineDisposed;
|
|
1827
2005
|
private _trackId;
|
|
1828
2006
|
private _anim;
|
|
1829
2007
|
private _metadataLoaded;
|