@dawcore/components 0.0.32 → 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 +161 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +162 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.mjs
CHANGED
|
@@ -2747,6 +2747,11 @@ import {
|
|
|
2747
2747
|
var RecordingController = class {
|
|
2748
2748
|
constructor(host) {
|
|
2749
2749
|
this._sessions = /* @__PURE__ */ new Map();
|
|
2750
|
+
/** Track IDs with a startRecording in flight (session not yet in _sessions).
|
|
2751
|
+
* The session is only set after several awaits — without this, two rapid
|
|
2752
|
+
* start calls both pass the _sessions guard and build two capture
|
|
2753
|
+
* pipelines feeding one session (garbled audio + a leaked worklet). */
|
|
2754
|
+
this._starting = /* @__PURE__ */ new Set();
|
|
2750
2755
|
this._workletLoadedCtx = null;
|
|
2751
2756
|
/** Tracks worklet pause state explicitly so external consumers (editor,
|
|
2752
2757
|
* pause button, spacebar) can share one source of truth. */
|
|
@@ -2758,7 +2763,7 @@ var RecordingController = class {
|
|
|
2758
2763
|
}
|
|
2759
2764
|
hostDisconnected() {
|
|
2760
2765
|
for (const trackId of [...this._sessions.keys()]) {
|
|
2761
|
-
this._cleanupSession(trackId);
|
|
2766
|
+
this._cleanupSession(trackId, true);
|
|
2762
2767
|
}
|
|
2763
2768
|
this._workletLoadedCtx = null;
|
|
2764
2769
|
}
|
|
@@ -2777,14 +2782,18 @@ var RecordingController = class {
|
|
|
2777
2782
|
console.warn("[dawcore] RecordingController: No track selected for recording");
|
|
2778
2783
|
return;
|
|
2779
2784
|
}
|
|
2780
|
-
if (this._sessions.has(trackId)) {
|
|
2785
|
+
if (this._sessions.has(trackId) || this._starting.has(trackId)) {
|
|
2781
2786
|
console.warn('[dawcore] RecordingController: Already recording on track "' + trackId + '"');
|
|
2782
2787
|
return;
|
|
2783
2788
|
}
|
|
2789
|
+
this._starting.add(trackId);
|
|
2784
2790
|
const bits = options.bits ?? 16;
|
|
2785
2791
|
try {
|
|
2786
2792
|
const rawCtx = this._host.audioContext;
|
|
2787
2793
|
this._host.resolveAudioContextSampleRate(rawCtx.sampleRate);
|
|
2794
|
+
if (rawCtx.state === "suspended") {
|
|
2795
|
+
await rawCtx.resume();
|
|
2796
|
+
}
|
|
2788
2797
|
if (!this._workletLoadedCtx || this._workletLoadedCtx !== rawCtx) {
|
|
2789
2798
|
let addRecordingWorkletModule;
|
|
2790
2799
|
try {
|
|
@@ -2805,7 +2814,7 @@ var RecordingController = class {
|
|
|
2805
2814
|
);
|
|
2806
2815
|
}
|
|
2807
2816
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
2808
|
-
const startSample = options.startSample ?? Math.floor(this._host.
|
|
2817
|
+
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
2809
2818
|
const latencySamples = resolveRecordingOffsetSamples({
|
|
2810
2819
|
overrideSeconds: options.latencyOffset,
|
|
2811
2820
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
@@ -2839,13 +2848,17 @@ var RecordingController = class {
|
|
|
2839
2848
|
),
|
|
2840
2849
|
startSample,
|
|
2841
2850
|
channelCount,
|
|
2851
|
+
captureSampleRate: rawCtx.sampleRate,
|
|
2842
2852
|
bits,
|
|
2843
2853
|
isFirstMessage: true,
|
|
2844
2854
|
latencySamples,
|
|
2855
|
+
clipName: options.clipName,
|
|
2856
|
+
armedPrevMuted: null,
|
|
2845
2857
|
wasOverdub: options.overdub ?? false,
|
|
2846
2858
|
_onTrackEnded: onTrackEnded,
|
|
2847
2859
|
_audioTrack: audioTrack,
|
|
2848
2860
|
stopAckResolve: null,
|
|
2861
|
+
stopPromise: null,
|
|
2849
2862
|
stopping: false
|
|
2850
2863
|
};
|
|
2851
2864
|
this._sessions.set(trackId, session);
|
|
@@ -2857,6 +2870,11 @@ var RecordingController = class {
|
|
|
2857
2870
|
if (audioTrack && onTrackEnded) {
|
|
2858
2871
|
audioTrack.addEventListener("ended", onTrackEnded);
|
|
2859
2872
|
}
|
|
2873
|
+
const engine = this._host._engine;
|
|
2874
|
+
if (engine) {
|
|
2875
|
+
session.armedPrevMuted = engine.getState().tracks.find((t) => t.id === trackId)?.muted ?? false;
|
|
2876
|
+
engine.setTrackMute(trackId, true);
|
|
2877
|
+
}
|
|
2860
2878
|
this._host.dispatchEvent(
|
|
2861
2879
|
new CustomEvent("daw-recording-start", {
|
|
2862
2880
|
bubbles: true,
|
|
@@ -2866,7 +2884,7 @@ var RecordingController = class {
|
|
|
2866
2884
|
);
|
|
2867
2885
|
this._host.requestUpdate();
|
|
2868
2886
|
if (options.overdub && typeof this._host.play === "function") {
|
|
2869
|
-
await this._host.play(this._host.
|
|
2887
|
+
await this._host.play(this._host.currentTime);
|
|
2870
2888
|
}
|
|
2871
2889
|
} catch (err) {
|
|
2872
2890
|
this._cleanupSession(trackId);
|
|
@@ -2878,6 +2896,8 @@ var RecordingController = class {
|
|
|
2878
2896
|
detail: { trackId, error: err }
|
|
2879
2897
|
})
|
|
2880
2898
|
);
|
|
2899
|
+
} finally {
|
|
2900
|
+
this._starting.delete(trackId);
|
|
2881
2901
|
}
|
|
2882
2902
|
}
|
|
2883
2903
|
pauseRecording(trackId) {
|
|
@@ -2915,14 +2935,23 @@ var RecordingController = class {
|
|
|
2915
2935
|
if (!id) return;
|
|
2916
2936
|
const session = this._sessions.get(id);
|
|
2917
2937
|
if (!session) return;
|
|
2938
|
+
if (session.stopping) {
|
|
2939
|
+
return session.stopPromise ?? void 0;
|
|
2940
|
+
}
|
|
2941
|
+
session.stopping = true;
|
|
2942
|
+
const stopPromise = this._finishStopRecording(id, session);
|
|
2943
|
+
session.stopPromise = stopPromise;
|
|
2944
|
+
return stopPromise;
|
|
2945
|
+
}
|
|
2946
|
+
async _finishStopRecording(id, session) {
|
|
2918
2947
|
const wasPaused = this._isPaused;
|
|
2919
2948
|
this._isPaused = false;
|
|
2920
|
-
session.stopping = true;
|
|
2921
2949
|
if (session.wasOverdub && typeof this._host.stop === "function") {
|
|
2922
2950
|
this._host.stop();
|
|
2923
2951
|
}
|
|
2924
2952
|
if (wasPaused) {
|
|
2925
2953
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
2954
|
+
await this._drainWorkletQueue(session);
|
|
2926
2955
|
} else {
|
|
2927
2956
|
const stopAck = new Promise((resolve) => {
|
|
2928
2957
|
session.stopAckResolve = resolve;
|
|
@@ -2935,17 +2964,7 @@ var RecordingController = class {
|
|
|
2935
2964
|
await Promise.race([stopAck, timeout]);
|
|
2936
2965
|
clearTimeout(timeoutId);
|
|
2937
2966
|
session.stopAckResolve = null;
|
|
2938
|
-
|
|
2939
|
-
let stable = 0;
|
|
2940
|
-
for (let i = 0; i < 50; i++) {
|
|
2941
|
-
if (session.totalSamples === lastSamples) {
|
|
2942
|
-
if (++stable >= 3) break;
|
|
2943
|
-
} else {
|
|
2944
|
-
stable = 0;
|
|
2945
|
-
lastSamples = session.totalSamples;
|
|
2946
|
-
}
|
|
2947
|
-
await new Promise((r) => setTimeout(r, 5));
|
|
2948
|
-
}
|
|
2967
|
+
await this._drainWorkletQueue(session);
|
|
2949
2968
|
}
|
|
2950
2969
|
session.source.disconnect();
|
|
2951
2970
|
session.workletNode.disconnect();
|
|
@@ -2968,13 +2987,14 @@ var RecordingController = class {
|
|
|
2968
2987
|
const audioBuffer = createAudioBuffer(
|
|
2969
2988
|
stopCtx,
|
|
2970
2989
|
channelData,
|
|
2971
|
-
|
|
2990
|
+
session.captureSampleRate,
|
|
2972
2991
|
session.channelCount
|
|
2973
2992
|
);
|
|
2974
2993
|
const latencyOffsetSamples = session.latencySamples;
|
|
2975
2994
|
const effectiveDuration = Math.max(0, audioBuffer.length - latencyOffsetSamples);
|
|
2976
2995
|
if (effectiveDuration === 0) {
|
|
2977
2996
|
console.warn("[dawcore] RecordingController: Recording too short for latency compensation");
|
|
2997
|
+
this._restoreArmedTrackMute(session);
|
|
2978
2998
|
this._sessions.delete(id);
|
|
2979
2999
|
this._host.requestUpdate();
|
|
2980
3000
|
this._host.dispatchEvent(
|
|
@@ -2999,6 +3019,7 @@ var RecordingController = class {
|
|
|
2999
3019
|
}
|
|
3000
3020
|
});
|
|
3001
3021
|
const notPrevented = this._host.dispatchEvent(event);
|
|
3022
|
+
this._restoreArmedTrackMute(session);
|
|
3002
3023
|
this._sessions.delete(id);
|
|
3003
3024
|
this._host.requestUpdate();
|
|
3004
3025
|
if (notPrevented) {
|
|
@@ -3007,10 +3028,29 @@ var RecordingController = class {
|
|
|
3007
3028
|
audioBuffer,
|
|
3008
3029
|
session.startSample,
|
|
3009
3030
|
effectiveDuration,
|
|
3010
|
-
latencyOffsetSamples
|
|
3031
|
+
latencyOffsetSamples,
|
|
3032
|
+
session.clipName
|
|
3011
3033
|
);
|
|
3012
3034
|
}
|
|
3013
3035
|
}
|
|
3036
|
+
/** Drain the event-loop queue of pending worklet flush messages. During
|
|
3037
|
+
* recording the worklet posts a flush every ~16ms; if main was slower,
|
|
3038
|
+
* messages back up. Yield repeatedly until session.totalSamples stabilizes
|
|
3039
|
+
* (no new messages processed) for several consecutive ticks — at that
|
|
3040
|
+
* point the queue is empty and chunks are complete. */
|
|
3041
|
+
async _drainWorkletQueue(session) {
|
|
3042
|
+
let lastSamples = -1;
|
|
3043
|
+
let stable = 0;
|
|
3044
|
+
for (let i = 0; i < 50; i++) {
|
|
3045
|
+
if (session.totalSamples === lastSamples) {
|
|
3046
|
+
if (++stable >= 3) break;
|
|
3047
|
+
} else {
|
|
3048
|
+
stable = 0;
|
|
3049
|
+
lastSamples = session.totalSamples;
|
|
3050
|
+
}
|
|
3051
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3014
3054
|
// Session fields are mutated in place on the hot path (~60fps worklet messages).
|
|
3015
3055
|
// This is intentional — creating new session objects + Map entries per message
|
|
3016
3056
|
// would cause significant GC pressure. Mutations are confined to the controller's
|
|
@@ -3046,7 +3086,10 @@ var RecordingController = class {
|
|
|
3046
3086
|
session.peaks[ch] = appendPeaks(
|
|
3047
3087
|
session.peaks[ch],
|
|
3048
3088
|
channels[ch],
|
|
3049
|
-
this
|
|
3089
|
+
// Render-space scale — in beats mode this differs from
|
|
3090
|
+
// samplesPerPixel, and the preview container is laid out in
|
|
3091
|
+
// render space (see RecordingHost.renderSamplesPerPixel).
|
|
3092
|
+
this._host.renderSamplesPerPixel,
|
|
3050
3093
|
samplesProcessedBefore,
|
|
3051
3094
|
session.bits
|
|
3052
3095
|
);
|
|
@@ -3065,22 +3108,23 @@ var RecordingController = class {
|
|
|
3065
3108
|
}
|
|
3066
3109
|
}
|
|
3067
3110
|
session.isFirstMessage = false;
|
|
3068
|
-
const newPixelWidth = Math.floor(session.totalSamples / this._host.
|
|
3111
|
+
const newPixelWidth = Math.floor(session.totalSamples / this._host.renderSamplesPerPixel);
|
|
3069
3112
|
const oldPixelWidth = Math.floor(
|
|
3070
|
-
(session.totalSamples - channels[0].length) / this._host.
|
|
3113
|
+
(session.totalSamples - channels[0].length) / this._host.renderSamplesPerPixel
|
|
3071
3114
|
);
|
|
3072
3115
|
if (newPixelWidth > oldPixelWidth) {
|
|
3073
3116
|
this._host.requestUpdate();
|
|
3074
3117
|
}
|
|
3075
3118
|
}
|
|
3076
|
-
_createClipFromRecording(trackId, audioBuffer, startSample, durationSamples, offsetSamples = 0) {
|
|
3119
|
+
_createClipFromRecording(trackId, audioBuffer, startSample, durationSamples, offsetSamples = 0, clipName) {
|
|
3077
3120
|
if (typeof this._host._addRecordedClip === "function") {
|
|
3078
3121
|
this._host._addRecordedClip(
|
|
3079
3122
|
trackId,
|
|
3080
3123
|
audioBuffer,
|
|
3081
3124
|
startSample,
|
|
3082
3125
|
durationSamples,
|
|
3083
|
-
offsetSamples
|
|
3126
|
+
offsetSamples,
|
|
3127
|
+
clipName
|
|
3084
3128
|
);
|
|
3085
3129
|
} else {
|
|
3086
3130
|
console.warn(
|
|
@@ -3093,10 +3137,21 @@ var RecordingController = class {
|
|
|
3093
3137
|
session._audioTrack.removeEventListener("ended", session._onTrackEnded);
|
|
3094
3138
|
}
|
|
3095
3139
|
}
|
|
3096
|
-
|
|
3140
|
+
/** Restore the armed track's pre-session mute state (idempotent — safe to
|
|
3141
|
+
* call from both the finalize path and _cleanupSession). */
|
|
3142
|
+
_restoreArmedTrackMute(session) {
|
|
3143
|
+
if (session.armedPrevMuted === null) return;
|
|
3144
|
+
this._host._engine?.setTrackMute(session.trackId, session.armedPrevMuted);
|
|
3145
|
+
session.armedPrevMuted = null;
|
|
3146
|
+
}
|
|
3147
|
+
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
3148
|
+
* disposal paths that would otherwise discard the session silently. The
|
|
3149
|
+
* startRecording catch path passes false (it dispatches its own error). */
|
|
3150
|
+
_cleanupSession(trackId, notifyError = false) {
|
|
3097
3151
|
const session = this._sessions.get(trackId);
|
|
3098
3152
|
if (!session) return;
|
|
3099
3153
|
try {
|
|
3154
|
+
this._restoreArmedTrackMute(session);
|
|
3100
3155
|
this._removeTrackEndedListener(session);
|
|
3101
3156
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
3102
3157
|
session.source.disconnect();
|
|
@@ -3107,6 +3162,21 @@ var RecordingController = class {
|
|
|
3107
3162
|
);
|
|
3108
3163
|
}
|
|
3109
3164
|
this._sessions.delete(trackId);
|
|
3165
|
+
if (this._sessions.size === 0) {
|
|
3166
|
+
this._isPaused = false;
|
|
3167
|
+
}
|
|
3168
|
+
if (notifyError) {
|
|
3169
|
+
this._host.dispatchEvent(
|
|
3170
|
+
new CustomEvent("daw-recording-error", {
|
|
3171
|
+
bubbles: true,
|
|
3172
|
+
composed: true,
|
|
3173
|
+
detail: {
|
|
3174
|
+
trackId,
|
|
3175
|
+
error: new Error("Recording cancelled: editor was disconnected mid-recording")
|
|
3176
|
+
}
|
|
3177
|
+
})
|
|
3178
|
+
);
|
|
3179
|
+
}
|
|
3110
3180
|
}
|
|
3111
3181
|
};
|
|
3112
3182
|
|
|
@@ -4016,8 +4086,8 @@ function stringifyReason(reason) {
|
|
|
4016
4086
|
}
|
|
4017
4087
|
|
|
4018
4088
|
// src/interactions/recording-clip.ts
|
|
4019
|
-
import { createClip as createClip2 } from "@waveform-playlist/core";
|
|
4020
|
-
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0) {
|
|
4089
|
+
import { carveClipRange, createClip as createClip2 } from "@waveform-playlist/core";
|
|
4090
|
+
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
4021
4091
|
let trimmedBuf = buf;
|
|
4022
4092
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
4023
4093
|
const trimmed = new AudioBuffer({
|
|
@@ -4038,11 +4108,10 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4038
4108
|
offsetSamples: 0,
|
|
4039
4109
|
// offset already applied by slicing
|
|
4040
4110
|
gain: 1,
|
|
4041
|
-
name: "Recording"
|
|
4111
|
+
name: clipName ?? "Recording"
|
|
4042
4112
|
});
|
|
4043
4113
|
host._clipBuffers = new Map(host._clipBuffers).set(clip.id, trimmedBuf);
|
|
4044
4114
|
host._peakPipeline.generatePeaks(trimmedBuf, host.samplesPerPixel, host.mono).then((pd) => {
|
|
4045
|
-
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
4046
4115
|
const t = host._engineTracks.get(trackId);
|
|
4047
4116
|
if (!t) {
|
|
4048
4117
|
const next = new Map(host._clipBuffers);
|
|
@@ -4050,9 +4119,13 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4050
4119
|
host._clipBuffers = next;
|
|
4051
4120
|
return;
|
|
4052
4121
|
}
|
|
4122
|
+
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
4053
4123
|
host._engineTracks = new Map(host._engineTracks).set(trackId, {
|
|
4054
4124
|
...t,
|
|
4055
|
-
|
|
4125
|
+
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
4126
|
+
// startSample + durSamples) — carve overlapped content out of the
|
|
4127
|
+
// existing clips before inserting (parity with the React provider).
|
|
4128
|
+
clips: [...carveClipRange(t.clips, startSample, startSample + durSamples), clip]
|
|
4056
4129
|
});
|
|
4057
4130
|
const desc = host._tracks.get(trackId);
|
|
4058
4131
|
if (desc) {
|
|
@@ -4065,7 +4138,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4065
4138
|
duration: durSamples / sr,
|
|
4066
4139
|
offset: 0,
|
|
4067
4140
|
gain: 1,
|
|
4068
|
-
name: "Recording",
|
|
4141
|
+
name: clipName ?? "Recording",
|
|
4069
4142
|
fadeIn: 0,
|
|
4070
4143
|
fadeOut: 0,
|
|
4071
4144
|
fadeType: "linear",
|
|
@@ -5521,7 +5594,9 @@ var AnimationController = class {
|
|
|
5521
5594
|
this._callback = callback;
|
|
5522
5595
|
const loop = () => {
|
|
5523
5596
|
this._callback?.();
|
|
5524
|
-
this.
|
|
5597
|
+
if (this._callback !== null) {
|
|
5598
|
+
this._rafId = requestAnimationFrame(loop);
|
|
5599
|
+
}
|
|
5525
5600
|
};
|
|
5526
5601
|
this._rafId = requestAnimationFrame(loop);
|
|
5527
5602
|
}
|
|
@@ -5597,6 +5672,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
5597
5672
|
this.clipHeaderHeight = 20;
|
|
5598
5673
|
this.interactiveClips = false;
|
|
5599
5674
|
this.indefinitePlayback = false;
|
|
5675
|
+
this.fillViewport = false;
|
|
5600
5676
|
this._spectrogramConfig = null;
|
|
5601
5677
|
this._spectrogramColorMap = null;
|
|
5602
5678
|
this.scaleMode = "temporal";
|
|
@@ -6294,7 +6370,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
6294
6370
|
const naturalWidth = Math.ceil(
|
|
6295
6371
|
this._duration * this.effectiveSampleRate / this.samplesPerPixel
|
|
6296
6372
|
);
|
|
6297
|
-
if (this.indefinitePlayback) {
|
|
6373
|
+
if (this.indefinitePlayback || this.fillViewport) {
|
|
6298
6374
|
return Math.max(naturalWidth, this._viewport.containerWidth);
|
|
6299
6375
|
}
|
|
6300
6376
|
return naturalWidth;
|
|
@@ -7588,8 +7664,8 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7588
7664
|
this._wasPlayingDuringRecording = false;
|
|
7589
7665
|
return this._recordingController.stopRecording();
|
|
7590
7666
|
}
|
|
7591
|
-
_addRecordedClip(trackId, buf, startSample, durSamples, offsetSamples = 0) {
|
|
7592
|
-
addRecordedClip(this, trackId, buf, startSample, durSamples, offsetSamples);
|
|
7667
|
+
_addRecordedClip(trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
7668
|
+
addRecordedClip(this, trackId, buf, startSample, durSamples, offsetSamples, clipName);
|
|
7593
7669
|
}
|
|
7594
7670
|
// --- RecordingHost bridge methods for cross-context worklet support ---
|
|
7595
7671
|
// These delegate to the adapter's context type (native or standardized-audio-context).
|
|
@@ -7620,30 +7696,47 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7620
7696
|
const latencyPixels = Math.floor(rs.latencySamples / renderSpp);
|
|
7621
7697
|
const left = Math.floor(rs.startSample / renderSpp);
|
|
7622
7698
|
const w = Math.floor(audibleSamples / renderSpp);
|
|
7623
|
-
|
|
7699
|
+
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
7700
|
+
const height = hdrH + chH * rs.peaks.length;
|
|
7701
|
+
return html10`<div
|
|
7702
|
+
class="clip-container recording-preview"
|
|
7703
|
+
style="left:${left}px;top:0;width:${w}px;height:${height}px;"
|
|
7704
|
+
>
|
|
7705
|
+
${hdrH > 0 ? html10`<div class="clip-header" data-track-id=${trackId}>
|
|
7706
|
+
<span>${rs.clipName ?? "Recording\u2026"}</span>
|
|
7707
|
+
</div>` : ""}
|
|
7708
|
+
${rs.peaks.map((chPeaks, ch) => {
|
|
7624
7709
|
const slicedPeaks = latencyPixels > 0 ? chPeaks.slice(latencyPixels * 2) : chPeaks;
|
|
7625
7710
|
return html10`
|
|
7626
|
-
|
|
7627
|
-
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
})
|
|
7711
|
+
<daw-waveform
|
|
7712
|
+
data-recording-track=${trackId}
|
|
7713
|
+
data-recording-channel=${ch}
|
|
7714
|
+
style="position:absolute;left:0;top:${hdrH + ch * chH}px;"
|
|
7715
|
+
.peaks=${slicedPeaks}
|
|
7716
|
+
.length=${w}
|
|
7717
|
+
.waveHeight=${chH}
|
|
7718
|
+
.barWidth=${this.barWidth}
|
|
7719
|
+
.barGap=${this.barGap}
|
|
7720
|
+
.roundedBars=${this.roundedBars}
|
|
7721
|
+
.visibleStart=${this._viewport.visibleStart}
|
|
7722
|
+
.visibleEnd=${this._viewport.visibleEnd}
|
|
7723
|
+
.originX=${left}
|
|
7724
|
+
></daw-waveform>
|
|
7725
|
+
`;
|
|
7726
|
+
})}
|
|
7727
|
+
</div>`;
|
|
7642
7728
|
}
|
|
7643
7729
|
_startPlayhead() {
|
|
7644
7730
|
if (!this._engine) return;
|
|
7645
7731
|
const engine = this._engine;
|
|
7646
|
-
this._playbackAnimation.start(() =>
|
|
7732
|
+
this._playbackAnimation.start(() => {
|
|
7733
|
+
if (!this.indefinitePlayback && !this.isRecording && engine.getCurrentTime() >= this._duration) {
|
|
7734
|
+
this.stop();
|
|
7735
|
+
const t = this._currentTime;
|
|
7736
|
+
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
7737
|
+
}
|
|
7738
|
+
return engine.getAudibleTime();
|
|
7739
|
+
});
|
|
7647
7740
|
}
|
|
7648
7741
|
_stopPlayhead() {
|
|
7649
7742
|
const t = this._currentTime;
|
|
@@ -7655,11 +7748,11 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7655
7748
|
}
|
|
7656
7749
|
/** True when the controls column should be rendered (and its selector is valid). */
|
|
7657
7750
|
get _showControls() {
|
|
7658
|
-
return this._getOrderedTracks().length > 0 || this.indefinitePlayback;
|
|
7751
|
+
return this._getOrderedTracks().length > 0 || this.indefinitePlayback || this.fillViewport;
|
|
7659
7752
|
}
|
|
7660
7753
|
/** True when the ruler header band should be rendered (and its selector is valid). */
|
|
7661
7754
|
get _showRuler() {
|
|
7662
|
-
return (this._getOrderedTracks().length > 0 || this.scaleMode === "beats" || this.indefinitePlayback) && this.timescale;
|
|
7755
|
+
return (this._getOrderedTracks().length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport) && this.timescale;
|
|
7663
7756
|
}
|
|
7664
7757
|
_getOrderedTracks() {
|
|
7665
7758
|
const domOrder = [...this.querySelectorAll("daw-track")].map(
|
|
@@ -7764,7 +7857,7 @@ var DawEditorElement = class extends LitElement11 {
|
|
|
7764
7857
|
.length=${this._totalWidth}
|
|
7765
7858
|
.height=${orderedTracks.length > 0 ? orderedTracks.reduce((sum, t) => sum + t.trackHeight, 0) : this._emptyGridHeight}
|
|
7766
7859
|
></daw-grid>` : ""}
|
|
7767
|
-
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback ? html10`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
7860
|
+
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ? html10`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
7768
7861
|
<daw-playhead></daw-playhead>` : ""}
|
|
7769
7862
|
${orderedTracks.map((t) => {
|
|
7770
7863
|
const channelHeight = this.waveHeight;
|
|
@@ -8030,6 +8123,9 @@ __decorateClass([
|
|
|
8030
8123
|
__decorateClass([
|
|
8031
8124
|
property9({ type: Boolean, attribute: "indefinite-playback" })
|
|
8032
8125
|
], DawEditorElement.prototype, "indefinitePlayback", 2);
|
|
8126
|
+
__decorateClass([
|
|
8127
|
+
property9({ type: Boolean, attribute: "fill-viewport" })
|
|
8128
|
+
], DawEditorElement.prototype, "fillViewport", 2);
|
|
8033
8129
|
__decorateClass([
|
|
8034
8130
|
property9({ attribute: false, noAccessor: true })
|
|
8035
8131
|
], DawEditorElement.prototype, "spectrogramConfig", 1);
|
|
@@ -8156,14 +8252,22 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8156
8252
|
}
|
|
8157
8253
|
connectedCallback() {
|
|
8158
8254
|
super.connectedCallback();
|
|
8159
|
-
requestAnimationFrame(() =>
|
|
8255
|
+
requestAnimationFrame(() => {
|
|
8256
|
+
if (!this.isConnected) return;
|
|
8257
|
+
this._ensureTargetListeners();
|
|
8258
|
+
});
|
|
8160
8259
|
}
|
|
8161
8260
|
disconnectedCallback() {
|
|
8162
8261
|
super.disconnectedCallback();
|
|
8163
8262
|
this._cleanupListeners();
|
|
8164
8263
|
}
|
|
8165
|
-
|
|
8264
|
+
updated() {
|
|
8265
|
+
this._ensureTargetListeners();
|
|
8266
|
+
}
|
|
8267
|
+
_ensureTargetListeners() {
|
|
8166
8268
|
const target = this.target;
|
|
8269
|
+
if (target === this._targetRef) return;
|
|
8270
|
+
this._cleanupListeners();
|
|
8167
8271
|
if (!target) return;
|
|
8168
8272
|
this._targetRef = target;
|
|
8169
8273
|
target.addEventListener("daw-recording-start", this._onStart);
|
|
@@ -8197,6 +8301,7 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8197
8301
|
warnNoTargetOnce(this);
|
|
8198
8302
|
return;
|
|
8199
8303
|
}
|
|
8304
|
+
this._ensureTargetListeners();
|
|
8200
8305
|
target.startRecording(target.recordingStream);
|
|
8201
8306
|
}
|
|
8202
8307
|
};
|