@dawcore/components 0.0.39-next.3 → 0.0.39-next.5
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 +8 -6
- package/dist/index.d.mts +131 -30
- package/dist/index.d.ts +131 -30
- package/dist/index.js +405 -194
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -135
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -82,7 +82,7 @@ __export(index_exports, {
|
|
|
82
82
|
module.exports = __toCommonJS(index_exports);
|
|
83
83
|
|
|
84
84
|
// <define:__INSTALL_SPECS__>
|
|
85
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.
|
|
85
|
+
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.4", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.4", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.4", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.2", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.4" };
|
|
86
86
|
|
|
87
87
|
// src/elements/daw-annotation.ts
|
|
88
88
|
var import_lit = require("lit");
|
|
@@ -306,6 +306,7 @@ var DawAnnotationTrackElement = class extends import_lit2.LitElement {
|
|
|
306
306
|
this._onKeyDownCapture = (e) => {
|
|
307
307
|
if (!this.keyboardControls) return;
|
|
308
308
|
if (e.repeat) return;
|
|
309
|
+
if (e.key === "Escape" && e.defaultPrevented) return;
|
|
309
310
|
if ((0, import_core.keyBelongsToFocusedControl)(e)) return;
|
|
310
311
|
const match = this._shortcutEntries().find((entry) => (0, import_core.matchesKeyBinding)(e, entry.binding));
|
|
311
312
|
if (!match) return;
|
|
@@ -1062,6 +1063,17 @@ function isDomClip(desc) {
|
|
|
1062
1063
|
}
|
|
1063
1064
|
|
|
1064
1065
|
// src/elements/daw-track.ts
|
|
1066
|
+
var TRACK_PROPS = [
|
|
1067
|
+
"volume",
|
|
1068
|
+
"pan",
|
|
1069
|
+
"muted",
|
|
1070
|
+
"soloed",
|
|
1071
|
+
"src",
|
|
1072
|
+
"name",
|
|
1073
|
+
"kind",
|
|
1074
|
+
"renderMode",
|
|
1075
|
+
"spectrogramConfig"
|
|
1076
|
+
];
|
|
1065
1077
|
var DawTrackElement = class extends import_lit5.LitElement {
|
|
1066
1078
|
constructor() {
|
|
1067
1079
|
super(...arguments);
|
|
@@ -1192,24 +1204,14 @@ var DawTrackElement = class extends import_lit5.LitElement {
|
|
|
1192
1204
|
this._hasRendered = true;
|
|
1193
1205
|
return;
|
|
1194
1206
|
}
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
"muted",
|
|
1199
|
-
"soloed",
|
|
1200
|
-
"src",
|
|
1201
|
-
"name",
|
|
1202
|
-
"kind",
|
|
1203
|
-
"renderMode",
|
|
1204
|
-
"spectrogramConfig"
|
|
1205
|
-
];
|
|
1206
|
-
const hasTrackChange = trackProps.some((p) => changed.has(p));
|
|
1207
|
-
if (hasTrackChange) {
|
|
1207
|
+
const trackChanged = TRACK_PROPS.filter((p) => changed.has(p));
|
|
1208
|
+
if (trackChanged.length > 0) {
|
|
1209
|
+
const detail = { trackId: this.trackId, changed: trackChanged };
|
|
1208
1210
|
this.dispatchEvent(
|
|
1209
1211
|
new CustomEvent("daw-track-update", {
|
|
1210
1212
|
bubbles: true,
|
|
1211
1213
|
composed: true,
|
|
1212
|
-
detail
|
|
1214
|
+
detail
|
|
1213
1215
|
})
|
|
1214
1216
|
);
|
|
1215
1217
|
}
|
|
@@ -2279,7 +2281,7 @@ DawStopButtonElement = __decorateClass([
|
|
|
2279
2281
|
// src/elements/daw-editor.ts
|
|
2280
2282
|
var import_lit19 = require("lit");
|
|
2281
2283
|
var import_decorators16 = require("lit/decorators.js");
|
|
2282
|
-
var
|
|
2284
|
+
var import_core17 = require("@waveform-playlist/core");
|
|
2283
2285
|
|
|
2284
2286
|
// src/workers/peaksWorker.ts
|
|
2285
2287
|
var import_waveform_data = __toESM(require("waveform-data"));
|
|
@@ -3023,9 +3025,39 @@ DawRulerElement = __decorateClass([
|
|
|
3023
3025
|
(0, import_decorators13.customElement)("daw-ruler")
|
|
3024
3026
|
], DawRulerElement);
|
|
3025
3027
|
|
|
3028
|
+
// src/utils/track-mix.ts
|
|
3029
|
+
var DEFAULT_TRACK_MIX = Object.freeze({
|
|
3030
|
+
volume: 1,
|
|
3031
|
+
pan: 0,
|
|
3032
|
+
muted: false,
|
|
3033
|
+
soloed: false
|
|
3034
|
+
});
|
|
3035
|
+
function mixOfTrack(track) {
|
|
3036
|
+
return { volume: track.volume, pan: track.pan, muted: track.muted, soloed: track.soloed };
|
|
3037
|
+
}
|
|
3038
|
+
function mixOfElement(el) {
|
|
3039
|
+
return { volume: el.volume, pan: el.pan, muted: el.muted, soloed: el.soloed };
|
|
3040
|
+
}
|
|
3041
|
+
function pickMix(mix, names) {
|
|
3042
|
+
const named = new Set(names);
|
|
3043
|
+
return {
|
|
3044
|
+
...named.has("volume") && { volume: mix.volume },
|
|
3045
|
+
...named.has("pan") && { pan: mix.pan },
|
|
3046
|
+
...named.has("muted") && { muted: mix.muted },
|
|
3047
|
+
...named.has("soloed") && { soloed: mix.soloed }
|
|
3048
|
+
};
|
|
3049
|
+
}
|
|
3050
|
+
function withMix(track, mix) {
|
|
3051
|
+
return { ...track, ...mixOfElement(mix) };
|
|
3052
|
+
}
|
|
3053
|
+
function clampNumber(value, min, max) {
|
|
3054
|
+
return Math.max(min, Math.min(max, Number(value)));
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3026
3057
|
// src/elements/daw-track-controls.ts
|
|
3027
3058
|
var import_lit15 = require("lit");
|
|
3028
3059
|
var import_decorators14 = require("lit/decorators.js");
|
|
3060
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
3029
3061
|
var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
3030
3062
|
constructor() {
|
|
3031
3063
|
super(...arguments);
|
|
@@ -3034,19 +3066,30 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3034
3066
|
this.volume = 1;
|
|
3035
3067
|
this.pan = 0;
|
|
3036
3068
|
this.muted = false;
|
|
3069
|
+
this.recording = false;
|
|
3037
3070
|
this.soloed = false;
|
|
3038
3071
|
this.reorderable = false;
|
|
3039
3072
|
this.trackIndex = 0;
|
|
3040
3073
|
this.trackCount = 1;
|
|
3074
|
+
/**
|
|
3075
|
+
* One gesture per slider (#843): the `daw-track-control` events of one
|
|
3076
|
+
* drag, or of one key press (a held key included), carry the same
|
|
3077
|
+
* `gesture` id, and the editor makes them one undo step. Each gesture is
|
|
3078
|
+
* attached to its range input while the element is connected.
|
|
3079
|
+
*/
|
|
3080
|
+
this._volumeGesture = (0, import_core4.createMixerGesture)();
|
|
3081
|
+
this._panGesture = (0, import_core4.createMixerGesture)();
|
|
3082
|
+
this._detachGestures = [];
|
|
3041
3083
|
this._onVolumeInput = (e) => {
|
|
3042
3084
|
const value = Number(e.target.value);
|
|
3043
|
-
if (Number.isFinite(value)) this._dispatchControl("volume", value);
|
|
3085
|
+
if (Number.isFinite(value)) this._dispatchControl("volume", value, this._volumeGesture.id);
|
|
3044
3086
|
};
|
|
3045
3087
|
this._onPanInput = (e) => {
|
|
3046
3088
|
const value = Number(e.target.value);
|
|
3047
|
-
if (Number.isFinite(value)) this._dispatchControl("pan", value);
|
|
3089
|
+
if (Number.isFinite(value)) this._dispatchControl("pan", value, this._panGesture.id);
|
|
3048
3090
|
};
|
|
3049
3091
|
this._onMuteClick = () => {
|
|
3092
|
+
if (this.recording) return;
|
|
3050
3093
|
this._dispatchControl("muted", !this.muted);
|
|
3051
3094
|
};
|
|
3052
3095
|
this._onSoloClick = () => {
|
|
@@ -3080,7 +3123,29 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3080
3123
|
);
|
|
3081
3124
|
};
|
|
3082
3125
|
}
|
|
3126
|
+
connectedCallback() {
|
|
3127
|
+
super.connectedCallback();
|
|
3128
|
+
if (this.hasUpdated) this._attachGestures();
|
|
3129
|
+
}
|
|
3130
|
+
disconnectedCallback() {
|
|
3131
|
+
super.disconnectedCallback();
|
|
3132
|
+
this._detachAllGestures();
|
|
3133
|
+
}
|
|
3134
|
+
_attachGestures() {
|
|
3135
|
+
this._detachAllGestures();
|
|
3136
|
+
const volumeInput = this.shadowRoot?.querySelector(".vol-row input");
|
|
3137
|
+
const panInput = this.shadowRoot?.querySelector(".pan-row input");
|
|
3138
|
+
const detach = [];
|
|
3139
|
+
if (volumeInput) detach.push(this._volumeGesture.attach(volumeInput));
|
|
3140
|
+
if (panInput) detach.push(this._panGesture.attach(panInput));
|
|
3141
|
+
this._detachGestures = detach;
|
|
3142
|
+
}
|
|
3143
|
+
_detachAllGestures() {
|
|
3144
|
+
for (const detach of this._detachGestures) detach();
|
|
3145
|
+
this._detachGestures = [];
|
|
3146
|
+
}
|
|
3083
3147
|
firstUpdated() {
|
|
3148
|
+
this._attachGestures();
|
|
3084
3149
|
requestAnimationFrame(() => {
|
|
3085
3150
|
if (!this.isConnected) return;
|
|
3086
3151
|
const rect = this.getBoundingClientRect();
|
|
@@ -3091,13 +3156,15 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3091
3156
|
}
|
|
3092
3157
|
});
|
|
3093
3158
|
}
|
|
3094
|
-
|
|
3159
|
+
/** `gesture` for the sliders only: each mute or solo click is a step. */
|
|
3160
|
+
_dispatchControl(prop, value, gesture) {
|
|
3095
3161
|
if (!this.trackId) return;
|
|
3162
|
+
const detail = gesture === void 0 ? { trackId: this.trackId, prop, value } : { trackId: this.trackId, prop, value, gesture };
|
|
3096
3163
|
this.dispatchEvent(
|
|
3097
3164
|
new CustomEvent("daw-track-control", {
|
|
3098
3165
|
bubbles: true,
|
|
3099
3166
|
composed: true,
|
|
3100
|
-
detail
|
|
3167
|
+
detail
|
|
3101
3168
|
})
|
|
3102
3169
|
);
|
|
3103
3170
|
}
|
|
@@ -3134,6 +3201,7 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3134
3201
|
<button
|
|
3135
3202
|
class="btn ${this.muted ? "muted-active" : ""}"
|
|
3136
3203
|
@click=${this._onMuteClick}
|
|
3204
|
+
?disabled=${this.recording}
|
|
3137
3205
|
title="Mute"
|
|
3138
3206
|
>
|
|
3139
3207
|
M
|
|
@@ -3375,6 +3443,9 @@ __decorateClass([
|
|
|
3375
3443
|
__decorateClass([
|
|
3376
3444
|
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3377
3445
|
], DawTrackControlsElement.prototype, "muted", 2);
|
|
3446
|
+
__decorateClass([
|
|
3447
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3448
|
+
], DawTrackControlsElement.prototype, "recording", 2);
|
|
3378
3449
|
__decorateClass([
|
|
3379
3450
|
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3380
3451
|
], DawTrackControlsElement.prototype, "soloed", 2);
|
|
@@ -3394,7 +3465,7 @@ DawTrackControlsElement = __decorateClass([
|
|
|
3394
3465
|
// src/elements/daw-grid.ts
|
|
3395
3466
|
var import_lit16 = require("lit");
|
|
3396
3467
|
var import_decorators15 = require("lit/decorators.js");
|
|
3397
|
-
var
|
|
3468
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
3398
3469
|
var MAX_CANVAS_WIDTH4 = 1e3;
|
|
3399
3470
|
var DawGridElement = class extends import_lit16.LitElement {
|
|
3400
3471
|
constructor() {
|
|
@@ -3471,7 +3542,7 @@ var DawGridElement = class extends import_lit16.LitElement {
|
|
|
3471
3542
|
ctx.resetTransform();
|
|
3472
3543
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
3473
3544
|
ctx.scale(dpr, dpr);
|
|
3474
|
-
if (pixelsPerQuarterNote * 4 >=
|
|
3545
|
+
if (pixelsPerQuarterNote * 4 >= import_core5.MIN_PIXELS_PER_UNIT) {
|
|
3475
3546
|
ctx.fillStyle = barHighlight;
|
|
3476
3547
|
const majorTicks = ticks.filter((t) => t.type === "major");
|
|
3477
3548
|
for (let i = 0; i < majorTicks.length; i++) {
|
|
@@ -3807,7 +3878,7 @@ function installCommand(...names) {
|
|
|
3807
3878
|
}
|
|
3808
3879
|
|
|
3809
3880
|
// src/controllers/recording-controller.ts
|
|
3810
|
-
var
|
|
3881
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
3811
3882
|
var RecordingController = class {
|
|
3812
3883
|
constructor(host) {
|
|
3813
3884
|
this._sessions = /* @__PURE__ */ new Map();
|
|
@@ -3901,7 +3972,7 @@ var RecordingController = class {
|
|
|
3901
3972
|
}
|
|
3902
3973
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
3903
3974
|
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
3904
|
-
const latencySamples = (0,
|
|
3975
|
+
const latencySamples = (0, import_core6.resolveRecordingOffsetSamples)({
|
|
3905
3976
|
overrideSeconds: options.latencyOffset,
|
|
3906
3977
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
3907
3978
|
lookAhead: 0,
|
|
@@ -3939,7 +4010,6 @@ var RecordingController = class {
|
|
|
3939
4010
|
isFirstMessage: true,
|
|
3940
4011
|
latencySamples,
|
|
3941
4012
|
clipName: options.clipName,
|
|
3942
|
-
armedPrevMuted: null,
|
|
3943
4013
|
wasOverdub: options.overdub ?? false,
|
|
3944
4014
|
_onTrackEnded: onTrackEnded,
|
|
3945
4015
|
_audioTrack: audioTrack,
|
|
@@ -3956,11 +4026,7 @@ var RecordingController = class {
|
|
|
3956
4026
|
if (audioTrack && onTrackEnded) {
|
|
3957
4027
|
audioTrack.addEventListener("ended", onTrackEnded);
|
|
3958
4028
|
}
|
|
3959
|
-
|
|
3960
|
-
if (engine) {
|
|
3961
|
-
session.armedPrevMuted = engine.getState().tracks.find((t) => t.id === trackId)?.muted ?? false;
|
|
3962
|
-
engine.setTrackMute(trackId, true);
|
|
3963
|
-
}
|
|
4029
|
+
this._host._engine?.setTrackRecording(trackId, true);
|
|
3964
4030
|
this._host.dispatchEvent(
|
|
3965
4031
|
new CustomEvent("daw-recording-start", {
|
|
3966
4032
|
bubbles: true,
|
|
@@ -4075,8 +4141,8 @@ var RecordingController = class {
|
|
|
4075
4141
|
return;
|
|
4076
4142
|
}
|
|
4077
4143
|
const stopCtx = this._host.audioContext;
|
|
4078
|
-
const channelData = session.chunks.map((chunkArr) => (0,
|
|
4079
|
-
const audioBuffer = (0,
|
|
4144
|
+
const channelData = session.chunks.map((chunkArr) => (0, import_core6.concatenateAudioData)(chunkArr));
|
|
4145
|
+
const audioBuffer = (0, import_core6.createAudioBuffer)(
|
|
4080
4146
|
stopCtx,
|
|
4081
4147
|
channelData,
|
|
4082
4148
|
session.captureSampleRate,
|
|
@@ -4106,7 +4172,7 @@ var RecordingController = class {
|
|
|
4106
4172
|
}
|
|
4107
4173
|
});
|
|
4108
4174
|
const notPrevented = this._host.dispatchEvent(event);
|
|
4109
|
-
this.
|
|
4175
|
+
this._clearTakeMute(session);
|
|
4110
4176
|
this._sessions.delete(id);
|
|
4111
4177
|
this._host.requestUpdate();
|
|
4112
4178
|
if (notPrevented) {
|
|
@@ -4170,7 +4236,7 @@ var RecordingController = class {
|
|
|
4170
4236
|
for (let ch = 0; ch < session.channelCount; ch++) {
|
|
4171
4237
|
if (!channels[ch]) continue;
|
|
4172
4238
|
const oldPeakCount = Math.floor(session.peaks[ch].length / 2);
|
|
4173
|
-
session.peaks[ch] = (0,
|
|
4239
|
+
session.peaks[ch] = (0, import_core6.appendPeaks)(
|
|
4174
4240
|
session.peaks[ch],
|
|
4175
4241
|
channels[ch],
|
|
4176
4242
|
// Render-space scale — in beats mode this differs from
|
|
@@ -4234,22 +4300,23 @@ var RecordingController = class {
|
|
|
4234
4300
|
);
|
|
4235
4301
|
}
|
|
4236
4302
|
/** Shared teardown for finalize paths that end without a take (no data
|
|
4237
|
-
* captured / too short after latency compensation):
|
|
4238
|
-
*
|
|
4239
|
-
*
|
|
4303
|
+
* captured / too short after latency compensation): clear the take's mute, drop
|
|
4304
|
+
* the session, and notify via daw-recording-error so record buttons reset
|
|
4305
|
+
* their state. */
|
|
4240
4306
|
_abandonFinalize(id, session, warnMessage, errorMessage = warnMessage) {
|
|
4241
4307
|
console.warn("[dawcore] RecordingController: " + warnMessage);
|
|
4242
|
-
this.
|
|
4308
|
+
this._clearTakeMute(session);
|
|
4243
4309
|
this._sessions.delete(id);
|
|
4244
4310
|
this._host.requestUpdate();
|
|
4245
4311
|
this._dispatchRecordingError(id, new Error(errorMessage));
|
|
4246
4312
|
}
|
|
4247
|
-
/**
|
|
4248
|
-
*
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4313
|
+
/** Clear the take's mute on the session's track, by its id. Each teardown
|
|
4314
|
+
* path calls this once, right before it drops the session from the map, so
|
|
4315
|
+
* a later path never reaches the same session; clearing an id that is not
|
|
4316
|
+
* set is a no-op in the engine. Another session's mute on another track is
|
|
4317
|
+
* left alone. */
|
|
4318
|
+
_clearTakeMute(session) {
|
|
4319
|
+
this._host._engine?.setTrackRecording(session.trackId, false);
|
|
4253
4320
|
}
|
|
4254
4321
|
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
4255
4322
|
* disposal paths that would otherwise discard the session silently. The
|
|
@@ -4258,7 +4325,7 @@ var RecordingController = class {
|
|
|
4258
4325
|
const session = this._sessions.get(trackId);
|
|
4259
4326
|
if (!session) return;
|
|
4260
4327
|
try {
|
|
4261
|
-
this.
|
|
4328
|
+
this._clearTakeMute(session);
|
|
4262
4329
|
this._removeTrackEndedListener(session);
|
|
4263
4330
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
4264
4331
|
session.source.disconnect();
|
|
@@ -4465,7 +4532,7 @@ var AnnotationController = class {
|
|
|
4465
4532
|
|
|
4466
4533
|
// src/controllers/spectrogram-controller.ts
|
|
4467
4534
|
var import_spectrogram = require("@dawcore/spectrogram");
|
|
4468
|
-
var
|
|
4535
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
4469
4536
|
var SpectrogramController = class {
|
|
4470
4537
|
constructor(host, workerFactory) {
|
|
4471
4538
|
this.orchestrator = null;
|
|
@@ -4574,18 +4641,18 @@ var SpectrogramController = class {
|
|
|
4574
4641
|
track = c;
|
|
4575
4642
|
break;
|
|
4576
4643
|
}
|
|
4577
|
-
return { ...
|
|
4644
|
+
return { ...import_core7.SPECTROGRAM_DEFAULTS, ...this.editorConfig ?? {}, ...track ?? {} };
|
|
4578
4645
|
}
|
|
4579
4646
|
mergedColorMap() {
|
|
4580
4647
|
for (const c of this.trackColorMaps.values()) {
|
|
4581
|
-
return c ??
|
|
4648
|
+
return c ?? import_core7.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
4582
4649
|
}
|
|
4583
|
-
return this.editorColorMap ??
|
|
4650
|
+
return this.editorColorMap ?? import_core7.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
4584
4651
|
}
|
|
4585
4652
|
};
|
|
4586
4653
|
|
|
4587
4654
|
// src/interactions/pointer-handler.ts
|
|
4588
|
-
var
|
|
4655
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
4589
4656
|
|
|
4590
4657
|
// src/interactions/constants.ts
|
|
4591
4658
|
var DRAG_THRESHOLD = 3;
|
|
@@ -4607,6 +4674,8 @@ var PointerHandler = class {
|
|
|
4607
4674
|
// still holds; zeroing only the host would desync the two).
|
|
4608
4675
|
this._preDragSelectionStart = 0;
|
|
4609
4676
|
this._preDragSelectionEnd = 0;
|
|
4677
|
+
/** Cancels the armed clip drag; set while one is armed (#848). */
|
|
4678
|
+
this._cancelArmedClipDrag = null;
|
|
4610
4679
|
this.onPointerDown = (e) => {
|
|
4611
4680
|
const clipHandler = this._host._clipHandler;
|
|
4612
4681
|
if (clipHandler) {
|
|
@@ -4621,12 +4690,13 @@ var PointerHandler = class {
|
|
|
4621
4690
|
console.warn("[dawcore] setPointerCapture failed: " + String(err));
|
|
4622
4691
|
}
|
|
4623
4692
|
const onMove = (me) => clipHandler.onPointerMove(me);
|
|
4624
|
-
const detach = (
|
|
4693
|
+
const detach = (pointerId) => {
|
|
4694
|
+
this._cancelArmedClipDrag = null;
|
|
4625
4695
|
this._timeline?.removeEventListener("pointermove", onMove);
|
|
4626
4696
|
this._timeline?.removeEventListener("pointerup", onUp);
|
|
4627
4697
|
this._timeline?.removeEventListener("pointercancel", onCancel);
|
|
4628
4698
|
try {
|
|
4629
|
-
this._timeline?.releasePointerCapture(
|
|
4699
|
+
this._timeline?.releasePointerCapture(pointerId);
|
|
4630
4700
|
} catch (err) {
|
|
4631
4701
|
console.warn(
|
|
4632
4702
|
"[dawcore] releasePointerCapture failed (may already be released): " + String(err)
|
|
@@ -4636,13 +4706,19 @@ var PointerHandler = class {
|
|
|
4636
4706
|
};
|
|
4637
4707
|
const onUp = (ue) => {
|
|
4638
4708
|
clipHandler.onPointerUp(ue);
|
|
4639
|
-
detach(ue);
|
|
4709
|
+
detach(ue.pointerId);
|
|
4640
4710
|
};
|
|
4641
4711
|
const downPointerId = e.pointerId;
|
|
4642
4712
|
const onCancel = (ce) => {
|
|
4643
4713
|
if (ce.pointerId !== downPointerId) return;
|
|
4644
4714
|
clipHandler.onPointerCancel(ce);
|
|
4645
|
-
detach(ce);
|
|
4715
|
+
detach(ce.pointerId);
|
|
4716
|
+
};
|
|
4717
|
+
this._cancelArmedClipDrag = () => {
|
|
4718
|
+
clipHandler.onPointerCancel(
|
|
4719
|
+
new PointerEvent("pointercancel", { pointerId: downPointerId })
|
|
4720
|
+
);
|
|
4721
|
+
detach(downPointerId);
|
|
4646
4722
|
};
|
|
4647
4723
|
this._timeline.addEventListener("pointermove", onMove);
|
|
4648
4724
|
this._timeline.addEventListener("pointerup", onUp);
|
|
@@ -4742,10 +4818,10 @@ var PointerHandler = class {
|
|
|
4742
4818
|
const h = this._host;
|
|
4743
4819
|
if (h.scaleMode === "beats") {
|
|
4744
4820
|
let tick = px * h.ticksPerPixel;
|
|
4745
|
-
tick = (0,
|
|
4821
|
+
tick = (0, import_core8.snapTickToGrid)(tick, h.snapTo, h._meterEntries, h.ppqn);
|
|
4746
4822
|
return h._ticksToSeconds(tick);
|
|
4747
4823
|
}
|
|
4748
|
-
return (0,
|
|
4824
|
+
return (0, import_core8.pixelsToSeconds)(px, h.samplesPerPixel, h.effectiveSampleRate);
|
|
4749
4825
|
}
|
|
4750
4826
|
_timeToPx(time) {
|
|
4751
4827
|
const h = this._host;
|
|
@@ -4755,6 +4831,17 @@ var PointerHandler = class {
|
|
|
4755
4831
|
}
|
|
4756
4832
|
return time * h.effectiveSampleRate / h.samplesPerPixel;
|
|
4757
4833
|
}
|
|
4834
|
+
/**
|
|
4835
|
+
* Cancel an armed clip move or trim as a `pointercancel` would: the clip
|
|
4836
|
+
* handler reverts it and the timeline's listeners and pointer capture are
|
|
4837
|
+
* released. Returns whether a clip drag was armed.
|
|
4838
|
+
*/
|
|
4839
|
+
cancelClipDrag() {
|
|
4840
|
+
const cancel = this._cancelArmedClipDrag;
|
|
4841
|
+
if (!cancel) return false;
|
|
4842
|
+
cancel();
|
|
4843
|
+
return true;
|
|
4844
|
+
}
|
|
4758
4845
|
/** Detach the drag listeners and release capture — shared by the up and
|
|
4759
4846
|
* cancel terminals so a new listener added to onPointerDown can't be
|
|
4760
4847
|
* missed on one of them. */
|
|
@@ -4864,7 +4951,7 @@ var PointerHandler = class {
|
|
|
4864
4951
|
};
|
|
4865
4952
|
|
|
4866
4953
|
// src/interactions/clip-pointer-handler.ts
|
|
4867
|
-
var
|
|
4954
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
4868
4955
|
var ClipPointerHandler = class {
|
|
4869
4956
|
constructor(host) {
|
|
4870
4957
|
this._mode = null;
|
|
@@ -4898,7 +4985,7 @@ var ClipPointerHandler = class {
|
|
|
4898
4985
|
const anchorTick = h._secondsToTicks(anchorSeconds);
|
|
4899
4986
|
const deltaTicks = totalDeltaPx * h.ticksPerPixel;
|
|
4900
4987
|
const targetTick = anchorTick + deltaTicks;
|
|
4901
|
-
const snappedTick = h.snapTo !== "off" ? (0,
|
|
4988
|
+
const snappedTick = h.snapTo !== "off" ? (0, import_core9.snapTickToGrid)(targetTick, h.snapTo, h._meterEntries, h.ppqn) : targetTick;
|
|
4902
4989
|
const snappedSeconds = h._ticksToSeconds(snappedTick);
|
|
4903
4990
|
const snappedSample = Math.round(snappedSeconds * h.effectiveSampleRate);
|
|
4904
4991
|
return snappedSample - anchorSample;
|
|
@@ -4909,6 +4996,11 @@ var ClipPointerHandler = class {
|
|
|
4909
4996
|
get isActive() {
|
|
4910
4997
|
return this._mode !== null;
|
|
4911
4998
|
}
|
|
4999
|
+
/** True once the pointer of the current press has moved past the drag
|
|
5000
|
+
* threshold: a press that has not moved is not a drag (#848). */
|
|
5001
|
+
get isDragging() {
|
|
5002
|
+
return this._isDragging;
|
|
5003
|
+
}
|
|
4912
5004
|
/**
|
|
4913
5005
|
* Attempts to handle a pointerdown event on the given target element.
|
|
4914
5006
|
* Returns true if the target is a recognized clip interaction element.
|
|
@@ -4943,21 +5035,32 @@ var ClipPointerHandler = class {
|
|
|
4943
5035
|
this._startPx = e.clientX;
|
|
4944
5036
|
this._isDragging = false;
|
|
4945
5037
|
this._cumulativeDeltaSamples = 0;
|
|
5038
|
+
}
|
|
5039
|
+
/**
|
|
5040
|
+
* The press has become a drag (the pointer passed the threshold): take the
|
|
5041
|
+
* clip's bounds and open the transaction now, not at the press. An undo
|
|
5042
|
+
* made during the press (it is not a drag, so undo works) then has no
|
|
5043
|
+
* transaction to abort, and the drag that follows starts from the clip as
|
|
5044
|
+
* the undo left it, one undo step (#848, review of #915). Returns false
|
|
5045
|
+
* when the clip is gone (the undo removed it): the press is dropped.
|
|
5046
|
+
*/
|
|
5047
|
+
_startDrag() {
|
|
4946
5048
|
const engine = this._host.engine;
|
|
5049
|
+
const trackId = this._trackId;
|
|
5050
|
+
const clipId = this._clipId;
|
|
4947
5051
|
if (engine) {
|
|
4948
5052
|
const bounds = engine.getClipBounds(trackId, clipId);
|
|
4949
|
-
if (bounds)
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
if (engine) {
|
|
5053
|
+
if (!bounds) return false;
|
|
5054
|
+
this._originalStartSample = bounds.startSample;
|
|
5055
|
+
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5056
|
+
this._originalDurationSamples = bounds.durationSamples;
|
|
4954
5057
|
engine.beginTransaction();
|
|
4955
5058
|
} else {
|
|
4956
5059
|
console.warn(
|
|
4957
|
-
"[dawcore]
|
|
5060
|
+
"[dawcore] drag start: engine unavailable, drag mutations will not be grouped for undo"
|
|
4958
5061
|
);
|
|
4959
5062
|
}
|
|
4960
|
-
if (
|
|
5063
|
+
if (this._mode === "trim-left" || this._mode === "trim-right") {
|
|
4961
5064
|
const container = this._host.shadowRoot?.querySelector(
|
|
4962
5065
|
`.clip-container[data-clip-id="${clipId}"]`
|
|
4963
5066
|
);
|
|
@@ -4968,21 +5071,18 @@ var ClipPointerHandler = class {
|
|
|
4968
5071
|
} else {
|
|
4969
5072
|
console.warn("[dawcore] clip container not found for trim visual feedback: " + clipId);
|
|
4970
5073
|
}
|
|
4971
|
-
const engine2 = this._host.engine;
|
|
4972
|
-
if (engine2) {
|
|
4973
|
-
const bounds = engine2.getClipBounds(trackId, clipId);
|
|
4974
|
-
if (bounds) {
|
|
4975
|
-
this._originalOffsetSamples = bounds.offsetSamples;
|
|
4976
|
-
this._originalDurationSamples = bounds.durationSamples;
|
|
4977
|
-
}
|
|
4978
|
-
}
|
|
4979
5074
|
}
|
|
5075
|
+
return true;
|
|
4980
5076
|
}
|
|
4981
5077
|
/** Processes pointermove events during an active drag. */
|
|
4982
5078
|
onPointerMove(e) {
|
|
4983
5079
|
if (this._mode === null) return;
|
|
4984
5080
|
const totalDeltaPx = e.clientX - this._startPx;
|
|
4985
5081
|
if (!this._isDragging && Math.abs(totalDeltaPx) > DRAG_THRESHOLD) {
|
|
5082
|
+
if (!this._startDrag()) {
|
|
5083
|
+
this._reset();
|
|
5084
|
+
return;
|
|
5085
|
+
}
|
|
4986
5086
|
this._isDragging = true;
|
|
4987
5087
|
if (this._boundaryEl) {
|
|
4988
5088
|
this._boundaryEl.classList.add("dragging");
|
|
@@ -5104,10 +5204,12 @@ var ClipPointerHandler = class {
|
|
|
5104
5204
|
}
|
|
5105
5205
|
}
|
|
5106
5206
|
} finally {
|
|
5107
|
-
if (this._isDragging
|
|
5108
|
-
this.
|
|
5109
|
-
|
|
5110
|
-
|
|
5207
|
+
if (this._isDragging) {
|
|
5208
|
+
if (this._cumulativeDeltaSamples !== 0) {
|
|
5209
|
+
this._host.engine?.commitTransaction();
|
|
5210
|
+
} else {
|
|
5211
|
+
this._host.engine?.abortTransaction();
|
|
5212
|
+
}
|
|
5111
5213
|
}
|
|
5112
5214
|
this._reset();
|
|
5113
5215
|
}
|
|
@@ -5125,7 +5227,7 @@ var ClipPointerHandler = class {
|
|
|
5125
5227
|
try {
|
|
5126
5228
|
this._restoreTrimVisual();
|
|
5127
5229
|
} finally {
|
|
5128
|
-
this._host.engine?.abortTransaction();
|
|
5230
|
+
if (this._isDragging) this._host.engine?.abortTransaction();
|
|
5129
5231
|
this._reset();
|
|
5130
5232
|
}
|
|
5131
5233
|
}
|
|
@@ -5183,8 +5285,8 @@ var ClipPointerHandler = class {
|
|
|
5183
5285
|
};
|
|
5184
5286
|
|
|
5185
5287
|
// src/interactions/annotation-drag.ts
|
|
5186
|
-
var import_core9 = require("@waveform-playlist/core");
|
|
5187
5288
|
var import_core10 = require("@waveform-playlist/core");
|
|
5289
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
5188
5290
|
var AnnotationDragHandler = class {
|
|
5189
5291
|
constructor(host) {
|
|
5190
5292
|
this._drag = null;
|
|
@@ -5246,7 +5348,7 @@ var AnnotationDragHandler = class {
|
|
|
5246
5348
|
) - drag.edgeTime;
|
|
5247
5349
|
let newTick = drag.edgeTime + deltaTicks;
|
|
5248
5350
|
if (this._host.scaleMode === "beats" && this._host.snapTo !== "off") {
|
|
5249
|
-
newTick = (0,
|
|
5351
|
+
newTick = (0, import_core10.snapTickToGrid)(
|
|
5250
5352
|
newTick,
|
|
5251
5353
|
this._host.snapTo,
|
|
5252
5354
|
this._host._meterEntries,
|
|
@@ -5254,7 +5356,7 @@ var AnnotationDragHandler = class {
|
|
|
5254
5356
|
);
|
|
5255
5357
|
}
|
|
5256
5358
|
const clamp = this._host._annotationClampDuration;
|
|
5257
|
-
const updated2 = (0,
|
|
5359
|
+
const updated2 = (0, import_core10.updateAnnotationBoundaries)(
|
|
5258
5360
|
{
|
|
5259
5361
|
annotationIndex: index,
|
|
5260
5362
|
newTime: newTick,
|
|
@@ -5264,15 +5366,15 @@ var AnnotationDragHandler = class {
|
|
|
5264
5366
|
linkEndpoints: drag.track.linkEndpoints
|
|
5265
5367
|
},
|
|
5266
5368
|
{
|
|
5267
|
-
linkThreshold:
|
|
5268
|
-
minDuration: (0,
|
|
5369
|
+
linkThreshold: import_core11.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
5370
|
+
minDuration: (0, import_core11.annotationMinDurationTicks)(this._host.ppqn)
|
|
5269
5371
|
}
|
|
5270
5372
|
);
|
|
5271
5373
|
applyTickBoundaryResults(elements, updated2, (t) => this._host._ticksToSeconds(t));
|
|
5272
5374
|
return;
|
|
5273
5375
|
}
|
|
5274
5376
|
const deltaSeconds = deltaPx * this._host._renderSpp / this._host.effectiveSampleRate;
|
|
5275
|
-
const updated = (0,
|
|
5377
|
+
const updated = (0, import_core10.updateAnnotationBoundaries)({
|
|
5276
5378
|
annotationIndex: index,
|
|
5277
5379
|
newTime: drag.edgeTime + deltaSeconds,
|
|
5278
5380
|
isDraggingStart: drag.edge === "start",
|
|
@@ -5297,16 +5399,35 @@ var AnnotationDragHandler = class {
|
|
|
5297
5399
|
this._onPointerCancel = (e) => {
|
|
5298
5400
|
const drag = this._drag;
|
|
5299
5401
|
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5300
|
-
|
|
5301
|
-
if (drag.mode === "ticks") {
|
|
5302
|
-
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5303
|
-
} else {
|
|
5304
|
-
applyBoundaryResults(elements, drag.snapshot);
|
|
5305
|
-
}
|
|
5306
|
-
this._teardown();
|
|
5402
|
+
this._restoreAndTeardown(drag);
|
|
5307
5403
|
};
|
|
5308
5404
|
this._host = host;
|
|
5309
5405
|
}
|
|
5406
|
+
/** True from pointerdown on an annotation until the drag ends or is cancelled. */
|
|
5407
|
+
get isActive() {
|
|
5408
|
+
return this._drag !== null;
|
|
5409
|
+
}
|
|
5410
|
+
/** True once the pointer has moved at least `DRAG_THRESHOLD` px (an edge
|
|
5411
|
+
* drag, or a box press that moved): a press that has not moved (a click on
|
|
5412
|
+
* the box) is not a drag (#848). */
|
|
5413
|
+
get isDragging() {
|
|
5414
|
+
return this._drag?.moved ?? false;
|
|
5415
|
+
}
|
|
5416
|
+
/** Cancel the drag in progress (Escape, editor disconnect): the boundaries
|
|
5417
|
+
* go back to where they were when it began (#848). */
|
|
5418
|
+
cancel() {
|
|
5419
|
+
if (this._drag) this._restoreAndTeardown(this._drag);
|
|
5420
|
+
}
|
|
5421
|
+
/** Restore the drag-start snapshot — a cancelled drag must not commit. */
|
|
5422
|
+
_restoreAndTeardown(drag) {
|
|
5423
|
+
const elements = drag.track.annotationElements;
|
|
5424
|
+
if (drag.mode === "ticks") {
|
|
5425
|
+
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5426
|
+
} else {
|
|
5427
|
+
applyBoundaryResults(elements, drag.snapshot);
|
|
5428
|
+
}
|
|
5429
|
+
this._teardown();
|
|
5430
|
+
}
|
|
5310
5431
|
_teardown() {
|
|
5311
5432
|
const drag = this._drag;
|
|
5312
5433
|
if (!drag) return;
|
|
@@ -5454,6 +5575,10 @@ var TrackReorderHandler = class _TrackReorderHandler {
|
|
|
5454
5575
|
static _reducedMotion() {
|
|
5455
5576
|
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5456
5577
|
}
|
|
5578
|
+
/** True from the grab until the drag ends or is cancelled. */
|
|
5579
|
+
get isActive() {
|
|
5580
|
+
return this._trackId !== null;
|
|
5581
|
+
}
|
|
5457
5582
|
/** Abort any in-progress drag and reset state. Called by the editor on
|
|
5458
5583
|
* disconnect — without this, a drag interrupted by editor removal (with no
|
|
5459
5584
|
* pointercancel delivered) would leave the handler wedged and silently
|
|
@@ -5692,7 +5817,7 @@ function stringifyReason(reason) {
|
|
|
5692
5817
|
}
|
|
5693
5818
|
|
|
5694
5819
|
// src/interactions/recording-clip.ts
|
|
5695
|
-
var
|
|
5820
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
5696
5821
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
5697
5822
|
let trimmedBuf = buf;
|
|
5698
5823
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -5707,7 +5832,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5707
5832
|
}
|
|
5708
5833
|
trimmedBuf = trimmed;
|
|
5709
5834
|
}
|
|
5710
|
-
const clip = (0,
|
|
5835
|
+
const clip = (0, import_core12.createClip)({
|
|
5711
5836
|
audioBuffer: trimmedBuf,
|
|
5712
5837
|
startSample,
|
|
5713
5838
|
durationSamples: durSamples,
|
|
@@ -5734,7 +5859,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5734
5859
|
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
5735
5860
|
// startSample + durSamples) — carve overlapped content out of the
|
|
5736
5861
|
// existing clips before inserting (parity with the React provider).
|
|
5737
|
-
clips: [...(0,
|
|
5862
|
+
clips: [...(0, import_core12.carveClipRange)(t.clips, startSample, startSample + durSamples), clip]
|
|
5738
5863
|
});
|
|
5739
5864
|
const desc = host._tracks.get(trackId);
|
|
5740
5865
|
if (desc) {
|
|
@@ -6176,10 +6301,10 @@ function loadFaustModule(feature) {
|
|
|
6176
6301
|
}
|
|
6177
6302
|
|
|
6178
6303
|
// src/effects/effects-manager.ts
|
|
6179
|
-
var
|
|
6304
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
6180
6305
|
|
|
6181
6306
|
// src/effects/effect-registry.ts
|
|
6182
|
-
var
|
|
6307
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
6183
6308
|
var MAX_DELAY_SECONDS = 10;
|
|
6184
6309
|
function singleNode(node, applyParams) {
|
|
6185
6310
|
return { input: node, output: node, applyParams };
|
|
@@ -6255,8 +6380,8 @@ function biquadDefinition(spec) {
|
|
|
6255
6380
|
};
|
|
6256
6381
|
}
|
|
6257
6382
|
function registerBuiltIn(type, definition) {
|
|
6258
|
-
if (!(0,
|
|
6259
|
-
(0,
|
|
6383
|
+
if (!(0, import_core13.getEffectDefinitions)().has(type)) {
|
|
6384
|
+
(0, import_core13.registerEffect)(type, { ...definition, builtIn: true });
|
|
6260
6385
|
}
|
|
6261
6386
|
}
|
|
6262
6387
|
function registerBuiltIns() {
|
|
@@ -6411,7 +6536,7 @@ var EffectsManager = class {
|
|
|
6411
6536
|
/** Run a registered effect's async `prepare` hook on the adapter's
|
|
6412
6537
|
* context, so the synchronous addEffect() can create it. */
|
|
6413
6538
|
async prepareEffect(type) {
|
|
6414
|
-
await (0,
|
|
6539
|
+
await (0, import_core14.prepareEffect)(type, this._requireWiring().audioContext);
|
|
6415
6540
|
}
|
|
6416
6541
|
// --- Track chains ---
|
|
6417
6542
|
addTrackEffect(trackId, target, type, params) {
|
|
@@ -6616,7 +6741,7 @@ var EffectsManager = class {
|
|
|
6616
6741
|
this._runOp(chain, target, "setParams", effectId, { [paramId]: value });
|
|
6617
6742
|
};
|
|
6618
6743
|
if (entry.kind === "native") {
|
|
6619
|
-
const definition = (0,
|
|
6744
|
+
const definition = (0, import_core14.getEffectDefinitions)().get(entry.type);
|
|
6620
6745
|
if (!definition) {
|
|
6621
6746
|
throw new Error(
|
|
6622
6747
|
PREFIX2 + 'openEffectGui: no registry definition for effect type "' + entry.type + '"'
|
|
@@ -6675,7 +6800,7 @@ var EffectsManager = class {
|
|
|
6675
6800
|
}
|
|
6676
6801
|
_addToChain(chain, target, type, params) {
|
|
6677
6802
|
const audioContext = this._requireWiring().audioContext;
|
|
6678
|
-
const created = (0,
|
|
6803
|
+
const created = (0, import_core14.createEffectInstance)(type, audioContext, params);
|
|
6679
6804
|
const effectId = chain.add({
|
|
6680
6805
|
kind: "native",
|
|
6681
6806
|
type,
|
|
@@ -6847,8 +6972,8 @@ var EffectsManager = class {
|
|
|
6847
6972
|
if (entry.kind === "native") {
|
|
6848
6973
|
try {
|
|
6849
6974
|
const liveContext = this._requireWiring().audioContext;
|
|
6850
|
-
if ((0,
|
|
6851
|
-
await (0,
|
|
6975
|
+
if ((0, import_core14.needsPrepare)(entry.type, liveContext)) {
|
|
6976
|
+
await (0, import_core14.ensureEffectPrepared)(entry.type, liveContext);
|
|
6852
6977
|
if (superseded() || chain.disposed) return;
|
|
6853
6978
|
}
|
|
6854
6979
|
const id = this._addToChain(chain, target, entry.type, entry.params);
|
|
@@ -7023,8 +7148,8 @@ function toWamParameterMap(params) {
|
|
|
7023
7148
|
}
|
|
7024
7149
|
|
|
7025
7150
|
// src/interactions/export-audio.ts
|
|
7026
|
-
var import_core14 = require("@waveform-playlist/core");
|
|
7027
7151
|
var import_core15 = require("@waveform-playlist/core");
|
|
7152
|
+
var import_core16 = require("@waveform-playlist/core");
|
|
7028
7153
|
var PREFIX3 = "[waveform-playlist] ";
|
|
7029
7154
|
async function exportAudioImpl(host, options = {}) {
|
|
7030
7155
|
const sampleRate = options.sampleRate ?? host.effectiveSampleRate;
|
|
@@ -7059,7 +7184,7 @@ async function exportAudioImpl(host, options = {}) {
|
|
|
7059
7184
|
cleanups.push(chain.dispose);
|
|
7060
7185
|
const volume = ctx.createGain();
|
|
7061
7186
|
volume.gain.value = track.volume;
|
|
7062
|
-
const panStage = (0,
|
|
7187
|
+
const panStage = (0, import_core15.createPanStage)(ctx, track.pan, (0, import_core15.trackChannelCount)(track));
|
|
7063
7188
|
cleanups.push(panStage.dispose);
|
|
7064
7189
|
chain.output.connect(volume);
|
|
7065
7190
|
volume.connect(panStage.input);
|
|
@@ -7141,12 +7266,12 @@ async function buildOfflineChain(ctx, entries) {
|
|
|
7141
7266
|
continue;
|
|
7142
7267
|
}
|
|
7143
7268
|
if (entry.kind === "native") {
|
|
7144
|
-
const definition = (0,
|
|
7269
|
+
const definition = (0, import_core16.getEffectDefinitions)().get(entry.type);
|
|
7145
7270
|
if (entry.bypassed && definition && !definition.wetParam) {
|
|
7146
7271
|
continue;
|
|
7147
7272
|
}
|
|
7148
|
-
await (0,
|
|
7149
|
-
const created = (0,
|
|
7273
|
+
await (0, import_core16.ensureEffectPrepared)(entry.type, ctx);
|
|
7274
|
+
const created = (0, import_core16.createEffectInstance)(entry.type, ctx, entry.params);
|
|
7150
7275
|
if (entry.bypassed && created.wetParam) {
|
|
7151
7276
|
created.instance.applyParams({ [created.wetParam]: 0 });
|
|
7152
7277
|
}
|
|
@@ -7450,6 +7575,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7450
7575
|
/** Resolved sample rate — falls back to sampleRate property until first audio decode. */
|
|
7451
7576
|
this._resolvedSampleRate = null;
|
|
7452
7577
|
this._tracks = /* @__PURE__ */ new Map();
|
|
7578
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
7453
7579
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
7454
7580
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
7455
7581
|
this._isPlaying = false;
|
|
@@ -7572,6 +7698,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7572
7698
|
}
|
|
7573
7699
|
const descriptor = this._readTrackDescriptor(trackEl);
|
|
7574
7700
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7701
|
+
this._setSeedMix(trackId, mixOfElement(trackEl));
|
|
7575
7702
|
this._trackElements.set(trackId, trackEl);
|
|
7576
7703
|
this._loadTrack(trackId, descriptor);
|
|
7577
7704
|
};
|
|
@@ -7597,15 +7724,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7597
7724
|
});
|
|
7598
7725
|
}
|
|
7599
7726
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
this._engine.setTrackVolume(trackId, descriptor.volume);
|
|
7603
|
-
if (oldDescriptor?.pan !== descriptor.pan) this._engine.setTrackPan(trackId, descriptor.pan);
|
|
7604
|
-
if (oldDescriptor?.muted !== descriptor.muted)
|
|
7605
|
-
this._engine.setTrackMute(trackId, descriptor.muted);
|
|
7606
|
-
if (oldDescriptor?.soloed !== descriptor.soloed)
|
|
7607
|
-
this._engine.setTrackSolo(trackId, descriptor.soloed);
|
|
7608
|
-
}
|
|
7727
|
+
const changed = Array.isArray(e.detail.changed) ? e.detail.changed : [];
|
|
7728
|
+
this._writeMixFields(trackId, pickMix(mixOfElement(trackEl), changed));
|
|
7609
7729
|
if (oldDescriptor?.src !== descriptor.src) {
|
|
7610
7730
|
this._loadTrack(trackId, descriptor);
|
|
7611
7731
|
}
|
|
@@ -7631,7 +7751,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7631
7751
|
}
|
|
7632
7752
|
};
|
|
7633
7753
|
this._onTrackControl = (e) => {
|
|
7634
|
-
const { trackId, prop, value } = e.detail ?? {};
|
|
7754
|
+
const { trackId, prop, value, gesture } = e.detail ?? {};
|
|
7635
7755
|
if (!trackId || !prop || !DawEditorElement._CONTROL_PROPS.has(prop)) return;
|
|
7636
7756
|
if (this._selectedTrackId !== trackId) {
|
|
7637
7757
|
this._setSelectedTrackId(trackId);
|
|
@@ -7646,18 +7766,12 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7646
7766
|
})
|
|
7647
7767
|
);
|
|
7648
7768
|
}
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7653
|
-
if (this.
|
|
7654
|
-
|
|
7655
|
-
this._engine.setTrackVolume(trackId, Math.max(0, Math.min(1, Number(value))));
|
|
7656
|
-
if (prop === "pan")
|
|
7657
|
-
this._engine.setTrackPan(trackId, Math.max(-1, Math.min(1, Number(value))));
|
|
7658
|
-
if (prop === "muted") this._engine.setTrackMute(trackId, Boolean(value));
|
|
7659
|
-
if (prop === "soloed") this._engine.setTrackSolo(trackId, Boolean(value));
|
|
7660
|
-
}
|
|
7769
|
+
if (this._tracks.has(trackId)) {
|
|
7770
|
+
const options = typeof gesture === "string" ? { gesture } : void 0;
|
|
7771
|
+
if (prop === "volume") this._writeMix(trackId, "volume", clampNumber(value, 0, 1), options);
|
|
7772
|
+
if (prop === "pan") this._writeMix(trackId, "pan", clampNumber(value, -1, 1), options);
|
|
7773
|
+
if (prop === "muted") this._writeMix(trackId, "muted", Boolean(value), options);
|
|
7774
|
+
if (prop === "soloed") this._writeMix(trackId, "soloed", Boolean(value), options);
|
|
7661
7775
|
}
|
|
7662
7776
|
};
|
|
7663
7777
|
this._onTrackRemoveRequest = (e) => {
|
|
@@ -7768,6 +7882,16 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7768
7882
|
if (!this.trackReordering) return;
|
|
7769
7883
|
this._trackReorderDrag.onGrab(e.detail.trackId, e.detail.pointerEvent, e.detail.gripElement);
|
|
7770
7884
|
};
|
|
7885
|
+
/**
|
|
7886
|
+
* Escape during a drag cancels it and does nothing else: the default is
|
|
7887
|
+
* prevented, so `<daw-keyboard-shortcuts>` (core's `handleKeyboardEvent`)
|
|
7888
|
+
* does not also stop playback. No `stopPropagation`: an app's own listener
|
|
7889
|
+
* can read `defaultPrevented`.
|
|
7890
|
+
*/
|
|
7891
|
+
this._onDragEscape = (e) => {
|
|
7892
|
+
if (e.key !== "Escape") return;
|
|
7893
|
+
if (this._cancelDrags()) e.preventDefault();
|
|
7894
|
+
};
|
|
7771
7895
|
// --- Recording ---
|
|
7772
7896
|
this.recordingStream = null;
|
|
7773
7897
|
/** Set in togglePauseRecording when Transport is paused alongside the
|
|
@@ -8278,9 +8402,69 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8278
8402
|
get tracks() {
|
|
8279
8403
|
return [...this._tracks.entries()].map(([trackId, descriptor]) => ({
|
|
8280
8404
|
trackId,
|
|
8281
|
-
...descriptor
|
|
8405
|
+
...descriptor,
|
|
8406
|
+
...this._mixOf(trackId)
|
|
8282
8407
|
}));
|
|
8283
8408
|
}
|
|
8409
|
+
/**
|
|
8410
|
+
* A track's mix, from its one owner: the arrangement (through
|
|
8411
|
+
* `_engineTracks`, which follows `mixerVersion`) for a track the engine
|
|
8412
|
+
* holds, the seed for one still on its way in (#843).
|
|
8413
|
+
*/
|
|
8414
|
+
_mixOf(trackId) {
|
|
8415
|
+
const seed = this._seedMix.get(trackId);
|
|
8416
|
+
if (seed) return seed;
|
|
8417
|
+
const track = this._engineTracks.get(trackId);
|
|
8418
|
+
return track ? mixOfTrack(track) : DEFAULT_TRACK_MIX;
|
|
8419
|
+
}
|
|
8420
|
+
/** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
|
|
8421
|
+
_setSeedMix(trackId, mix) {
|
|
8422
|
+
this._seedMix = new Map(this._seedMix).set(trackId, mix);
|
|
8423
|
+
}
|
|
8424
|
+
_deleteSeedMix(trackIds) {
|
|
8425
|
+
let next = null;
|
|
8426
|
+
for (const id of trackIds) {
|
|
8427
|
+
if (!this._seedMix.has(id)) continue;
|
|
8428
|
+
next ?? (next = new Map(this._seedMix));
|
|
8429
|
+
next.delete(id);
|
|
8430
|
+
}
|
|
8431
|
+
if (next) this._seedMix = next;
|
|
8432
|
+
}
|
|
8433
|
+
/**
|
|
8434
|
+
* Change one mixer field of a track: the seed while the track is loading
|
|
8435
|
+
* (not an undo step, nothing sent), else the engine's setter with
|
|
8436
|
+
* `options` (an undo step; changes with one `gesture` id are one step).
|
|
8437
|
+
*/
|
|
8438
|
+
_writeMix(trackId, field, value, options) {
|
|
8439
|
+
const seed = this._seedMix.get(trackId);
|
|
8440
|
+
if (seed) {
|
|
8441
|
+
if (seed[field] !== value) this._setSeedMix(trackId, { ...seed, [field]: value });
|
|
8442
|
+
return;
|
|
8443
|
+
}
|
|
8444
|
+
if (!this._engine) return;
|
|
8445
|
+
if (field === "volume") this._engine.setTrackVolume(trackId, value, options);
|
|
8446
|
+
else if (field === "pan") this._engine.setTrackPan(trackId, value, options);
|
|
8447
|
+
else if (field === "muted") this._engine.setTrackMute(trackId, value, options);
|
|
8448
|
+
else this._engine.setTrackSolo(trackId, value, options);
|
|
8449
|
+
}
|
|
8450
|
+
/**
|
|
8451
|
+
* Change the given mixer fields of a track as ONE undo step (#843): all
|
|
8452
|
+
* of them carry one fresh gesture id. A field left out is not sent.
|
|
8453
|
+
*/
|
|
8454
|
+
_writeMixFields(trackId, mix) {
|
|
8455
|
+
const options = { gesture: (0, import_core17.createMixerGesture)().id };
|
|
8456
|
+
if (mix.volume !== void 0) this._writeMix(trackId, "volume", mix.volume, options);
|
|
8457
|
+
if (mix.pan !== void 0) this._writeMix(trackId, "pan", mix.pan, options);
|
|
8458
|
+
if (mix.muted !== void 0) this._writeMix(trackId, "muted", mix.muted, options);
|
|
8459
|
+
if (mix.soloed !== void 0) this._writeMix(trackId, "soloed", mix.soloed, options);
|
|
8460
|
+
}
|
|
8461
|
+
/** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
|
|
8462
|
+
_tracksForEngine() {
|
|
8463
|
+
return this._getOrderedTracks().map(([trackId, track]) => {
|
|
8464
|
+
const seed = this._seedMix.get(trackId);
|
|
8465
|
+
return seed ? withMix(track, seed) : track;
|
|
8466
|
+
});
|
|
8467
|
+
}
|
|
8284
8468
|
get selectedTrackId() {
|
|
8285
8469
|
return this._selectedTrackId;
|
|
8286
8470
|
}
|
|
@@ -8306,6 +8490,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8306
8490
|
// --- Lifecycle ---
|
|
8307
8491
|
connectedCallback() {
|
|
8308
8492
|
super.connectedCallback();
|
|
8493
|
+
window.addEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8309
8494
|
this.addEventListener("daw-track-connected", this._onTrackConnected);
|
|
8310
8495
|
this.addEventListener("daw-track-update", this._onTrackUpdate);
|
|
8311
8496
|
this.addEventListener("daw-track-control", this._onTrackControl);
|
|
@@ -8366,6 +8551,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8366
8551
|
}
|
|
8367
8552
|
disconnectedCallback() {
|
|
8368
8553
|
super.disconnectedCallback();
|
|
8554
|
+
window.removeEventListener("keydown", this._onDragEscape, { capture: true });
|
|
8369
8555
|
this._effectsManager?.disposeAll();
|
|
8370
8556
|
this._effectsManager = null;
|
|
8371
8557
|
this.removeEventListener("daw-track-connected", this._onTrackConnected);
|
|
@@ -8381,7 +8567,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8381
8567
|
this.removeEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
8382
8568
|
this.removeEventListener("daw-track-reorder", this._onTrackReorder);
|
|
8383
8569
|
this.removeEventListener("daw-track-reorder-grab", this._onTrackReorderGrab);
|
|
8384
|
-
this.
|
|
8570
|
+
this._cancelDrags(true);
|
|
8385
8571
|
this._childObserver?.disconnect();
|
|
8386
8572
|
this._childObserver = null;
|
|
8387
8573
|
this._trackElements.clear();
|
|
@@ -8404,6 +8590,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8404
8590
|
this._adapterConsumedByDispose = true;
|
|
8405
8591
|
}
|
|
8406
8592
|
this._tracks = /* @__PURE__ */ new Map();
|
|
8593
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
8407
8594
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
8408
8595
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
8409
8596
|
this._loadingTracks.clear();
|
|
@@ -8477,6 +8664,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8477
8664
|
const nextTracks = new Map(this._tracks);
|
|
8478
8665
|
nextTracks.delete(trackId);
|
|
8479
8666
|
this._tracks = nextTracks;
|
|
8667
|
+
this._deleteSeedMix([trackId]);
|
|
8480
8668
|
const nextEngine = new Map(this._engineTracks);
|
|
8481
8669
|
nextEngine.delete(trackId);
|
|
8482
8670
|
this._engineTracks = nextEngine;
|
|
@@ -8538,12 +8726,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8538
8726
|
next.set(track.id, {
|
|
8539
8727
|
name: track.name ?? "",
|
|
8540
8728
|
src: "",
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
muted: track.muted ?? false,
|
|
8544
|
-
soloed: track.soloed ?? false,
|
|
8545
|
-
kind: (0, import_core16.trackKind)(track),
|
|
8546
|
-
renderMode: trackDescriptorRenderMode((0, import_core16.trackKind)(track), "waveform"),
|
|
8729
|
+
kind: (0, import_core17.trackKind)(track),
|
|
8730
|
+
renderMode: trackDescriptorRenderMode((0, import_core17.trackKind)(track), "waveform"),
|
|
8547
8731
|
clips: []
|
|
8548
8732
|
});
|
|
8549
8733
|
}
|
|
@@ -8700,7 +8884,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8700
8884
|
let clip;
|
|
8701
8885
|
if (waveformData) {
|
|
8702
8886
|
const wdRate = waveformData.sample_rate;
|
|
8703
|
-
clip = (0,
|
|
8887
|
+
clip = (0, import_core17.createClip)({
|
|
8704
8888
|
audioBuffer,
|
|
8705
8889
|
waveformData,
|
|
8706
8890
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
@@ -8713,7 +8897,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8713
8897
|
});
|
|
8714
8898
|
this._peakPipeline.cacheWaveformData(audioBuffer, waveformData);
|
|
8715
8899
|
} else {
|
|
8716
|
-
clip = (0,
|
|
8900
|
+
clip = (0, import_core17.createClipFromSeconds)({
|
|
8717
8901
|
audioBuffer,
|
|
8718
8902
|
startTime: clipDesc.start,
|
|
8719
8903
|
duration: clipDesc.duration || audioBuffer.duration,
|
|
@@ -8792,7 +8976,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8792
8976
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
8793
8977
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipDesc.duration, 1) * sr);
|
|
8794
8978
|
const requestedDurationSamples = clipDesc.duration > 0 ? Math.round(clipDesc.duration * sr) : sourceDurationSamples;
|
|
8795
|
-
const clip = (0,
|
|
8979
|
+
const clip = (0, import_core17.createClip)({
|
|
8796
8980
|
startSample: Math.round(clipDesc.start * sr),
|
|
8797
8981
|
durationSamples: requestedDurationSamples,
|
|
8798
8982
|
offsetSamples: Math.round(clipDesc.offset * sr),
|
|
@@ -8828,8 +9012,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8828
9012
|
_commitTrackChange(trackId, updatedTrack) {
|
|
8829
9013
|
this._recomputeDuration();
|
|
8830
9014
|
if (this._engine?.updateTrack) this._engine.updateTrack(trackId, updatedTrack);
|
|
8831
|
-
else if (this._engine)
|
|
8832
|
-
this._engine.setTracks(this._getOrderedTracks().map(([, track]) => track));
|
|
9015
|
+
else if (this._engine) this._engine.setTracks(this._tracksForEngine());
|
|
8833
9016
|
}
|
|
8834
9017
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
8835
9018
|
const t = this._engineTracks.get(trackId);
|
|
@@ -8848,7 +9031,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8848
9031
|
const sr = oldClip.sampleRate ?? this.effectiveSampleRate;
|
|
8849
9032
|
const isMidiNow = clipEl.midiNotes != null && !clipEl.src;
|
|
8850
9033
|
const wasMidi = oldClip.midiNotes != null;
|
|
8851
|
-
if (isMidiNow && (0,
|
|
9034
|
+
if (isMidiNow && (0, import_core17.trackKind)(t) !== "midi") {
|
|
8852
9035
|
const kindError = this._clipKindError(t.name, "audio", true, clipEl.name || clipId);
|
|
8853
9036
|
console.warn("[dawcore] _applyClipUpdate: " + kindError?.message);
|
|
8854
9037
|
this.dispatchEvent(
|
|
@@ -8991,10 +9174,6 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8991
9174
|
return {
|
|
8992
9175
|
name: trackEl.name || "Untitled",
|
|
8993
9176
|
src: trackEl.src,
|
|
8994
|
-
volume: trackEl.volume,
|
|
8995
|
-
pan: trackEl.pan,
|
|
8996
|
-
muted: trackEl.muted,
|
|
8997
|
-
soloed: trackEl.soloed,
|
|
8998
9177
|
kind: trackEl.kind,
|
|
8999
9178
|
renderMode: trackDescriptorRenderMode(trackEl.kind, trackEl.renderMode),
|
|
9000
9179
|
clips
|
|
@@ -9053,7 +9232,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9053
9232
|
const waveformData = await waveformDataPromise;
|
|
9054
9233
|
if (waveformData) {
|
|
9055
9234
|
const wdRate = waveformData.sample_rate;
|
|
9056
|
-
const clip2 = (0,
|
|
9235
|
+
const clip2 = (0, import_core17.createClip)({
|
|
9057
9236
|
waveformData,
|
|
9058
9237
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
9059
9238
|
durationSamples: Math.round((clipDesc.duration || waveformData.duration) * wdRate),
|
|
@@ -9079,14 +9258,11 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9079
9258
|
this._peaksData = new Map(this._peaksData).set(clip2.id, peakData);
|
|
9080
9259
|
this._raiseZoomFloor(waveformData.scale);
|
|
9081
9260
|
if (this._tracks.has(trackId)) {
|
|
9082
|
-
const previewTrack = (0,
|
|
9261
|
+
const previewTrack = (0, import_core17.createTrack)({
|
|
9083
9262
|
name: descriptor.name,
|
|
9084
9263
|
kind: descriptor.kind,
|
|
9085
9264
|
clips: [clip2],
|
|
9086
|
-
|
|
9087
|
-
pan: descriptor.pan,
|
|
9088
|
-
muted: descriptor.muted,
|
|
9089
|
-
soloed: descriptor.soloed
|
|
9265
|
+
...this._mixOf(trackId)
|
|
9090
9266
|
});
|
|
9091
9267
|
previewTrack.id = trackId;
|
|
9092
9268
|
this._engineTracks = new Map(this._engineTracks).set(trackId, previewTrack);
|
|
@@ -9157,14 +9333,11 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9157
9333
|
trackWasRemoved ? "removed" : "disconnected"
|
|
9158
9334
|
);
|
|
9159
9335
|
}
|
|
9160
|
-
const track = (0,
|
|
9336
|
+
const track = (0, import_core17.createTrack)({
|
|
9161
9337
|
name: descriptor.name,
|
|
9162
9338
|
kind: descriptor.kind,
|
|
9163
9339
|
clips,
|
|
9164
|
-
|
|
9165
|
-
pan: descriptor.pan,
|
|
9166
|
-
muted: descriptor.muted,
|
|
9167
|
-
soloed: descriptor.soloed
|
|
9340
|
+
...this._mixOf(trackId)
|
|
9168
9341
|
});
|
|
9169
9342
|
const requestedClips = descriptor.clips.filter((c) => c.src).length + refusedMidiClips;
|
|
9170
9343
|
if (requestedClips > 0 && clips.length === 0) {
|
|
@@ -9179,7 +9352,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9179
9352
|
this._maybeRegisterSpectrogramClipAudio(trackId, c);
|
|
9180
9353
|
}
|
|
9181
9354
|
const engine = await this._ensureEngine();
|
|
9182
|
-
engine.setTracks(this.
|
|
9355
|
+
engine.setTracks(this._tracksForEngine());
|
|
9183
9356
|
this.dispatchEvent(
|
|
9184
9357
|
new CustomEvent("daw-track-ready", {
|
|
9185
9358
|
bubbles: true,
|
|
@@ -9304,6 +9477,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9304
9477
|
nextTracks.set(track.id, track);
|
|
9305
9478
|
}
|
|
9306
9479
|
this._engineTracks = nextTracks;
|
|
9480
|
+
this._deleteSeedMix(nextTracks.keys());
|
|
9307
9481
|
this._reconcileDescriptorsWithEngineTracks(engineState.tracks);
|
|
9308
9482
|
}
|
|
9309
9483
|
if (structuralChange) {
|
|
@@ -9311,7 +9485,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9311
9485
|
this._syncDomToEngineOrder(engineState.tracks);
|
|
9312
9486
|
}
|
|
9313
9487
|
this._effectsManager?.rewireTrackChains();
|
|
9314
|
-
const audioTracks = engineState.tracks.filter((t) => (0,
|
|
9488
|
+
const audioTracks = engineState.tracks.filter((t) => (0, import_core17.trackKind)(t) !== "midi");
|
|
9315
9489
|
syncPeaksForChangedClips(this, audioTracks);
|
|
9316
9490
|
}
|
|
9317
9491
|
if (engineState.bpm !== this._lastAnnotationBpm) {
|
|
@@ -9477,14 +9651,22 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9477
9651
|
}
|
|
9478
9652
|
}
|
|
9479
9653
|
/**
|
|
9480
|
-
* Update reflected attributes on a track.
|
|
9481
|
-
*
|
|
9482
|
-
*
|
|
9483
|
-
*
|
|
9654
|
+
* Update reflected attributes on a track. The mixer fields go to their
|
|
9655
|
+
* owner as one undo step (#843): the engine, or while the track is loading
|
|
9656
|
+
* the values it will enter with (not a step). For DOM-element tracks the
|
|
9657
|
+
* changes are also written to the `<daw-track>` element; for tracks
|
|
9658
|
+
* without a DOM element (file drops) the descriptor is updated in place.
|
|
9484
9659
|
*/
|
|
9485
9660
|
updateTrack(trackId, partial) {
|
|
9661
|
+
const mix = {
|
|
9662
|
+
volume: partial.volume,
|
|
9663
|
+
pan: partial.pan,
|
|
9664
|
+
muted: partial.muted,
|
|
9665
|
+
soloed: partial.soloed
|
|
9666
|
+
};
|
|
9486
9667
|
const trackEl = this._trackElements.get(trackId);
|
|
9487
9668
|
if (trackEl) {
|
|
9669
|
+
this._writeMixFields(trackId, mix);
|
|
9488
9670
|
if (partial.name !== void 0) trackEl.setAttribute("name", partial.name);
|
|
9489
9671
|
if (partial.volume !== void 0) trackEl.volume = partial.volume;
|
|
9490
9672
|
if (partial.pan !== void 0) trackEl.pan = partial.pan;
|
|
@@ -9511,21 +9693,12 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9511
9693
|
const newDesc = {
|
|
9512
9694
|
...oldDesc,
|
|
9513
9695
|
...partial.name !== void 0 && { name: partial.name },
|
|
9514
|
-
...partial.volume !== void 0 && { volume: partial.volume },
|
|
9515
|
-
...partial.pan !== void 0 && { pan: partial.pan },
|
|
9516
|
-
...partial.muted !== void 0 && { muted: partial.muted },
|
|
9517
|
-
...partial.soloed !== void 0 && { soloed: partial.soloed },
|
|
9518
9696
|
...normalizedRenderMode !== void 0 && {
|
|
9519
9697
|
renderMode: trackDescriptorRenderMode(oldDesc.kind, normalizedRenderMode)
|
|
9520
9698
|
}
|
|
9521
9699
|
};
|
|
9522
9700
|
this._tracks = new Map(this._tracks).set(trackId, newDesc);
|
|
9523
|
-
|
|
9524
|
-
if (partial.volume !== void 0) this._engine.setTrackVolume(trackId, partial.volume);
|
|
9525
|
-
if (partial.pan !== void 0) this._engine.setTrackPan(trackId, partial.pan);
|
|
9526
|
-
if (partial.muted !== void 0) this._engine.setTrackMute(trackId, partial.muted);
|
|
9527
|
-
if (partial.soloed !== void 0) this._engine.setTrackSolo(trackId, partial.soloed);
|
|
9528
|
-
}
|
|
9701
|
+
this._writeMixFields(trackId, mix);
|
|
9529
9702
|
}
|
|
9530
9703
|
/**
|
|
9531
9704
|
* Append a clip to an existing track. Builds a `<daw-clip>` from `config`
|
|
@@ -9785,16 +9958,49 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9785
9958
|
})
|
|
9786
9959
|
);
|
|
9787
9960
|
}
|
|
9788
|
-
/**
|
|
9961
|
+
/**
|
|
9962
|
+
* A clip or track drag is in progress: undo and redo do nothing until it
|
|
9963
|
+
* ends (#848). A clip counts once its pointer has moved past the drag
|
|
9964
|
+
* threshold; annotation drags do not count (annotations are not in the
|
|
9965
|
+
* undo history).
|
|
9966
|
+
*/
|
|
9967
|
+
get _dragInProgress() {
|
|
9968
|
+
return this._clipPointer.isDragging || this._trackReorderDrag.isActive;
|
|
9969
|
+
}
|
|
9970
|
+
/**
|
|
9971
|
+
* Cancel every drag in progress, as a `pointercancel` would. Returns whether
|
|
9972
|
+
* one was. A clip or annotation press that has not moved is not a drag and
|
|
9973
|
+
* is left alone, unless `includePresses` (the editor's disconnect, which
|
|
9974
|
+
* ends every pointer interaction).
|
|
9975
|
+
*/
|
|
9976
|
+
_cancelDrags(includePresses = false) {
|
|
9977
|
+
let cancelled = false;
|
|
9978
|
+
if (includePresses || this._clipPointer.isDragging) {
|
|
9979
|
+
cancelled = this._pointer.cancelClipDrag() || cancelled;
|
|
9980
|
+
}
|
|
9981
|
+
if (this._trackReorderDrag.isActive) {
|
|
9982
|
+
this._trackReorderDrag.cancel();
|
|
9983
|
+
cancelled = true;
|
|
9984
|
+
}
|
|
9985
|
+
const annotation = this._annotationDrag;
|
|
9986
|
+
if (includePresses ? annotation.isActive : annotation.isDragging) {
|
|
9987
|
+
annotation.cancel();
|
|
9988
|
+
cancelled = true;
|
|
9989
|
+
}
|
|
9990
|
+
return cancelled;
|
|
9991
|
+
}
|
|
9992
|
+
/** Undo the last edit. Does nothing while a drag is in progress. */
|
|
9789
9993
|
undo() {
|
|
9994
|
+
if (this._dragInProgress) return;
|
|
9790
9995
|
if (!this._engine) {
|
|
9791
9996
|
console.warn("[dawcore] undo: engine not ready, call ignored");
|
|
9792
9997
|
return;
|
|
9793
9998
|
}
|
|
9794
9999
|
this._engine.undo();
|
|
9795
10000
|
}
|
|
9796
|
-
/** Redo the last undone edit. */
|
|
10001
|
+
/** Redo the last undone edit. Does nothing while a drag is in progress. */
|
|
9797
10002
|
redo() {
|
|
10003
|
+
if (this._dragInProgress) return;
|
|
9798
10004
|
if (!this._engine) {
|
|
9799
10005
|
console.warn("[dawcore] redo: engine not ready, call ignored");
|
|
9800
10006
|
return;
|
|
@@ -10153,22 +10359,24 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10153
10359
|
<span class="annotation-lane-name">${track.name}</span>
|
|
10154
10360
|
</div>`
|
|
10155
10361
|
)}
|
|
10156
|
-
${orderedTracks.map(
|
|
10157
|
-
|
|
10362
|
+
${orderedTracks.map((t, i) => {
|
|
10363
|
+
const mix = this._mixOf(t.trackId);
|
|
10364
|
+
return import_lit19.html`
|
|
10158
10365
|
<daw-track-controls
|
|
10159
10366
|
style="height: ${t.trackHeight}px;"
|
|
10160
10367
|
.trackId=${t.trackId}
|
|
10161
10368
|
.trackName=${t.descriptor?.name ?? "Untitled"}
|
|
10162
|
-
.volume=${
|
|
10163
|
-
.pan=${
|
|
10164
|
-
.muted=${
|
|
10165
|
-
.
|
|
10369
|
+
.volume=${mix.volume}
|
|
10370
|
+
.pan=${mix.pan}
|
|
10371
|
+
.muted=${mix.muted}
|
|
10372
|
+
.recording=${this._engine?.recordingTrackIds.has(t.trackId) ?? false}
|
|
10373
|
+
.soloed=${mix.soloed}
|
|
10166
10374
|
.reorderable=${this.trackReordering}
|
|
10167
10375
|
.trackIndex=${i}
|
|
10168
10376
|
.trackCount=${orderedTracks.length}
|
|
10169
10377
|
></daw-track-controls>
|
|
10170
|
-
|
|
10171
|
-
)}
|
|
10378
|
+
`;
|
|
10379
|
+
})}
|
|
10172
10380
|
</div>
|
|
10173
10381
|
</div>` : ""}
|
|
10174
10382
|
<div class="scroll-area">
|
|
@@ -10220,7 +10428,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10220
10428
|
width = Math.round(endTick / this.ticksPerPixel) - clipLeft;
|
|
10221
10429
|
} else {
|
|
10222
10430
|
clipLeft = Math.floor(clip.startSample / spp);
|
|
10223
|
-
width = (0,
|
|
10431
|
+
width = (0, import_core17.clipPixelWidth)(clip.startSample, clip.durationSamples, spp);
|
|
10224
10432
|
}
|
|
10225
10433
|
let clipSegments;
|
|
10226
10434
|
let segmentChannels;
|
|
@@ -10578,6 +10786,9 @@ __decorateClass([
|
|
|
10578
10786
|
__decorateClass([
|
|
10579
10787
|
(0, import_decorators16.state)()
|
|
10580
10788
|
], DawEditorElement.prototype, "_tracks", 2);
|
|
10789
|
+
__decorateClass([
|
|
10790
|
+
(0, import_decorators16.state)()
|
|
10791
|
+
], DawEditorElement.prototype, "_seedMix", 2);
|
|
10581
10792
|
__decorateClass([
|
|
10582
10793
|
(0, import_decorators16.state)()
|
|
10583
10794
|
], DawEditorElement.prototype, "_engineTracks", 2);
|
|
@@ -10745,7 +10956,7 @@ DawRecordButtonElement = __decorateClass([
|
|
|
10745
10956
|
// src/elements/daw-keyboard-shortcuts.ts
|
|
10746
10957
|
var import_lit22 = require("lit");
|
|
10747
10958
|
var import_decorators19 = require("lit/decorators.js");
|
|
10748
|
-
var
|
|
10959
|
+
var import_core18 = require("@waveform-playlist/core");
|
|
10749
10960
|
var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
10750
10961
|
constructor() {
|
|
10751
10962
|
super(...arguments);
|
|
@@ -10770,7 +10981,7 @@ var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
|
10770
10981
|
const shortcuts = this.shortcuts;
|
|
10771
10982
|
if (shortcuts.length === 0) return;
|
|
10772
10983
|
try {
|
|
10773
|
-
(0,
|
|
10984
|
+
(0, import_core18.handleKeyboardEvent)(e, shortcuts, true);
|
|
10774
10985
|
} catch (err) {
|
|
10775
10986
|
console.warn("[dawcore] Keyboard shortcut failed (key=" + e.key + "): " + String(err));
|
|
10776
10987
|
const target = this._editor ?? this;
|
|
@@ -10960,7 +11171,7 @@ DawKeyboardShortcutsElement = __decorateClass([
|
|
|
10960
11171
|
// src/elements/daw-spectrogram.ts
|
|
10961
11172
|
var import_lit23 = require("lit");
|
|
10962
11173
|
var import_decorators20 = require("lit/decorators.js");
|
|
10963
|
-
var
|
|
11174
|
+
var import_core19 = require("@waveform-playlist/core");
|
|
10964
11175
|
var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
10965
11176
|
constructor() {
|
|
10966
11177
|
super(...arguments);
|
|
@@ -11025,11 +11236,11 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11025
11236
|
this._unregisterAllCanvases();
|
|
11026
11237
|
this._canvases = [];
|
|
11027
11238
|
if (this.length <= 0) return;
|
|
11028
|
-
const chunkCount = Math.ceil(this.length /
|
|
11239
|
+
const chunkCount = Math.ceil(this.length / import_core19.MAX_CANVAS_WIDTH);
|
|
11029
11240
|
for (let i = 0; i < chunkCount; i++) {
|
|
11030
|
-
const widthPx = Math.min(
|
|
11241
|
+
const widthPx = Math.min(import_core19.MAX_CANVAS_WIDTH, this.length - i * import_core19.MAX_CANVAS_WIDTH);
|
|
11031
11242
|
const canvas = document.createElement("canvas");
|
|
11032
|
-
canvas.style.left = i *
|
|
11243
|
+
canvas.style.left = i * import_core19.MAX_CANVAS_WIDTH + "px";
|
|
11033
11244
|
canvas.style.width = widthPx + "px";
|
|
11034
11245
|
const dpr = window.devicePixelRatio || 1;
|
|
11035
11246
|
canvas.width = widthPx * dpr;
|
|
@@ -11055,7 +11266,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11055
11266
|
}
|
|
11056
11267
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
11057
11268
|
const canvas = this._canvases[i];
|
|
11058
|
-
const canvasId = (0,
|
|
11269
|
+
const canvasId = (0, import_core19.buildSpectrogramCanvasId)({
|
|
11059
11270
|
clipId: this.clipId,
|
|
11060
11271
|
channelIndex: this.channelIndex,
|
|
11061
11272
|
chunkIndex: i
|
|
@@ -11076,7 +11287,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11076
11287
|
trackId: this.trackId,
|
|
11077
11288
|
channelIndex: this.channelIndex,
|
|
11078
11289
|
chunkIndex: i,
|
|
11079
|
-
globalPixelOffset: this.originX + i *
|
|
11290
|
+
globalPixelOffset: this.originX + i * import_core19.MAX_CANVAS_WIDTH,
|
|
11080
11291
|
widthPx: parseFloat(canvas.style.width),
|
|
11081
11292
|
heightPx: this.waveHeight
|
|
11082
11293
|
});
|