@dawcore/components 0.0.27 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +334 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +333 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -7
package/dist/index.d.mts
CHANGED
|
@@ -1037,6 +1037,8 @@ interface DawEventMap {
|
|
|
1037
1037
|
'daw-track-removed': CustomEvent<DawTrackIdDetail>;
|
|
1038
1038
|
'daw-track-error': CustomEvent<DawTrackErrorDetail>;
|
|
1039
1039
|
'daw-files-load-error': CustomEvent<DawFilesLoadErrorDetail>;
|
|
1040
|
+
'daw-ready': CustomEvent<void>;
|
|
1041
|
+
'daw-ended': CustomEvent<void>;
|
|
1040
1042
|
'daw-play': CustomEvent<void>;
|
|
1041
1043
|
'daw-pause': CustomEvent<void>;
|
|
1042
1044
|
'daw-stop': CustomEvent<void>;
|
|
@@ -1798,6 +1800,83 @@ declare global {
|
|
|
1798
1800
|
}
|
|
1799
1801
|
}
|
|
1800
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* `<daw-player>` — lightweight single-track HTMLMediaElement player.
|
|
1805
|
+
* Wraps a MediaElementPlayout engine for playback and composes
|
|
1806
|
+
* <daw-ruler>/<daw-waveform>/<daw-playhead> for visuals. No PlaylistEngine,
|
|
1807
|
+
* no adapter, no AudioContext. See docs/specs/2026-06-29-daw-player-core-design.md.
|
|
1808
|
+
*/
|
|
1809
|
+
declare class DawPlayerElement extends LitElement {
|
|
1810
|
+
src: string;
|
|
1811
|
+
peaksSrc: string;
|
|
1812
|
+
waveHeight: number;
|
|
1813
|
+
timescale: boolean;
|
|
1814
|
+
mono: boolean;
|
|
1815
|
+
barWidth: number;
|
|
1816
|
+
barGap: number;
|
|
1817
|
+
get playbackRate(): number;
|
|
1818
|
+
set playbackRate(value: number);
|
|
1819
|
+
private _playbackRate;
|
|
1820
|
+
private _engine;
|
|
1821
|
+
private _trackId;
|
|
1822
|
+
private _anim;
|
|
1823
|
+
private _metadataLoaded;
|
|
1824
|
+
private _readyDispatched;
|
|
1825
|
+
/** True once peaks resolution is complete: succeeded, failed, or no peaks-src set. */
|
|
1826
|
+
private _peaksSettled;
|
|
1827
|
+
private _waveformData;
|
|
1828
|
+
private _channelPeaks;
|
|
1829
|
+
private _sampleRate;
|
|
1830
|
+
private _resizeObserver;
|
|
1831
|
+
static styles: lit.CSSResult;
|
|
1832
|
+
connectedCallback(): void;
|
|
1833
|
+
render(): lit.TemplateResult<1>;
|
|
1834
|
+
protected updated(changed: PropertyValues): void;
|
|
1835
|
+
private _loadPeaks;
|
|
1836
|
+
/** Recompute fit-to-width peaks from the loaded WaveformData. No-op without data. */
|
|
1837
|
+
private _renderWaveform;
|
|
1838
|
+
/**
|
|
1839
|
+
* Samples-per-pixel used by the ruler so its time labels span the full width.
|
|
1840
|
+
* This is intentionally a separate time-based SPP (duration × sampleRate / width)
|
|
1841
|
+
* for the ruler labels — equivalent to the waveform SPP when the WaveformData spans
|
|
1842
|
+
* the full audio duration; may differ for pre-trimmed peaks.
|
|
1843
|
+
*/
|
|
1844
|
+
private _channelSpp;
|
|
1845
|
+
private _loadSource;
|
|
1846
|
+
play(): void;
|
|
1847
|
+
pause(): void;
|
|
1848
|
+
stop(): void;
|
|
1849
|
+
seekTo(time: number): void;
|
|
1850
|
+
setPlaybackRate(rate: number): void;
|
|
1851
|
+
setVolume(volume: number): void;
|
|
1852
|
+
get isPlaying(): boolean;
|
|
1853
|
+
get duration(): number;
|
|
1854
|
+
get currentTime(): number;
|
|
1855
|
+
set currentTime(time: number);
|
|
1856
|
+
get volume(): number;
|
|
1857
|
+
set volume(value: number);
|
|
1858
|
+
get audioElement(): HTMLAudioElement | null;
|
|
1859
|
+
private _onPointerDown;
|
|
1860
|
+
disconnectedCallback(): void;
|
|
1861
|
+
private _dispatch;
|
|
1862
|
+
private _onLoadedMetadata;
|
|
1863
|
+
private _onPlay;
|
|
1864
|
+
private _onPause;
|
|
1865
|
+
private _onEnded;
|
|
1866
|
+
private _onError;
|
|
1867
|
+
/** rAF tick while playing: positions the playhead and emits daw-timeupdate. */
|
|
1868
|
+
private _frame;
|
|
1869
|
+
private _maybeDispatchReady;
|
|
1870
|
+
private get _playhead();
|
|
1871
|
+
private _updatePlayhead;
|
|
1872
|
+
private get _timelineWidth();
|
|
1873
|
+
}
|
|
1874
|
+
declare global {
|
|
1875
|
+
interface HTMLElementTagNameMap {
|
|
1876
|
+
'daw-player': DawPlayerElement;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1801
1880
|
interface SpectrogramControllerHost extends ReactiveControllerHost {
|
|
1802
1881
|
dispatchEvent(event: Event): boolean;
|
|
1803
1882
|
}
|
|
@@ -1975,4 +2054,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
|
|
|
1975
2054
|
declare function getEffectDefinitions(): Map<string, EffectDefinition>;
|
|
1976
2055
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
|
|
1977
2056
|
|
|
1978
|
-
export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, 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, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
|
|
2057
|
+
export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayerElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
|
package/dist/index.d.ts
CHANGED
|
@@ -1037,6 +1037,8 @@ interface DawEventMap {
|
|
|
1037
1037
|
'daw-track-removed': CustomEvent<DawTrackIdDetail>;
|
|
1038
1038
|
'daw-track-error': CustomEvent<DawTrackErrorDetail>;
|
|
1039
1039
|
'daw-files-load-error': CustomEvent<DawFilesLoadErrorDetail>;
|
|
1040
|
+
'daw-ready': CustomEvent<void>;
|
|
1041
|
+
'daw-ended': CustomEvent<void>;
|
|
1040
1042
|
'daw-play': CustomEvent<void>;
|
|
1041
1043
|
'daw-pause': CustomEvent<void>;
|
|
1042
1044
|
'daw-stop': CustomEvent<void>;
|
|
@@ -1798,6 +1800,83 @@ declare global {
|
|
|
1798
1800
|
}
|
|
1799
1801
|
}
|
|
1800
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* `<daw-player>` — lightweight single-track HTMLMediaElement player.
|
|
1805
|
+
* Wraps a MediaElementPlayout engine for playback and composes
|
|
1806
|
+
* <daw-ruler>/<daw-waveform>/<daw-playhead> for visuals. No PlaylistEngine,
|
|
1807
|
+
* no adapter, no AudioContext. See docs/specs/2026-06-29-daw-player-core-design.md.
|
|
1808
|
+
*/
|
|
1809
|
+
declare class DawPlayerElement extends LitElement {
|
|
1810
|
+
src: string;
|
|
1811
|
+
peaksSrc: string;
|
|
1812
|
+
waveHeight: number;
|
|
1813
|
+
timescale: boolean;
|
|
1814
|
+
mono: boolean;
|
|
1815
|
+
barWidth: number;
|
|
1816
|
+
barGap: number;
|
|
1817
|
+
get playbackRate(): number;
|
|
1818
|
+
set playbackRate(value: number);
|
|
1819
|
+
private _playbackRate;
|
|
1820
|
+
private _engine;
|
|
1821
|
+
private _trackId;
|
|
1822
|
+
private _anim;
|
|
1823
|
+
private _metadataLoaded;
|
|
1824
|
+
private _readyDispatched;
|
|
1825
|
+
/** True once peaks resolution is complete: succeeded, failed, or no peaks-src set. */
|
|
1826
|
+
private _peaksSettled;
|
|
1827
|
+
private _waveformData;
|
|
1828
|
+
private _channelPeaks;
|
|
1829
|
+
private _sampleRate;
|
|
1830
|
+
private _resizeObserver;
|
|
1831
|
+
static styles: lit.CSSResult;
|
|
1832
|
+
connectedCallback(): void;
|
|
1833
|
+
render(): lit.TemplateResult<1>;
|
|
1834
|
+
protected updated(changed: PropertyValues): void;
|
|
1835
|
+
private _loadPeaks;
|
|
1836
|
+
/** Recompute fit-to-width peaks from the loaded WaveformData. No-op without data. */
|
|
1837
|
+
private _renderWaveform;
|
|
1838
|
+
/**
|
|
1839
|
+
* Samples-per-pixel used by the ruler so its time labels span the full width.
|
|
1840
|
+
* This is intentionally a separate time-based SPP (duration × sampleRate / width)
|
|
1841
|
+
* for the ruler labels — equivalent to the waveform SPP when the WaveformData spans
|
|
1842
|
+
* the full audio duration; may differ for pre-trimmed peaks.
|
|
1843
|
+
*/
|
|
1844
|
+
private _channelSpp;
|
|
1845
|
+
private _loadSource;
|
|
1846
|
+
play(): void;
|
|
1847
|
+
pause(): void;
|
|
1848
|
+
stop(): void;
|
|
1849
|
+
seekTo(time: number): void;
|
|
1850
|
+
setPlaybackRate(rate: number): void;
|
|
1851
|
+
setVolume(volume: number): void;
|
|
1852
|
+
get isPlaying(): boolean;
|
|
1853
|
+
get duration(): number;
|
|
1854
|
+
get currentTime(): number;
|
|
1855
|
+
set currentTime(time: number);
|
|
1856
|
+
get volume(): number;
|
|
1857
|
+
set volume(value: number);
|
|
1858
|
+
get audioElement(): HTMLAudioElement | null;
|
|
1859
|
+
private _onPointerDown;
|
|
1860
|
+
disconnectedCallback(): void;
|
|
1861
|
+
private _dispatch;
|
|
1862
|
+
private _onLoadedMetadata;
|
|
1863
|
+
private _onPlay;
|
|
1864
|
+
private _onPause;
|
|
1865
|
+
private _onEnded;
|
|
1866
|
+
private _onError;
|
|
1867
|
+
/** rAF tick while playing: positions the playhead and emits daw-timeupdate. */
|
|
1868
|
+
private _frame;
|
|
1869
|
+
private _maybeDispatchReady;
|
|
1870
|
+
private get _playhead();
|
|
1871
|
+
private _updatePlayhead;
|
|
1872
|
+
private get _timelineWidth();
|
|
1873
|
+
}
|
|
1874
|
+
declare global {
|
|
1875
|
+
interface HTMLElementTagNameMap {
|
|
1876
|
+
'daw-player': DawPlayerElement;
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1801
1880
|
interface SpectrogramControllerHost extends ReactiveControllerHost {
|
|
1802
1881
|
dispatchEvent(event: Event): boolean;
|
|
1803
1882
|
}
|
|
@@ -1975,4 +2054,4 @@ declare function registerEffect(type: string, definition: EffectDefinition): voi
|
|
|
1975
2054
|
declare function getEffectDefinitions(): Map<string, EffectDefinition>;
|
|
1976
2055
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedEffect;
|
|
1977
2056
|
|
|
1978
|
-
export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, 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, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
|
|
2057
|
+
export { AudioResumeController, type ClipConfig, type ClipDescriptor, type ClipEngineContract, ClipPointerHandler, type ClipPointerHost, type DawClipConnectedDetail, DawClipElement, type DawClipErrorDetail, type DawClipIdDetail, type DawClipMoveDetail, type DawClipSplitDetail, type DawClipTrimDetail, type DawClipUpdateDetail, DawEditorElement, type DawEffectAddDetail, type DawEffectBypassDetail, type DawEffectChangeDetail, type DawEffectErrorDetail, type DawEffectRemoveDetail, type DawEffectReorderDetail, type DawErrorDetail, type DawEvent, type DawEventMap, type DawFilesLoadErrorDetail, DawGridElement, DawKeyboardShortcutsElement, DawPauseButtonElement, DawPianoRollElement, DawPlayButtonElement, DawPlayerElement, DawPlayheadElement, DawRecordButtonElement, type DawRecordingCompleteDetail, type DawRecordingErrorDetail, type DawRecordingStartDetail, DawRulerElement, type DawSeekDetail, type DawSelectionDetail, DawSelectionElement, DawSpectrogramElement, DawStopButtonElement, DawTimeDisplayElement, type DawTimeFormatChangeDetail, DawTimeFormatElement, type DawTimeUpdateDetail, type DawTrackConnectedDetail, type DawTrackControlDetail, DawTrackControlsElement, DawTrackElement, type DawTrackErrorDetail, type DawTrackIdDetail, type DawTrackRemoveDetail, type DawTrackSelectDetail, DawTransportButton, DawTransportElement, DawWaveformElement, type DomClipDescriptor, type DropClipDescriptor, type EffectDefinition, type EffectInstance, type EffectParamDef, type EffectState, type ExportAudioHost, type ExportOptions, type KeyBinding, type LoadFilesResult, PlaybackAnimationController, type PlaybackAnimationOptions, type PlaybackShortcutMap, type PlayheadLike, type PointerEngineContract, RecordingController, type RecordingOptions, type RecordingSession, type SerializedEffectEntry, SpectrogramController, type SplitEngineContract, type SplitHost, type SplittingShortcutMap, TIME_DISPLAY_FORMATS, type TimeDisplayFormat, type TrackConfig, type TrackDescriptor, type TrackRenderMode, type TrackWithId, type UndoShortcutMap, type WaveformSegment, createEffectInstance, formatDisplayTime, getEffectDefinitions, isDomClip, isTimeDisplayFormat, parseDisplayTime, registerEffect, resolveTransportTarget, splitAtPlayhead, targetSupports, warnOnce, warnUnsupportedOnce };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(index_exports, {
|
|
|
47
47
|
DawPauseButtonElement: () => DawPauseButtonElement,
|
|
48
48
|
DawPianoRollElement: () => DawPianoRollElement,
|
|
49
49
|
DawPlayButtonElement: () => DawPlayButtonElement,
|
|
50
|
+
DawPlayerElement: () => DawPlayerElement,
|
|
50
51
|
DawPlayheadElement: () => DawPlayheadElement,
|
|
51
52
|
DawRecordButtonElement: () => DawRecordButtonElement,
|
|
52
53
|
DawRulerElement: () => DawRulerElement,
|
|
@@ -3195,8 +3196,8 @@ var SpectrogramController = class {
|
|
|
3195
3196
|
unregisterCanvas(canvasId) {
|
|
3196
3197
|
this.orchestrator?.unregisterCanvas(canvasId);
|
|
3197
3198
|
}
|
|
3198
|
-
setViewport(
|
|
3199
|
-
this.orchestrator?.setViewport(
|
|
3199
|
+
setViewport(state8) {
|
|
3200
|
+
this.orchestrator?.setViewport(state8);
|
|
3200
3201
|
}
|
|
3201
3202
|
dispose() {
|
|
3202
3203
|
if (this.orchestrator) {
|
|
@@ -4150,9 +4151,9 @@ function splitAtPlayhead(host) {
|
|
|
4150
4151
|
function canSplitAtTime(host, time) {
|
|
4151
4152
|
const { engine } = host;
|
|
4152
4153
|
if (!engine) return false;
|
|
4153
|
-
const
|
|
4154
|
-
if (!
|
|
4155
|
-
const track =
|
|
4154
|
+
const state8 = engine.getState();
|
|
4155
|
+
if (!state8.selectedTrackId) return false;
|
|
4156
|
+
const track = state8.tracks.find((t) => t.id === state8.selectedTrackId);
|
|
4156
4157
|
if (!track) return false;
|
|
4157
4158
|
const atSample = Math.round(time * host.effectiveSampleRate);
|
|
4158
4159
|
const clip = findClipAtSample(track.clips, atSample);
|
|
@@ -4342,9 +4343,9 @@ var EffectsChainController = class {
|
|
|
4342
4343
|
...entry.placeholder.state !== void 0 ? { state: entry.placeholder.state } : {}
|
|
4343
4344
|
};
|
|
4344
4345
|
}
|
|
4345
|
-
let
|
|
4346
|
+
let state8;
|
|
4346
4347
|
try {
|
|
4347
|
-
|
|
4348
|
+
state8 = await entry.instance.getState?.();
|
|
4348
4349
|
} catch (err) {
|
|
4349
4350
|
console.warn(
|
|
4350
4351
|
'[waveform-playlist] serialize: plugin "' + (entry.url ?? entry.label ?? entry.type) + '" getState failed: ' + String(err)
|
|
@@ -4354,7 +4355,7 @@ var EffectsChainController = class {
|
|
|
4354
4355
|
kind: "wam",
|
|
4355
4356
|
...sourceFields,
|
|
4356
4357
|
bypassed: entry.bypassed,
|
|
4357
|
-
...
|
|
4358
|
+
...state8 !== void 0 ? { state: state8 } : {}
|
|
4358
4359
|
};
|
|
4359
4360
|
}
|
|
4360
4361
|
return {
|
|
@@ -4649,6 +4650,8 @@ var EffectsManager = class {
|
|
|
4649
4650
|
/** Live WAM plugin nodes across all chains, fed to the wam-transport bridge. */
|
|
4650
4651
|
this._wamNodes = /* @__PURE__ */ new Set();
|
|
4651
4652
|
this._transportBridge = null;
|
|
4653
|
+
/** One-time warn when the adapter transport can't host the wam-transport bridge. */
|
|
4654
|
+
this._transportBridgeWarned = false;
|
|
4652
4655
|
this._getAdapter = getAdapter;
|
|
4653
4656
|
this._masterTarget = masterEventTarget;
|
|
4654
4657
|
}
|
|
@@ -5055,15 +5058,21 @@ var EffectsManager = class {
|
|
|
5055
5058
|
}
|
|
5056
5059
|
/**
|
|
5057
5060
|
* Lazily create the wam-transport bridge so tempo-synced plugins lock to
|
|
5058
|
-
* the timeline. Skipped (not an error) when the adapter's
|
|
5059
|
-
* the query/event surface — the bridge is an enhancement,
|
|
5060
|
-
* requirement for audio processing.
|
|
5061
|
+
* the timeline. Skipped (not an error, one-time warn) when the adapter's
|
|
5062
|
+
* transport lacks the query/event surface — the bridge is an enhancement,
|
|
5063
|
+
* not a requirement for audio processing.
|
|
5061
5064
|
*/
|
|
5062
5065
|
_ensureTransportBridge(wamModule) {
|
|
5063
5066
|
if (this._transportBridge) return this._transportBridge;
|
|
5064
5067
|
if (typeof wamModule.createWamTransportBridge !== "function") return null;
|
|
5065
5068
|
const transport = this._getAdapter()?.transport;
|
|
5066
5069
|
if (!transport || typeof transport.on !== "function" || typeof transport.getTempo !== "function" || typeof transport.tickToBar !== "function" || typeof transport.timeToTick !== "function") {
|
|
5070
|
+
if (!this._transportBridgeWarned) {
|
|
5071
|
+
this._transportBridgeWarned = true;
|
|
5072
|
+
console.warn(
|
|
5073
|
+
"[waveform-playlist] wam-transport bridge skipped: the adapter transport does not implement the query surface (on/getTempo/tickToBar/timeToTick), so WAM plugins won't receive transport/tempo events. Use NativePlayoutAdapter for transport sync \u2014 see issue #537."
|
|
5074
|
+
);
|
|
5075
|
+
}
|
|
5067
5076
|
return null;
|
|
5068
5077
|
}
|
|
5069
5078
|
this._transportBridge = wamModule.createWamTransportBridge(transport, () => [
|
|
@@ -8784,6 +8793,319 @@ __decorateClass([
|
|
|
8784
8793
|
DawTimeFormatElement = __decorateClass([
|
|
8785
8794
|
(0, import_decorators19.customElement)("daw-time-format")
|
|
8786
8795
|
], DawTimeFormatElement);
|
|
8796
|
+
|
|
8797
|
+
// src/elements/daw-player.ts
|
|
8798
|
+
var import_lit22 = require("lit");
|
|
8799
|
+
var import_decorators20 = require("lit/decorators.js");
|
|
8800
|
+
var import_repeat = require("lit/directives/repeat.js");
|
|
8801
|
+
var import_media_element_playout = require("@waveform-playlist/media-element-playout");
|
|
8802
|
+
var MIN_RATE = 0.25;
|
|
8803
|
+
var MAX_RATE = 4;
|
|
8804
|
+
var DawPlayerElement = class extends import_lit22.LitElement {
|
|
8805
|
+
constructor() {
|
|
8806
|
+
super(...arguments);
|
|
8807
|
+
this.src = "";
|
|
8808
|
+
this.peaksSrc = "";
|
|
8809
|
+
this.waveHeight = 128;
|
|
8810
|
+
this.timescale = false;
|
|
8811
|
+
this.mono = false;
|
|
8812
|
+
this.barWidth = 1;
|
|
8813
|
+
this.barGap = 0;
|
|
8814
|
+
this._playbackRate = 1;
|
|
8815
|
+
this._engine = new import_media_element_playout.MediaElementPlayout();
|
|
8816
|
+
this._trackId = null;
|
|
8817
|
+
this._anim = new AnimationController(this);
|
|
8818
|
+
this._metadataLoaded = false;
|
|
8819
|
+
this._readyDispatched = false;
|
|
8820
|
+
/** True once peaks resolution is complete: succeeded, failed, or no peaks-src set. */
|
|
8821
|
+
this._peaksSettled = false;
|
|
8822
|
+
this._waveformData = null;
|
|
8823
|
+
this._channelPeaks = [];
|
|
8824
|
+
this._sampleRate = 48e3;
|
|
8825
|
+
this._resizeObserver = null;
|
|
8826
|
+
this._onPointerDown = (e) => {
|
|
8827
|
+
const area = e.currentTarget;
|
|
8828
|
+
const width = area.clientWidth;
|
|
8829
|
+
const d = this._engine.duration;
|
|
8830
|
+
if (width <= 0 || d <= 0) return;
|
|
8831
|
+
const ratio = Math.max(0, Math.min(1, e.offsetX / width));
|
|
8832
|
+
this.seekTo(ratio * d);
|
|
8833
|
+
this._updatePlayhead();
|
|
8834
|
+
};
|
|
8835
|
+
this._onLoadedMetadata = () => {
|
|
8836
|
+
this._metadataLoaded = true;
|
|
8837
|
+
this.requestUpdate();
|
|
8838
|
+
this._maybeDispatchReady();
|
|
8839
|
+
};
|
|
8840
|
+
this._onPlay = () => {
|
|
8841
|
+
this._dispatch("daw-play");
|
|
8842
|
+
this._anim.start(this._frame);
|
|
8843
|
+
};
|
|
8844
|
+
this._onPause = () => {
|
|
8845
|
+
this._anim.stop();
|
|
8846
|
+
this._updatePlayhead();
|
|
8847
|
+
this._dispatch("daw-pause");
|
|
8848
|
+
};
|
|
8849
|
+
this._onEnded = () => {
|
|
8850
|
+
this._anim.stop();
|
|
8851
|
+
this._updatePlayhead();
|
|
8852
|
+
this._dispatch("daw-ended");
|
|
8853
|
+
};
|
|
8854
|
+
this._onError = (err) => {
|
|
8855
|
+
console.warn("[dawcore] <daw-player> failed to load src: " + (err?.message ?? "unknown"));
|
|
8856
|
+
this._dispatch("daw-error", { operation: "load", error: err });
|
|
8857
|
+
};
|
|
8858
|
+
/** rAF tick while playing: positions the playhead and emits daw-timeupdate. */
|
|
8859
|
+
this._frame = () => {
|
|
8860
|
+
this._updatePlayhead();
|
|
8861
|
+
this._dispatch("daw-timeupdate", { time: this._engine.getCurrentTime() });
|
|
8862
|
+
};
|
|
8863
|
+
}
|
|
8864
|
+
get playbackRate() {
|
|
8865
|
+
return this._playbackRate;
|
|
8866
|
+
}
|
|
8867
|
+
set playbackRate(value) {
|
|
8868
|
+
const valid = Number.isFinite(value);
|
|
8869
|
+
if (!valid || value < MIN_RATE || value > MAX_RATE) {
|
|
8870
|
+
console.warn(
|
|
8871
|
+
"[dawcore] <daw-player> playback-rate " + value + " out of range " + MIN_RATE + "\u2013" + MAX_RATE + " \u2014 clamping"
|
|
8872
|
+
);
|
|
8873
|
+
}
|
|
8874
|
+
const clamped = Math.max(MIN_RATE, Math.min(MAX_RATE, valid ? value : 1));
|
|
8875
|
+
const old = this._playbackRate;
|
|
8876
|
+
this._playbackRate = clamped;
|
|
8877
|
+
this.requestUpdate("playbackRate", old);
|
|
8878
|
+
}
|
|
8879
|
+
connectedCallback() {
|
|
8880
|
+
super.connectedCallback();
|
|
8881
|
+
this._engine.on("loadedmetadata", this._onLoadedMetadata);
|
|
8882
|
+
this._engine.on("play", this._onPlay);
|
|
8883
|
+
this._engine.on("pause", this._onPause);
|
|
8884
|
+
this._engine.on("ended", this._onEnded);
|
|
8885
|
+
this._engine.on("error", this._onError);
|
|
8886
|
+
this._resizeObserver = new ResizeObserver(() => this._renderWaveform());
|
|
8887
|
+
requestAnimationFrame(() => {
|
|
8888
|
+
const area = this.shadowRoot?.querySelector(".waveform-area");
|
|
8889
|
+
if (area) this._resizeObserver?.observe(area);
|
|
8890
|
+
});
|
|
8891
|
+
}
|
|
8892
|
+
render() {
|
|
8893
|
+
const width = this._timelineWidth;
|
|
8894
|
+
const channels = this._channelPeaks.length;
|
|
8895
|
+
const channelHeight = channels > 0 ? this.waveHeight / channels : this.waveHeight;
|
|
8896
|
+
return import_lit22.html`
|
|
8897
|
+
${this.timescale ? import_lit22.html`<daw-ruler
|
|
8898
|
+
.samplesPerPixel=${this._channelSpp(width)}
|
|
8899
|
+
.sampleRate=${this._sampleRate}
|
|
8900
|
+
.duration=${this._engine.duration}
|
|
8901
|
+
.totalWidth=${width}
|
|
8902
|
+
></daw-ruler>` : null}
|
|
8903
|
+
<div
|
|
8904
|
+
class="waveform-area"
|
|
8905
|
+
style="height:${this.waveHeight}px"
|
|
8906
|
+
@pointerdown=${this._onPointerDown}
|
|
8907
|
+
>
|
|
8908
|
+
${(0, import_repeat.repeat)(
|
|
8909
|
+
this._channelPeaks,
|
|
8910
|
+
(_p, i) => i,
|
|
8911
|
+
(peaks) => import_lit22.html`<daw-waveform
|
|
8912
|
+
.peaks=${peaks}
|
|
8913
|
+
.length=${width}
|
|
8914
|
+
.waveHeight=${channelHeight}
|
|
8915
|
+
.barWidth=${this.barWidth}
|
|
8916
|
+
.barGap=${this.barGap}
|
|
8917
|
+
></daw-waveform>`
|
|
8918
|
+
)}
|
|
8919
|
+
<daw-playhead></daw-playhead>
|
|
8920
|
+
</div>
|
|
8921
|
+
`;
|
|
8922
|
+
}
|
|
8923
|
+
updated(changed) {
|
|
8924
|
+
if (changed.has("src")) this._loadSource();
|
|
8925
|
+
if (changed.has("playbackRate")) this._engine.setPlaybackRate(this._playbackRate);
|
|
8926
|
+
if (changed.has("peaksSrc")) this._loadPeaks();
|
|
8927
|
+
if (changed.has("mono")) this._renderWaveform();
|
|
8928
|
+
}
|
|
8929
|
+
async _loadPeaks() {
|
|
8930
|
+
this._waveformData = null;
|
|
8931
|
+
this._readyDispatched = false;
|
|
8932
|
+
this._peaksSettled = false;
|
|
8933
|
+
if (!this.peaksSrc) {
|
|
8934
|
+
this._peaksSettled = true;
|
|
8935
|
+
this._renderWaveform();
|
|
8936
|
+
this._maybeDispatchReady();
|
|
8937
|
+
return;
|
|
8938
|
+
}
|
|
8939
|
+
const requested = this.peaksSrc;
|
|
8940
|
+
try {
|
|
8941
|
+
const wd = await loadWaveformDataFromUrl(requested);
|
|
8942
|
+
if (this.peaksSrc !== requested) return;
|
|
8943
|
+
this._waveformData = wd;
|
|
8944
|
+
this._sampleRate = wd.sample_rate;
|
|
8945
|
+
this._peaksSettled = true;
|
|
8946
|
+
this._renderWaveform();
|
|
8947
|
+
this._maybeDispatchReady();
|
|
8948
|
+
} catch (err) {
|
|
8949
|
+
console.warn("[dawcore] <daw-player> failed to load peaks-src: " + String(err));
|
|
8950
|
+
this._peaksSettled = true;
|
|
8951
|
+
this._renderWaveform();
|
|
8952
|
+
this._maybeDispatchReady();
|
|
8953
|
+
}
|
|
8954
|
+
}
|
|
8955
|
+
/** Recompute fit-to-width peaks from the loaded WaveformData. No-op without data. */
|
|
8956
|
+
_renderWaveform() {
|
|
8957
|
+
const wd = this._waveformData;
|
|
8958
|
+
const width = this._timelineWidth;
|
|
8959
|
+
if (!wd || width <= 0) {
|
|
8960
|
+
if (this._channelPeaks.length > 0) this._channelPeaks = [];
|
|
8961
|
+
return;
|
|
8962
|
+
}
|
|
8963
|
+
const totalSamples = wd.length * wd.scale;
|
|
8964
|
+
const samplesPerPixel = Math.max(wd.scale, Math.ceil(totalSamples / width));
|
|
8965
|
+
const peakData = extractPeaks(wd, samplesPerPixel, this.mono);
|
|
8966
|
+
this._channelPeaks = peakData.data;
|
|
8967
|
+
}
|
|
8968
|
+
/**
|
|
8969
|
+
* Samples-per-pixel used by the ruler so its time labels span the full width.
|
|
8970
|
+
* This is intentionally a separate time-based SPP (duration × sampleRate / width)
|
|
8971
|
+
* for the ruler labels — equivalent to the waveform SPP when the WaveformData spans
|
|
8972
|
+
* the full audio duration; may differ for pre-trimmed peaks.
|
|
8973
|
+
*/
|
|
8974
|
+
_channelSpp(width) {
|
|
8975
|
+
const d = this._engine.duration;
|
|
8976
|
+
if (d <= 0 || width <= 0) return 1;
|
|
8977
|
+
return Math.max(1, Math.ceil(d * this._sampleRate / width));
|
|
8978
|
+
}
|
|
8979
|
+
_loadSource() {
|
|
8980
|
+
if (!this.src) return;
|
|
8981
|
+
this._metadataLoaded = false;
|
|
8982
|
+
this._readyDispatched = false;
|
|
8983
|
+
const track = this._engine.setSource({ source: this.src });
|
|
8984
|
+
this._trackId = track.id;
|
|
8985
|
+
this._engine.setPlaybackRate(this._playbackRate);
|
|
8986
|
+
}
|
|
8987
|
+
// --- Transport methods ---
|
|
8988
|
+
play() {
|
|
8989
|
+
this._engine.play();
|
|
8990
|
+
}
|
|
8991
|
+
pause() {
|
|
8992
|
+
this._engine.pause();
|
|
8993
|
+
}
|
|
8994
|
+
stop() {
|
|
8995
|
+
this._engine.stop();
|
|
8996
|
+
this._anim.stop();
|
|
8997
|
+
this._updatePlayhead();
|
|
8998
|
+
this._dispatch("daw-stop");
|
|
8999
|
+
}
|
|
9000
|
+
seekTo(time) {
|
|
9001
|
+
this._engine.seekTo(time);
|
|
9002
|
+
}
|
|
9003
|
+
setPlaybackRate(rate) {
|
|
9004
|
+
this.playbackRate = rate;
|
|
9005
|
+
}
|
|
9006
|
+
setVolume(volume) {
|
|
9007
|
+
this._engine.setMasterVolume(volume);
|
|
9008
|
+
}
|
|
9009
|
+
// --- Properties ---
|
|
9010
|
+
get isPlaying() {
|
|
9011
|
+
return this._engine.isPlaying;
|
|
9012
|
+
}
|
|
9013
|
+
get duration() {
|
|
9014
|
+
return this._engine.duration;
|
|
9015
|
+
}
|
|
9016
|
+
get currentTime() {
|
|
9017
|
+
return this._engine.getCurrentTime();
|
|
9018
|
+
}
|
|
9019
|
+
set currentTime(time) {
|
|
9020
|
+
this._engine.seekTo(time);
|
|
9021
|
+
}
|
|
9022
|
+
get volume() {
|
|
9023
|
+
return this._engine.masterVolume;
|
|
9024
|
+
}
|
|
9025
|
+
set volume(value) {
|
|
9026
|
+
this._engine.setMasterVolume(value);
|
|
9027
|
+
}
|
|
9028
|
+
get audioElement() {
|
|
9029
|
+
return this._trackId ? this._engine.getTrack(this._trackId)?.element ?? null : null;
|
|
9030
|
+
}
|
|
9031
|
+
disconnectedCallback() {
|
|
9032
|
+
super.disconnectedCallback();
|
|
9033
|
+
this._anim.stop();
|
|
9034
|
+
this._resizeObserver?.disconnect();
|
|
9035
|
+
this._resizeObserver = null;
|
|
9036
|
+
this._engine.off("loadedmetadata", this._onLoadedMetadata);
|
|
9037
|
+
this._engine.off("play", this._onPlay);
|
|
9038
|
+
this._engine.off("pause", this._onPause);
|
|
9039
|
+
this._engine.off("ended", this._onEnded);
|
|
9040
|
+
this._engine.off("error", this._onError);
|
|
9041
|
+
this._engine.dispose();
|
|
9042
|
+
}
|
|
9043
|
+
// --- Private event handlers (arrow fields for stable identity) ---
|
|
9044
|
+
_dispatch(name, detail) {
|
|
9045
|
+
this.dispatchEvent(new CustomEvent(name, { bubbles: true, composed: true, detail }));
|
|
9046
|
+
}
|
|
9047
|
+
_maybeDispatchReady() {
|
|
9048
|
+
if (this._readyDispatched) return;
|
|
9049
|
+
if (this._metadataLoaded && this._peaksSettled) {
|
|
9050
|
+
this._readyDispatched = true;
|
|
9051
|
+
this._dispatch("daw-ready");
|
|
9052
|
+
}
|
|
9053
|
+
}
|
|
9054
|
+
get _playhead() {
|
|
9055
|
+
return this.shadowRoot?.querySelector("daw-playhead") ?? null;
|
|
9056
|
+
}
|
|
9057
|
+
_updatePlayhead() {
|
|
9058
|
+
const d = this._engine.duration;
|
|
9059
|
+
if (d <= 0) return;
|
|
9060
|
+
const px = this._engine.getCurrentTime() / d * this._timelineWidth;
|
|
9061
|
+
this._playhead?.setPosition(px);
|
|
9062
|
+
}
|
|
9063
|
+
get _timelineWidth() {
|
|
9064
|
+
return this.shadowRoot?.querySelector(".waveform-area")?.clientWidth ?? 0;
|
|
9065
|
+
}
|
|
9066
|
+
};
|
|
9067
|
+
DawPlayerElement.styles = import_lit22.css`
|
|
9068
|
+
:host {
|
|
9069
|
+
display: block;
|
|
9070
|
+
position: relative;
|
|
9071
|
+
background: var(--daw-background, #1a1a2e);
|
|
9072
|
+
}
|
|
9073
|
+
.waveform-area {
|
|
9074
|
+
position: relative;
|
|
9075
|
+
width: 100%;
|
|
9076
|
+
overflow: hidden;
|
|
9077
|
+
}
|
|
9078
|
+
`;
|
|
9079
|
+
__decorateClass([
|
|
9080
|
+
(0, import_decorators20.property)({ type: String })
|
|
9081
|
+
], DawPlayerElement.prototype, "src", 2);
|
|
9082
|
+
__decorateClass([
|
|
9083
|
+
(0, import_decorators20.property)({ type: String, attribute: "peaks-src" })
|
|
9084
|
+
], DawPlayerElement.prototype, "peaksSrc", 2);
|
|
9085
|
+
__decorateClass([
|
|
9086
|
+
(0, import_decorators20.property)({ type: Number, attribute: "wave-height" })
|
|
9087
|
+
], DawPlayerElement.prototype, "waveHeight", 2);
|
|
9088
|
+
__decorateClass([
|
|
9089
|
+
(0, import_decorators20.property)({ type: Boolean })
|
|
9090
|
+
], DawPlayerElement.prototype, "timescale", 2);
|
|
9091
|
+
__decorateClass([
|
|
9092
|
+
(0, import_decorators20.property)({ type: Boolean })
|
|
9093
|
+
], DawPlayerElement.prototype, "mono", 2);
|
|
9094
|
+
__decorateClass([
|
|
9095
|
+
(0, import_decorators20.property)({ type: Number, attribute: "bar-width" })
|
|
9096
|
+
], DawPlayerElement.prototype, "barWidth", 2);
|
|
9097
|
+
__decorateClass([
|
|
9098
|
+
(0, import_decorators20.property)({ type: Number, attribute: "bar-gap" })
|
|
9099
|
+
], DawPlayerElement.prototype, "barGap", 2);
|
|
9100
|
+
__decorateClass([
|
|
9101
|
+
(0, import_decorators20.property)({ type: Number, attribute: "playback-rate", noAccessor: true })
|
|
9102
|
+
], DawPlayerElement.prototype, "playbackRate", 1);
|
|
9103
|
+
__decorateClass([
|
|
9104
|
+
(0, import_decorators20.state)()
|
|
9105
|
+
], DawPlayerElement.prototype, "_channelPeaks", 2);
|
|
9106
|
+
DawPlayerElement = __decorateClass([
|
|
9107
|
+
(0, import_decorators20.customElement)("daw-player")
|
|
9108
|
+
], DawPlayerElement);
|
|
8787
9109
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8788
9110
|
0 && (module.exports = {
|
|
8789
9111
|
AudioResumeController,
|
|
@@ -8795,6 +9117,7 @@ DawTimeFormatElement = __decorateClass([
|
|
|
8795
9117
|
DawPauseButtonElement,
|
|
8796
9118
|
DawPianoRollElement,
|
|
8797
9119
|
DawPlayButtonElement,
|
|
9120
|
+
DawPlayerElement,
|
|
8798
9121
|
DawPlayheadElement,
|
|
8799
9122
|
DawRecordButtonElement,
|
|
8800
9123
|
DawRulerElement,
|