@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/dist/index.js
CHANGED
|
@@ -2808,6 +2808,11 @@ var import_core3 = require("@waveform-playlist/core");
|
|
|
2808
2808
|
var RecordingController = class {
|
|
2809
2809
|
constructor(host) {
|
|
2810
2810
|
this._sessions = /* @__PURE__ */ new Map();
|
|
2811
|
+
/** Track IDs with a startRecording in flight (session not yet in _sessions).
|
|
2812
|
+
* The session is only set after several awaits — without this, two rapid
|
|
2813
|
+
* start calls both pass the _sessions guard and build two capture
|
|
2814
|
+
* pipelines feeding one session (garbled audio + a leaked worklet). */
|
|
2815
|
+
this._starting = /* @__PURE__ */ new Set();
|
|
2811
2816
|
this._workletLoadedCtx = null;
|
|
2812
2817
|
/** Tracks worklet pause state explicitly so external consumers (editor,
|
|
2813
2818
|
* pause button, spacebar) can share one source of truth. */
|
|
@@ -2819,7 +2824,7 @@ var RecordingController = class {
|
|
|
2819
2824
|
}
|
|
2820
2825
|
hostDisconnected() {
|
|
2821
2826
|
for (const trackId of [...this._sessions.keys()]) {
|
|
2822
|
-
this._cleanupSession(trackId);
|
|
2827
|
+
this._cleanupSession(trackId, true);
|
|
2823
2828
|
}
|
|
2824
2829
|
this._workletLoadedCtx = null;
|
|
2825
2830
|
}
|
|
@@ -2838,14 +2843,18 @@ var RecordingController = class {
|
|
|
2838
2843
|
console.warn("[dawcore] RecordingController: No track selected for recording");
|
|
2839
2844
|
return;
|
|
2840
2845
|
}
|
|
2841
|
-
if (this._sessions.has(trackId)) {
|
|
2846
|
+
if (this._sessions.has(trackId) || this._starting.has(trackId)) {
|
|
2842
2847
|
console.warn('[dawcore] RecordingController: Already recording on track "' + trackId + '"');
|
|
2843
2848
|
return;
|
|
2844
2849
|
}
|
|
2850
|
+
this._starting.add(trackId);
|
|
2845
2851
|
const bits = options.bits ?? 16;
|
|
2846
2852
|
try {
|
|
2847
2853
|
const rawCtx = this._host.audioContext;
|
|
2848
2854
|
this._host.resolveAudioContextSampleRate(rawCtx.sampleRate);
|
|
2855
|
+
if (rawCtx.state === "suspended") {
|
|
2856
|
+
await rawCtx.resume();
|
|
2857
|
+
}
|
|
2849
2858
|
if (!this._workletLoadedCtx || this._workletLoadedCtx !== rawCtx) {
|
|
2850
2859
|
let addRecordingWorkletModule;
|
|
2851
2860
|
try {
|
|
@@ -2866,7 +2875,7 @@ var RecordingController = class {
|
|
|
2866
2875
|
);
|
|
2867
2876
|
}
|
|
2868
2877
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
2869
|
-
const startSample = options.startSample ?? Math.floor(this._host.
|
|
2878
|
+
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
2870
2879
|
const latencySamples = (0, import_core3.resolveRecordingOffsetSamples)({
|
|
2871
2880
|
overrideSeconds: options.latencyOffset,
|
|
2872
2881
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
@@ -2900,13 +2909,17 @@ var RecordingController = class {
|
|
|
2900
2909
|
),
|
|
2901
2910
|
startSample,
|
|
2902
2911
|
channelCount,
|
|
2912
|
+
captureSampleRate: rawCtx.sampleRate,
|
|
2903
2913
|
bits,
|
|
2904
2914
|
isFirstMessage: true,
|
|
2905
2915
|
latencySamples,
|
|
2916
|
+
clipName: options.clipName,
|
|
2917
|
+
armedPrevMuted: null,
|
|
2906
2918
|
wasOverdub: options.overdub ?? false,
|
|
2907
2919
|
_onTrackEnded: onTrackEnded,
|
|
2908
2920
|
_audioTrack: audioTrack,
|
|
2909
2921
|
stopAckResolve: null,
|
|
2922
|
+
stopPromise: null,
|
|
2910
2923
|
stopping: false
|
|
2911
2924
|
};
|
|
2912
2925
|
this._sessions.set(trackId, session);
|
|
@@ -2918,6 +2931,11 @@ var RecordingController = class {
|
|
|
2918
2931
|
if (audioTrack && onTrackEnded) {
|
|
2919
2932
|
audioTrack.addEventListener("ended", onTrackEnded);
|
|
2920
2933
|
}
|
|
2934
|
+
const engine = this._host._engine;
|
|
2935
|
+
if (engine) {
|
|
2936
|
+
session.armedPrevMuted = engine.getState().tracks.find((t) => t.id === trackId)?.muted ?? false;
|
|
2937
|
+
engine.setTrackMute(trackId, true);
|
|
2938
|
+
}
|
|
2921
2939
|
this._host.dispatchEvent(
|
|
2922
2940
|
new CustomEvent("daw-recording-start", {
|
|
2923
2941
|
bubbles: true,
|
|
@@ -2927,7 +2945,7 @@ var RecordingController = class {
|
|
|
2927
2945
|
);
|
|
2928
2946
|
this._host.requestUpdate();
|
|
2929
2947
|
if (options.overdub && typeof this._host.play === "function") {
|
|
2930
|
-
await this._host.play(this._host.
|
|
2948
|
+
await this._host.play(this._host.currentTime);
|
|
2931
2949
|
}
|
|
2932
2950
|
} catch (err) {
|
|
2933
2951
|
this._cleanupSession(trackId);
|
|
@@ -2939,6 +2957,8 @@ var RecordingController = class {
|
|
|
2939
2957
|
detail: { trackId, error: err }
|
|
2940
2958
|
})
|
|
2941
2959
|
);
|
|
2960
|
+
} finally {
|
|
2961
|
+
this._starting.delete(trackId);
|
|
2942
2962
|
}
|
|
2943
2963
|
}
|
|
2944
2964
|
pauseRecording(trackId) {
|
|
@@ -2976,14 +2996,23 @@ var RecordingController = class {
|
|
|
2976
2996
|
if (!id) return;
|
|
2977
2997
|
const session = this._sessions.get(id);
|
|
2978
2998
|
if (!session) return;
|
|
2999
|
+
if (session.stopping) {
|
|
3000
|
+
return session.stopPromise ?? void 0;
|
|
3001
|
+
}
|
|
3002
|
+
session.stopping = true;
|
|
3003
|
+
const stopPromise = this._finishStopRecording(id, session);
|
|
3004
|
+
session.stopPromise = stopPromise;
|
|
3005
|
+
return stopPromise;
|
|
3006
|
+
}
|
|
3007
|
+
async _finishStopRecording(id, session) {
|
|
2979
3008
|
const wasPaused = this._isPaused;
|
|
2980
3009
|
this._isPaused = false;
|
|
2981
|
-
session.stopping = true;
|
|
2982
3010
|
if (session.wasOverdub && typeof this._host.stop === "function") {
|
|
2983
3011
|
this._host.stop();
|
|
2984
3012
|
}
|
|
2985
3013
|
if (wasPaused) {
|
|
2986
3014
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
3015
|
+
await this._drainWorkletQueue(session);
|
|
2987
3016
|
} else {
|
|
2988
3017
|
const stopAck = new Promise((resolve) => {
|
|
2989
3018
|
session.stopAckResolve = resolve;
|
|
@@ -2996,17 +3025,7 @@ var RecordingController = class {
|
|
|
2996
3025
|
await Promise.race([stopAck, timeout]);
|
|
2997
3026
|
clearTimeout(timeoutId);
|
|
2998
3027
|
session.stopAckResolve = null;
|
|
2999
|
-
|
|
3000
|
-
let stable = 0;
|
|
3001
|
-
for (let i = 0; i < 50; i++) {
|
|
3002
|
-
if (session.totalSamples === lastSamples) {
|
|
3003
|
-
if (++stable >= 3) break;
|
|
3004
|
-
} else {
|
|
3005
|
-
stable = 0;
|
|
3006
|
-
lastSamples = session.totalSamples;
|
|
3007
|
-
}
|
|
3008
|
-
await new Promise((r) => setTimeout(r, 5));
|
|
3009
|
-
}
|
|
3028
|
+
await this._drainWorkletQueue(session);
|
|
3010
3029
|
}
|
|
3011
3030
|
session.source.disconnect();
|
|
3012
3031
|
session.workletNode.disconnect();
|
|
@@ -3029,13 +3048,14 @@ var RecordingController = class {
|
|
|
3029
3048
|
const audioBuffer = (0, import_core3.createAudioBuffer)(
|
|
3030
3049
|
stopCtx,
|
|
3031
3050
|
channelData,
|
|
3032
|
-
|
|
3051
|
+
session.captureSampleRate,
|
|
3033
3052
|
session.channelCount
|
|
3034
3053
|
);
|
|
3035
3054
|
const latencyOffsetSamples = session.latencySamples;
|
|
3036
3055
|
const effectiveDuration = Math.max(0, audioBuffer.length - latencyOffsetSamples);
|
|
3037
3056
|
if (effectiveDuration === 0) {
|
|
3038
3057
|
console.warn("[dawcore] RecordingController: Recording too short for latency compensation");
|
|
3058
|
+
this._restoreArmedTrackMute(session);
|
|
3039
3059
|
this._sessions.delete(id);
|
|
3040
3060
|
this._host.requestUpdate();
|
|
3041
3061
|
this._host.dispatchEvent(
|
|
@@ -3060,6 +3080,7 @@ var RecordingController = class {
|
|
|
3060
3080
|
}
|
|
3061
3081
|
});
|
|
3062
3082
|
const notPrevented = this._host.dispatchEvent(event);
|
|
3083
|
+
this._restoreArmedTrackMute(session);
|
|
3063
3084
|
this._sessions.delete(id);
|
|
3064
3085
|
this._host.requestUpdate();
|
|
3065
3086
|
if (notPrevented) {
|
|
@@ -3068,10 +3089,29 @@ var RecordingController = class {
|
|
|
3068
3089
|
audioBuffer,
|
|
3069
3090
|
session.startSample,
|
|
3070
3091
|
effectiveDuration,
|
|
3071
|
-
latencyOffsetSamples
|
|
3092
|
+
latencyOffsetSamples,
|
|
3093
|
+
session.clipName
|
|
3072
3094
|
);
|
|
3073
3095
|
}
|
|
3074
3096
|
}
|
|
3097
|
+
/** Drain the event-loop queue of pending worklet flush messages. During
|
|
3098
|
+
* recording the worklet posts a flush every ~16ms; if main was slower,
|
|
3099
|
+
* messages back up. Yield repeatedly until session.totalSamples stabilizes
|
|
3100
|
+
* (no new messages processed) for several consecutive ticks — at that
|
|
3101
|
+
* point the queue is empty and chunks are complete. */
|
|
3102
|
+
async _drainWorkletQueue(session) {
|
|
3103
|
+
let lastSamples = -1;
|
|
3104
|
+
let stable = 0;
|
|
3105
|
+
for (let i = 0; i < 50; i++) {
|
|
3106
|
+
if (session.totalSamples === lastSamples) {
|
|
3107
|
+
if (++stable >= 3) break;
|
|
3108
|
+
} else {
|
|
3109
|
+
stable = 0;
|
|
3110
|
+
lastSamples = session.totalSamples;
|
|
3111
|
+
}
|
|
3112
|
+
await new Promise((r) => setTimeout(r, 5));
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3075
3115
|
// Session fields are mutated in place on the hot path (~60fps worklet messages).
|
|
3076
3116
|
// This is intentional — creating new session objects + Map entries per message
|
|
3077
3117
|
// would cause significant GC pressure. Mutations are confined to the controller's
|
|
@@ -3107,7 +3147,10 @@ var RecordingController = class {
|
|
|
3107
3147
|
session.peaks[ch] = (0, import_core3.appendPeaks)(
|
|
3108
3148
|
session.peaks[ch],
|
|
3109
3149
|
channels[ch],
|
|
3110
|
-
this
|
|
3150
|
+
// Render-space scale — in beats mode this differs from
|
|
3151
|
+
// samplesPerPixel, and the preview container is laid out in
|
|
3152
|
+
// render space (see RecordingHost.renderSamplesPerPixel).
|
|
3153
|
+
this._host.renderSamplesPerPixel,
|
|
3111
3154
|
samplesProcessedBefore,
|
|
3112
3155
|
session.bits
|
|
3113
3156
|
);
|
|
@@ -3126,22 +3169,23 @@ var RecordingController = class {
|
|
|
3126
3169
|
}
|
|
3127
3170
|
}
|
|
3128
3171
|
session.isFirstMessage = false;
|
|
3129
|
-
const newPixelWidth = Math.floor(session.totalSamples / this._host.
|
|
3172
|
+
const newPixelWidth = Math.floor(session.totalSamples / this._host.renderSamplesPerPixel);
|
|
3130
3173
|
const oldPixelWidth = Math.floor(
|
|
3131
|
-
(session.totalSamples - channels[0].length) / this._host.
|
|
3174
|
+
(session.totalSamples - channels[0].length) / this._host.renderSamplesPerPixel
|
|
3132
3175
|
);
|
|
3133
3176
|
if (newPixelWidth > oldPixelWidth) {
|
|
3134
3177
|
this._host.requestUpdate();
|
|
3135
3178
|
}
|
|
3136
3179
|
}
|
|
3137
|
-
_createClipFromRecording(trackId, audioBuffer, startSample, durationSamples, offsetSamples = 0) {
|
|
3180
|
+
_createClipFromRecording(trackId, audioBuffer, startSample, durationSamples, offsetSamples = 0, clipName) {
|
|
3138
3181
|
if (typeof this._host._addRecordedClip === "function") {
|
|
3139
3182
|
this._host._addRecordedClip(
|
|
3140
3183
|
trackId,
|
|
3141
3184
|
audioBuffer,
|
|
3142
3185
|
startSample,
|
|
3143
3186
|
durationSamples,
|
|
3144
|
-
offsetSamples
|
|
3187
|
+
offsetSamples,
|
|
3188
|
+
clipName
|
|
3145
3189
|
);
|
|
3146
3190
|
} else {
|
|
3147
3191
|
console.warn(
|
|
@@ -3154,10 +3198,21 @@ var RecordingController = class {
|
|
|
3154
3198
|
session._audioTrack.removeEventListener("ended", session._onTrackEnded);
|
|
3155
3199
|
}
|
|
3156
3200
|
}
|
|
3157
|
-
|
|
3201
|
+
/** Restore the armed track's pre-session mute state (idempotent — safe to
|
|
3202
|
+
* call from both the finalize path and _cleanupSession). */
|
|
3203
|
+
_restoreArmedTrackMute(session) {
|
|
3204
|
+
if (session.armedPrevMuted === null) return;
|
|
3205
|
+
this._host._engine?.setTrackMute(session.trackId, session.armedPrevMuted);
|
|
3206
|
+
session.armedPrevMuted = null;
|
|
3207
|
+
}
|
|
3208
|
+
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
3209
|
+
* disposal paths that would otherwise discard the session silently. The
|
|
3210
|
+
* startRecording catch path passes false (it dispatches its own error). */
|
|
3211
|
+
_cleanupSession(trackId, notifyError = false) {
|
|
3158
3212
|
const session = this._sessions.get(trackId);
|
|
3159
3213
|
if (!session) return;
|
|
3160
3214
|
try {
|
|
3215
|
+
this._restoreArmedTrackMute(session);
|
|
3161
3216
|
this._removeTrackEndedListener(session);
|
|
3162
3217
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
3163
3218
|
session.source.disconnect();
|
|
@@ -3168,6 +3223,21 @@ var RecordingController = class {
|
|
|
3168
3223
|
);
|
|
3169
3224
|
}
|
|
3170
3225
|
this._sessions.delete(trackId);
|
|
3226
|
+
if (this._sessions.size === 0) {
|
|
3227
|
+
this._isPaused = false;
|
|
3228
|
+
}
|
|
3229
|
+
if (notifyError) {
|
|
3230
|
+
this._host.dispatchEvent(
|
|
3231
|
+
new CustomEvent("daw-recording-error", {
|
|
3232
|
+
bubbles: true,
|
|
3233
|
+
composed: true,
|
|
3234
|
+
detail: {
|
|
3235
|
+
trackId,
|
|
3236
|
+
error: new Error("Recording cancelled: editor was disconnected mid-recording")
|
|
3237
|
+
}
|
|
3238
|
+
})
|
|
3239
|
+
);
|
|
3240
|
+
}
|
|
3171
3241
|
}
|
|
3172
3242
|
};
|
|
3173
3243
|
|
|
@@ -4073,7 +4143,7 @@ function stringifyReason(reason) {
|
|
|
4073
4143
|
|
|
4074
4144
|
// src/interactions/recording-clip.ts
|
|
4075
4145
|
var import_core8 = require("@waveform-playlist/core");
|
|
4076
|
-
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0) {
|
|
4146
|
+
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
4077
4147
|
let trimmedBuf = buf;
|
|
4078
4148
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
4079
4149
|
const trimmed = new AudioBuffer({
|
|
@@ -4094,11 +4164,10 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4094
4164
|
offsetSamples: 0,
|
|
4095
4165
|
// offset already applied by slicing
|
|
4096
4166
|
gain: 1,
|
|
4097
|
-
name: "Recording"
|
|
4167
|
+
name: clipName ?? "Recording"
|
|
4098
4168
|
});
|
|
4099
4169
|
host._clipBuffers = new Map(host._clipBuffers).set(clip.id, trimmedBuf);
|
|
4100
4170
|
host._peakPipeline.generatePeaks(trimmedBuf, host.samplesPerPixel, host.mono).then((pd) => {
|
|
4101
|
-
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
4102
4171
|
const t = host._engineTracks.get(trackId);
|
|
4103
4172
|
if (!t) {
|
|
4104
4173
|
const next = new Map(host._clipBuffers);
|
|
@@ -4106,9 +4175,13 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4106
4175
|
host._clipBuffers = next;
|
|
4107
4176
|
return;
|
|
4108
4177
|
}
|
|
4178
|
+
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
4109
4179
|
host._engineTracks = new Map(host._engineTracks).set(trackId, {
|
|
4110
4180
|
...t,
|
|
4111
|
-
|
|
4181
|
+
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
4182
|
+
// startSample + durSamples) — carve overlapped content out of the
|
|
4183
|
+
// existing clips before inserting (parity with the React provider).
|
|
4184
|
+
clips: [...(0, import_core8.carveClipRange)(t.clips, startSample, startSample + durSamples), clip]
|
|
4112
4185
|
});
|
|
4113
4186
|
const desc = host._tracks.get(trackId);
|
|
4114
4187
|
if (desc) {
|
|
@@ -4121,7 +4194,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4121
4194
|
duration: durSamples / sr,
|
|
4122
4195
|
offset: 0,
|
|
4123
4196
|
gain: 1,
|
|
4124
|
-
name: "Recording",
|
|
4197
|
+
name: clipName ?? "Recording",
|
|
4125
4198
|
fadeIn: 0,
|
|
4126
4199
|
fadeOut: 0,
|
|
4127
4200
|
fadeType: "linear",
|
|
@@ -5577,7 +5650,9 @@ var AnimationController = class {
|
|
|
5577
5650
|
this._callback = callback;
|
|
5578
5651
|
const loop = () => {
|
|
5579
5652
|
this._callback?.();
|
|
5580
|
-
this.
|
|
5653
|
+
if (this._callback !== null) {
|
|
5654
|
+
this._rafId = requestAnimationFrame(loop);
|
|
5655
|
+
}
|
|
5581
5656
|
};
|
|
5582
5657
|
this._rafId = requestAnimationFrame(loop);
|
|
5583
5658
|
}
|
|
@@ -5654,6 +5729,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
5654
5729
|
this.clipHeaderHeight = 20;
|
|
5655
5730
|
this.interactiveClips = false;
|
|
5656
5731
|
this.indefinitePlayback = false;
|
|
5732
|
+
this.fillViewport = false;
|
|
5657
5733
|
this._spectrogramConfig = null;
|
|
5658
5734
|
this._spectrogramColorMap = null;
|
|
5659
5735
|
this.scaleMode = "temporal";
|
|
@@ -6351,7 +6427,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6351
6427
|
const naturalWidth = Math.ceil(
|
|
6352
6428
|
this._duration * this.effectiveSampleRate / this.samplesPerPixel
|
|
6353
6429
|
);
|
|
6354
|
-
if (this.indefinitePlayback) {
|
|
6430
|
+
if (this.indefinitePlayback || this.fillViewport) {
|
|
6355
6431
|
return Math.max(naturalWidth, this._viewport.containerWidth);
|
|
6356
6432
|
}
|
|
6357
6433
|
return naturalWidth;
|
|
@@ -7645,8 +7721,8 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7645
7721
|
this._wasPlayingDuringRecording = false;
|
|
7646
7722
|
return this._recordingController.stopRecording();
|
|
7647
7723
|
}
|
|
7648
|
-
_addRecordedClip(trackId, buf, startSample, durSamples, offsetSamples = 0) {
|
|
7649
|
-
addRecordedClip(this, trackId, buf, startSample, durSamples, offsetSamples);
|
|
7724
|
+
_addRecordedClip(trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
7725
|
+
addRecordedClip(this, trackId, buf, startSample, durSamples, offsetSamples, clipName);
|
|
7650
7726
|
}
|
|
7651
7727
|
// --- RecordingHost bridge methods for cross-context worklet support ---
|
|
7652
7728
|
// These delegate to the adapter's context type (native or standardized-audio-context).
|
|
@@ -7677,30 +7753,47 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7677
7753
|
const latencyPixels = Math.floor(rs.latencySamples / renderSpp);
|
|
7678
7754
|
const left = Math.floor(rs.startSample / renderSpp);
|
|
7679
7755
|
const w = Math.floor(audibleSamples / renderSpp);
|
|
7680
|
-
|
|
7756
|
+
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
7757
|
+
const height = hdrH + chH * rs.peaks.length;
|
|
7758
|
+
return import_lit15.html`<div
|
|
7759
|
+
class="clip-container recording-preview"
|
|
7760
|
+
style="left:${left}px;top:0;width:${w}px;height:${height}px;"
|
|
7761
|
+
>
|
|
7762
|
+
${hdrH > 0 ? import_lit15.html`<div class="clip-header" data-track-id=${trackId}>
|
|
7763
|
+
<span>${rs.clipName ?? "Recording\u2026"}</span>
|
|
7764
|
+
</div>` : ""}
|
|
7765
|
+
${rs.peaks.map((chPeaks, ch) => {
|
|
7681
7766
|
const slicedPeaks = latencyPixels > 0 ? chPeaks.slice(latencyPixels * 2) : chPeaks;
|
|
7682
7767
|
return import_lit15.html`
|
|
7683
|
-
|
|
7684
|
-
|
|
7685
|
-
|
|
7686
|
-
|
|
7687
|
-
|
|
7688
|
-
|
|
7689
|
-
|
|
7690
|
-
|
|
7691
|
-
|
|
7692
|
-
|
|
7693
|
-
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
})
|
|
7768
|
+
<daw-waveform
|
|
7769
|
+
data-recording-track=${trackId}
|
|
7770
|
+
data-recording-channel=${ch}
|
|
7771
|
+
style="position:absolute;left:0;top:${hdrH + ch * chH}px;"
|
|
7772
|
+
.peaks=${slicedPeaks}
|
|
7773
|
+
.length=${w}
|
|
7774
|
+
.waveHeight=${chH}
|
|
7775
|
+
.barWidth=${this.barWidth}
|
|
7776
|
+
.barGap=${this.barGap}
|
|
7777
|
+
.roundedBars=${this.roundedBars}
|
|
7778
|
+
.visibleStart=${this._viewport.visibleStart}
|
|
7779
|
+
.visibleEnd=${this._viewport.visibleEnd}
|
|
7780
|
+
.originX=${left}
|
|
7781
|
+
></daw-waveform>
|
|
7782
|
+
`;
|
|
7783
|
+
})}
|
|
7784
|
+
</div>`;
|
|
7699
7785
|
}
|
|
7700
7786
|
_startPlayhead() {
|
|
7701
7787
|
if (!this._engine) return;
|
|
7702
7788
|
const engine = this._engine;
|
|
7703
|
-
this._playbackAnimation.start(() =>
|
|
7789
|
+
this._playbackAnimation.start(() => {
|
|
7790
|
+
if (!this.indefinitePlayback && !this.isRecording && engine.getCurrentTime() >= this._duration) {
|
|
7791
|
+
this.stop();
|
|
7792
|
+
const t = this._currentTime;
|
|
7793
|
+
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
7794
|
+
}
|
|
7795
|
+
return engine.getAudibleTime();
|
|
7796
|
+
});
|
|
7704
7797
|
}
|
|
7705
7798
|
_stopPlayhead() {
|
|
7706
7799
|
const t = this._currentTime;
|
|
@@ -7712,11 +7805,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7712
7805
|
}
|
|
7713
7806
|
/** True when the controls column should be rendered (and its selector is valid). */
|
|
7714
7807
|
get _showControls() {
|
|
7715
|
-
return this._getOrderedTracks().length > 0 || this.indefinitePlayback;
|
|
7808
|
+
return this._getOrderedTracks().length > 0 || this.indefinitePlayback || this.fillViewport;
|
|
7716
7809
|
}
|
|
7717
7810
|
/** True when the ruler header band should be rendered (and its selector is valid). */
|
|
7718
7811
|
get _showRuler() {
|
|
7719
|
-
return (this._getOrderedTracks().length > 0 || this.scaleMode === "beats" || this.indefinitePlayback) && this.timescale;
|
|
7812
|
+
return (this._getOrderedTracks().length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport) && this.timescale;
|
|
7720
7813
|
}
|
|
7721
7814
|
_getOrderedTracks() {
|
|
7722
7815
|
const domOrder = [...this.querySelectorAll("daw-track")].map(
|
|
@@ -7821,7 +7914,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7821
7914
|
.length=${this._totalWidth}
|
|
7822
7915
|
.height=${orderedTracks.length > 0 ? orderedTracks.reduce((sum, t) => sum + t.trackHeight, 0) : this._emptyGridHeight}
|
|
7823
7916
|
></daw-grid>` : ""}
|
|
7824
|
-
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback ? import_lit15.html`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
7917
|
+
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ? import_lit15.html`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
7825
7918
|
<daw-playhead></daw-playhead>` : ""}
|
|
7826
7919
|
${orderedTracks.map((t) => {
|
|
7827
7920
|
const channelHeight = this.waveHeight;
|
|
@@ -8087,6 +8180,9 @@ __decorateClass([
|
|
|
8087
8180
|
__decorateClass([
|
|
8088
8181
|
(0, import_decorators13.property)({ type: Boolean, attribute: "indefinite-playback" })
|
|
8089
8182
|
], DawEditorElement.prototype, "indefinitePlayback", 2);
|
|
8183
|
+
__decorateClass([
|
|
8184
|
+
(0, import_decorators13.property)({ type: Boolean, attribute: "fill-viewport" })
|
|
8185
|
+
], DawEditorElement.prototype, "fillViewport", 2);
|
|
8090
8186
|
__decorateClass([
|
|
8091
8187
|
(0, import_decorators13.property)({ attribute: false, noAccessor: true })
|
|
8092
8188
|
], DawEditorElement.prototype, "spectrogramConfig", 1);
|
|
@@ -8213,14 +8309,22 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8213
8309
|
}
|
|
8214
8310
|
connectedCallback() {
|
|
8215
8311
|
super.connectedCallback();
|
|
8216
|
-
requestAnimationFrame(() =>
|
|
8312
|
+
requestAnimationFrame(() => {
|
|
8313
|
+
if (!this.isConnected) return;
|
|
8314
|
+
this._ensureTargetListeners();
|
|
8315
|
+
});
|
|
8217
8316
|
}
|
|
8218
8317
|
disconnectedCallback() {
|
|
8219
8318
|
super.disconnectedCallback();
|
|
8220
8319
|
this._cleanupListeners();
|
|
8221
8320
|
}
|
|
8222
|
-
|
|
8321
|
+
updated() {
|
|
8322
|
+
this._ensureTargetListeners();
|
|
8323
|
+
}
|
|
8324
|
+
_ensureTargetListeners() {
|
|
8223
8325
|
const target = this.target;
|
|
8326
|
+
if (target === this._targetRef) return;
|
|
8327
|
+
this._cleanupListeners();
|
|
8224
8328
|
if (!target) return;
|
|
8225
8329
|
this._targetRef = target;
|
|
8226
8330
|
target.addEventListener("daw-recording-start", this._onStart);
|
|
@@ -8254,6 +8358,7 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8254
8358
|
warnNoTargetOnce(this);
|
|
8255
8359
|
return;
|
|
8256
8360
|
}
|
|
8361
|
+
this._ensureTargetListeners();
|
|
8257
8362
|
target.startRecording(target.recordingStream);
|
|
8258
8363
|
}
|
|
8259
8364
|
};
|
|
@@ -8546,7 +8651,11 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
8546
8651
|
}
|
|
8547
8652
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
8548
8653
|
const canvas = this._canvases[i];
|
|
8549
|
-
const canvasId =
|
|
8654
|
+
const canvasId = (0, import_core11.buildSpectrogramCanvasId)({
|
|
8655
|
+
clipId: this.clipId,
|
|
8656
|
+
channelIndex: this.channelIndex,
|
|
8657
|
+
chunkIndex: i
|
|
8658
|
+
});
|
|
8550
8659
|
let offscreen;
|
|
8551
8660
|
try {
|
|
8552
8661
|
offscreen = canvas.transferControlToOffscreen();
|