@dawcore/components 0.0.31 → 0.0.33
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 +60 -5
- package/dist/index.d.mts +77 -8
- package/dist/index.d.ts +77 -8
- package/dist/index.js +166 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +168 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
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
|
|
|
@@ -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
|
@@ -663,6 +663,12 @@ interface RecordingOptions {
|
|
|
663
663
|
* Negative or non-finite values are treated as 0.
|
|
664
664
|
*/
|
|
665
665
|
latencyOffset?: number;
|
|
666
|
+
/**
|
|
667
|
+
* Display name for the take: shown in the live-preview clip header while
|
|
668
|
+
* recording (falls back to "Recording…") and used as the finalized clip's
|
|
669
|
+
* name (falls back to "Recording").
|
|
670
|
+
*/
|
|
671
|
+
clipName?: string;
|
|
666
672
|
}
|
|
667
673
|
interface RecordingSession {
|
|
668
674
|
readonly trackId: string;
|
|
@@ -680,16 +686,29 @@ interface RecordingSession {
|
|
|
680
686
|
readonly peaks: (Int8Array | Int16Array)[];
|
|
681
687
|
readonly startSample: number;
|
|
682
688
|
readonly channelCount: number;
|
|
689
|
+
/** Sample rate of the AudioContext the worklet captured at. The finalized
|
|
690
|
+
* AudioBuffer must be labeled with THIS rate — the host's sticky
|
|
691
|
+
* effectiveSampleRate can lag after a context swap, mislabeling the take
|
|
692
|
+
* (~8.9% off-speed for 44.1k vs 48k). */
|
|
693
|
+
readonly captureSampleRate: number;
|
|
683
694
|
readonly bits: Bits;
|
|
684
695
|
isFirstMessage: boolean;
|
|
685
696
|
/** Latency samples to skip in live preview (outputLatency only). */
|
|
686
697
|
readonly latencySamples: number;
|
|
698
|
+
/** Display name for the take (preview header + finalized clip name). */
|
|
699
|
+
readonly clipName?: string;
|
|
700
|
+
/** Pre-session mute state of the armed track — restored when the session
|
|
701
|
+
* ends. null = mute never engaged (no engine on the host). */
|
|
702
|
+
armedPrevMuted: boolean | null;
|
|
687
703
|
readonly wasOverdub: boolean;
|
|
688
704
|
/** Stored so it can be removed on stop/cleanup — not just when stream ends. */
|
|
689
705
|
readonly _onTrackEnded: (() => void) | null;
|
|
690
706
|
readonly _audioTrack: MediaStreamTrack | null;
|
|
691
707
|
/** Set during stopRecording, cleared by the done message from the worklet. */
|
|
692
708
|
stopAckResolve: (() => void) | null;
|
|
709
|
+
/** In-flight stop completion — re-entrant stopRecording calls await this
|
|
710
|
+
* instead of running a second handshake. */
|
|
711
|
+
stopPromise: Promise<void> | null;
|
|
693
712
|
/** True from the start of stopRecording until the session is deleted.
|
|
694
713
|
* Guards pauseRecording / resumeRecording so a mid-drain pause toggle
|
|
695
714
|
* can't dispatch events for a session that's already terminating. */
|
|
@@ -705,12 +724,33 @@ type ReadonlyRecordingSession = Readonly<Omit<RecordingSession, 'chunks' | 'peak
|
|
|
705
724
|
interface RecordingHost extends ReactiveControllerHost {
|
|
706
725
|
readonly audioContext: AudioContext;
|
|
707
726
|
readonly samplesPerPixel: number;
|
|
727
|
+
/** Render-space samples-per-pixel. In beats mode this is derived from
|
|
728
|
+
* ticksPerPixel/bpm and differs from samplesPerPixel — live-preview peaks
|
|
729
|
+
* must be generated at THIS scale or the drawn waveform disagrees with the
|
|
730
|
+
* preview container's width/position. */
|
|
731
|
+
readonly renderSamplesPerPixel: number;
|
|
708
732
|
readonly effectiveSampleRate: number;
|
|
709
733
|
readonly _selectedTrackId: string | null;
|
|
710
|
-
|
|
734
|
+
/** Live playhead position in seconds. Must read from the engine during
|
|
735
|
+
* playback — a cached field only written on pause/stop/seek lags the real
|
|
736
|
+
* position and misplaces punch-in (record-during-playback) clips. */
|
|
737
|
+
readonly currentTime: number;
|
|
711
738
|
readonly shadowRoot: ShadowRoot | null;
|
|
712
739
|
resolveAudioContextSampleRate(rate: number): void;
|
|
713
|
-
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
740
|
+
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
741
|
+
/** Structural view of the editor's engine for the armed-track transient
|
|
742
|
+
* mute (punch-in replaces the overlapped content, so the recorded-over
|
|
743
|
+
* track's existing material must not play under the take). Optional —
|
|
744
|
+
* hosts without an engine skip the mute. */
|
|
745
|
+
_engine?: {
|
|
746
|
+
setTrackMute(trackId: string, muted: boolean): void;
|
|
747
|
+
getState(): {
|
|
748
|
+
tracks: Array<{
|
|
749
|
+
id: string;
|
|
750
|
+
muted: boolean;
|
|
751
|
+
}>;
|
|
752
|
+
};
|
|
753
|
+
} | null;
|
|
714
754
|
play?(startTime?: number): Promise<void>;
|
|
715
755
|
stop?(): void;
|
|
716
756
|
dispatchEvent(event: Event): boolean;
|
|
@@ -734,6 +774,11 @@ interface RecordingHost extends ReactiveControllerHost {
|
|
|
734
774
|
declare class RecordingController implements ReactiveController {
|
|
735
775
|
private _host;
|
|
736
776
|
private _sessions;
|
|
777
|
+
/** Track IDs with a startRecording in flight (session not yet in _sessions).
|
|
778
|
+
* The session is only set after several awaits — without this, two rapid
|
|
779
|
+
* start calls both pass the _sessions guard and build two capture
|
|
780
|
+
* pipelines feeding one session (garbled audio + a leaked worklet). */
|
|
781
|
+
private _starting;
|
|
737
782
|
private _workletLoadedCtx;
|
|
738
783
|
/** Tracks worklet pause state explicitly so external consumers (editor,
|
|
739
784
|
* pause button, spacebar) can share one source of truth. */
|
|
@@ -748,10 +793,23 @@ declare class RecordingController implements ReactiveController {
|
|
|
748
793
|
pauseRecording(trackId?: string): void;
|
|
749
794
|
resumeRecording(trackId?: string): void;
|
|
750
795
|
stopRecording(trackId?: string): Promise<void>;
|
|
796
|
+
private _finishStopRecording;
|
|
797
|
+
/** Drain the event-loop queue of pending worklet flush messages. During
|
|
798
|
+
* recording the worklet posts a flush every ~16ms; if main was slower,
|
|
799
|
+
* messages back up. Yield repeatedly until session.totalSamples stabilizes
|
|
800
|
+
* (no new messages processed) for several consecutive ticks — at that
|
|
801
|
+
* point the queue is empty and chunks are complete. */
|
|
802
|
+
private _drainWorkletQueue;
|
|
751
803
|
private _onWorkletMessage;
|
|
752
804
|
private _processWorkletSamples;
|
|
753
805
|
private _createClipFromRecording;
|
|
754
806
|
private _removeTrackEndedListener;
|
|
807
|
+
/** Restore the armed track's pre-session mute state (idempotent — safe to
|
|
808
|
+
* call from both the finalize path and _cleanupSession). */
|
|
809
|
+
private _restoreArmedTrackMute;
|
|
810
|
+
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
811
|
+
* disposal paths that would otherwise discard the session silently. The
|
|
812
|
+
* startRecording catch path passes false (it dispatches its own error). */
|
|
755
813
|
private _cleanupSession;
|
|
756
814
|
}
|
|
757
815
|
|
|
@@ -1162,12 +1220,22 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1162
1220
|
clipHeaderHeight: number;
|
|
1163
1221
|
interactiveClips: boolean;
|
|
1164
1222
|
/**
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1223
|
+
* Disable the end-of-timeline auto-stop — the transport rolls until an
|
|
1224
|
+
* explicit stop/pause (DAW style). Implies the fill-viewport layout.
|
|
1225
|
+
* Recording sessions suppress the auto-stop automatically, so recording
|
|
1226
|
+
* UIs usually want `fill-viewport` instead. Parity with the React
|
|
1227
|
+
* provider's `indefinitePlayback` prop.
|
|
1169
1228
|
*/
|
|
1170
1229
|
indefinitePlayback: boolean;
|
|
1230
|
+
/**
|
|
1231
|
+
* When true, the timeline fills the visible viewport even if total clip
|
|
1232
|
+
* duration is less (layout only — playback still auto-stops at the end).
|
|
1233
|
+
* Lets the ruler render before any audio is loaded — useful for empty
|
|
1234
|
+
* editors and recording UIs. In beats mode the 32-bar floor already
|
|
1235
|
+
* provides this; this attribute controls the temporal mode. Parity with
|
|
1236
|
+
* the React provider's `fillViewport` prop.
|
|
1237
|
+
*/
|
|
1238
|
+
fillViewport: boolean;
|
|
1171
1239
|
/**
|
|
1172
1240
|
* Default spectrogram FFT/render config inherited by tracks with
|
|
1173
1241
|
* `render-mode="spectrogram"` that do not set their own. Wired into the
|
|
@@ -1592,7 +1660,7 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1592
1660
|
* worklet, so resume can restart it. Cleared on resume and on stop. */
|
|
1593
1661
|
private _wasPlayingDuringRecording;
|
|
1594
1662
|
stopRecording(): Promise<void>;
|
|
1595
|
-
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
1663
|
+
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
1596
1664
|
addWorkletModule(url: string): Promise<void>;
|
|
1597
1665
|
createAudioWorkletNode(name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1598
1666
|
createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
|
|
@@ -1638,7 +1706,8 @@ declare class DawRecordButtonElement extends DawTransportButton {
|
|
|
1638
1706
|
static styles: lit.CSSResultGroup[];
|
|
1639
1707
|
connectedCallback(): void;
|
|
1640
1708
|
disconnectedCallback(): void;
|
|
1641
|
-
|
|
1709
|
+
protected updated(): void;
|
|
1710
|
+
private _ensureTargetListeners;
|
|
1642
1711
|
private _cleanupListeners;
|
|
1643
1712
|
render(): lit.TemplateResult<1>;
|
|
1644
1713
|
private _onClick;
|
package/dist/index.d.ts
CHANGED
|
@@ -663,6 +663,12 @@ interface RecordingOptions {
|
|
|
663
663
|
* Negative or non-finite values are treated as 0.
|
|
664
664
|
*/
|
|
665
665
|
latencyOffset?: number;
|
|
666
|
+
/**
|
|
667
|
+
* Display name for the take: shown in the live-preview clip header while
|
|
668
|
+
* recording (falls back to "Recording…") and used as the finalized clip's
|
|
669
|
+
* name (falls back to "Recording").
|
|
670
|
+
*/
|
|
671
|
+
clipName?: string;
|
|
666
672
|
}
|
|
667
673
|
interface RecordingSession {
|
|
668
674
|
readonly trackId: string;
|
|
@@ -680,16 +686,29 @@ interface RecordingSession {
|
|
|
680
686
|
readonly peaks: (Int8Array | Int16Array)[];
|
|
681
687
|
readonly startSample: number;
|
|
682
688
|
readonly channelCount: number;
|
|
689
|
+
/** Sample rate of the AudioContext the worklet captured at. The finalized
|
|
690
|
+
* AudioBuffer must be labeled with THIS rate — the host's sticky
|
|
691
|
+
* effectiveSampleRate can lag after a context swap, mislabeling the take
|
|
692
|
+
* (~8.9% off-speed for 44.1k vs 48k). */
|
|
693
|
+
readonly captureSampleRate: number;
|
|
683
694
|
readonly bits: Bits;
|
|
684
695
|
isFirstMessage: boolean;
|
|
685
696
|
/** Latency samples to skip in live preview (outputLatency only). */
|
|
686
697
|
readonly latencySamples: number;
|
|
698
|
+
/** Display name for the take (preview header + finalized clip name). */
|
|
699
|
+
readonly clipName?: string;
|
|
700
|
+
/** Pre-session mute state of the armed track — restored when the session
|
|
701
|
+
* ends. null = mute never engaged (no engine on the host). */
|
|
702
|
+
armedPrevMuted: boolean | null;
|
|
687
703
|
readonly wasOverdub: boolean;
|
|
688
704
|
/** Stored so it can be removed on stop/cleanup — not just when stream ends. */
|
|
689
705
|
readonly _onTrackEnded: (() => void) | null;
|
|
690
706
|
readonly _audioTrack: MediaStreamTrack | null;
|
|
691
707
|
/** Set during stopRecording, cleared by the done message from the worklet. */
|
|
692
708
|
stopAckResolve: (() => void) | null;
|
|
709
|
+
/** In-flight stop completion — re-entrant stopRecording calls await this
|
|
710
|
+
* instead of running a second handshake. */
|
|
711
|
+
stopPromise: Promise<void> | null;
|
|
693
712
|
/** True from the start of stopRecording until the session is deleted.
|
|
694
713
|
* Guards pauseRecording / resumeRecording so a mid-drain pause toggle
|
|
695
714
|
* can't dispatch events for a session that's already terminating. */
|
|
@@ -705,12 +724,33 @@ type ReadonlyRecordingSession = Readonly<Omit<RecordingSession, 'chunks' | 'peak
|
|
|
705
724
|
interface RecordingHost extends ReactiveControllerHost {
|
|
706
725
|
readonly audioContext: AudioContext;
|
|
707
726
|
readonly samplesPerPixel: number;
|
|
727
|
+
/** Render-space samples-per-pixel. In beats mode this is derived from
|
|
728
|
+
* ticksPerPixel/bpm and differs from samplesPerPixel — live-preview peaks
|
|
729
|
+
* must be generated at THIS scale or the drawn waveform disagrees with the
|
|
730
|
+
* preview container's width/position. */
|
|
731
|
+
readonly renderSamplesPerPixel: number;
|
|
708
732
|
readonly effectiveSampleRate: number;
|
|
709
733
|
readonly _selectedTrackId: string | null;
|
|
710
|
-
|
|
734
|
+
/** Live playhead position in seconds. Must read from the engine during
|
|
735
|
+
* playback — a cached field only written on pause/stop/seek lags the real
|
|
736
|
+
* position and misplaces punch-in (record-during-playback) clips. */
|
|
737
|
+
readonly currentTime: number;
|
|
711
738
|
readonly shadowRoot: ShadowRoot | null;
|
|
712
739
|
resolveAudioContextSampleRate(rate: number): void;
|
|
713
|
-
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
740
|
+
_addRecordedClip?(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
741
|
+
/** Structural view of the editor's engine for the armed-track transient
|
|
742
|
+
* mute (punch-in replaces the overlapped content, so the recorded-over
|
|
743
|
+
* track's existing material must not play under the take). Optional —
|
|
744
|
+
* hosts without an engine skip the mute. */
|
|
745
|
+
_engine?: {
|
|
746
|
+
setTrackMute(trackId: string, muted: boolean): void;
|
|
747
|
+
getState(): {
|
|
748
|
+
tracks: Array<{
|
|
749
|
+
id: string;
|
|
750
|
+
muted: boolean;
|
|
751
|
+
}>;
|
|
752
|
+
};
|
|
753
|
+
} | null;
|
|
714
754
|
play?(startTime?: number): Promise<void>;
|
|
715
755
|
stop?(): void;
|
|
716
756
|
dispatchEvent(event: Event): boolean;
|
|
@@ -734,6 +774,11 @@ interface RecordingHost extends ReactiveControllerHost {
|
|
|
734
774
|
declare class RecordingController implements ReactiveController {
|
|
735
775
|
private _host;
|
|
736
776
|
private _sessions;
|
|
777
|
+
/** Track IDs with a startRecording in flight (session not yet in _sessions).
|
|
778
|
+
* The session is only set after several awaits — without this, two rapid
|
|
779
|
+
* start calls both pass the _sessions guard and build two capture
|
|
780
|
+
* pipelines feeding one session (garbled audio + a leaked worklet). */
|
|
781
|
+
private _starting;
|
|
737
782
|
private _workletLoadedCtx;
|
|
738
783
|
/** Tracks worklet pause state explicitly so external consumers (editor,
|
|
739
784
|
* pause button, spacebar) can share one source of truth. */
|
|
@@ -748,10 +793,23 @@ declare class RecordingController implements ReactiveController {
|
|
|
748
793
|
pauseRecording(trackId?: string): void;
|
|
749
794
|
resumeRecording(trackId?: string): void;
|
|
750
795
|
stopRecording(trackId?: string): Promise<void>;
|
|
796
|
+
private _finishStopRecording;
|
|
797
|
+
/** Drain the event-loop queue of pending worklet flush messages. During
|
|
798
|
+
* recording the worklet posts a flush every ~16ms; if main was slower,
|
|
799
|
+
* messages back up. Yield repeatedly until session.totalSamples stabilizes
|
|
800
|
+
* (no new messages processed) for several consecutive ticks — at that
|
|
801
|
+
* point the queue is empty and chunks are complete. */
|
|
802
|
+
private _drainWorkletQueue;
|
|
751
803
|
private _onWorkletMessage;
|
|
752
804
|
private _processWorkletSamples;
|
|
753
805
|
private _createClipFromRecording;
|
|
754
806
|
private _removeTrackEndedListener;
|
|
807
|
+
/** Restore the armed track's pre-session mute state (idempotent — safe to
|
|
808
|
+
* call from both the finalize path and _cleanupSession). */
|
|
809
|
+
private _restoreArmedTrackMute;
|
|
810
|
+
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
811
|
+
* disposal paths that would otherwise discard the session silently. The
|
|
812
|
+
* startRecording catch path passes false (it dispatches its own error). */
|
|
755
813
|
private _cleanupSession;
|
|
756
814
|
}
|
|
757
815
|
|
|
@@ -1162,12 +1220,22 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1162
1220
|
clipHeaderHeight: number;
|
|
1163
1221
|
interactiveClips: boolean;
|
|
1164
1222
|
/**
|
|
1165
|
-
*
|
|
1166
|
-
*
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1223
|
+
* Disable the end-of-timeline auto-stop — the transport rolls until an
|
|
1224
|
+
* explicit stop/pause (DAW style). Implies the fill-viewport layout.
|
|
1225
|
+
* Recording sessions suppress the auto-stop automatically, so recording
|
|
1226
|
+
* UIs usually want `fill-viewport` instead. Parity with the React
|
|
1227
|
+
* provider's `indefinitePlayback` prop.
|
|
1169
1228
|
*/
|
|
1170
1229
|
indefinitePlayback: boolean;
|
|
1230
|
+
/**
|
|
1231
|
+
* When true, the timeline fills the visible viewport even if total clip
|
|
1232
|
+
* duration is less (layout only — playback still auto-stops at the end).
|
|
1233
|
+
* Lets the ruler render before any audio is loaded — useful for empty
|
|
1234
|
+
* editors and recording UIs. In beats mode the 32-bar floor already
|
|
1235
|
+
* provides this; this attribute controls the temporal mode. Parity with
|
|
1236
|
+
* the React provider's `fillViewport` prop.
|
|
1237
|
+
*/
|
|
1238
|
+
fillViewport: boolean;
|
|
1171
1239
|
/**
|
|
1172
1240
|
* Default spectrogram FFT/render config inherited by tracks with
|
|
1173
1241
|
* `render-mode="spectrogram"` that do not set their own. Wired into the
|
|
@@ -1592,7 +1660,7 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
|
|
|
1592
1660
|
* worklet, so resume can restart it. Cleared on resume and on stop. */
|
|
1593
1661
|
private _wasPlayingDuringRecording;
|
|
1594
1662
|
stopRecording(): Promise<void>;
|
|
1595
|
-
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number): void;
|
|
1663
|
+
_addRecordedClip(trackId: string, buf: AudioBuffer, startSample: number, durSamples: number, offsetSamples?: number, clipName?: string): void;
|
|
1596
1664
|
addWorkletModule(url: string): Promise<void>;
|
|
1597
1665
|
createAudioWorkletNode(name: string, options?: AudioWorkletNodeOptions): AudioWorkletNode;
|
|
1598
1666
|
createMediaStreamSource(stream: MediaStream): MediaStreamAudioSourceNode;
|
|
@@ -1638,7 +1706,8 @@ declare class DawRecordButtonElement extends DawTransportButton {
|
|
|
1638
1706
|
static styles: lit.CSSResultGroup[];
|
|
1639
1707
|
connectedCallback(): void;
|
|
1640
1708
|
disconnectedCallback(): void;
|
|
1641
|
-
|
|
1709
|
+
protected updated(): void;
|
|
1710
|
+
private _ensureTargetListeners;
|
|
1642
1711
|
private _cleanupListeners;
|
|
1643
1712
|
render(): lit.TemplateResult<1>;
|
|
1644
1713
|
private _onClick;
|