@dawcore/components 0.0.39-next.2 → 0.0.39-next.4
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 +5 -5
- package/dist/index.d.mts +96 -28
- package/dist/index.d.ts +96 -28
- package/dist/index.js +267 -160
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +209 -101
- 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.3", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.3", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.3", "@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.3" };
|
|
86
86
|
|
|
87
87
|
// src/elements/daw-annotation.ts
|
|
88
88
|
var import_lit = require("lit");
|
|
@@ -1062,6 +1062,17 @@ function isDomClip(desc) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
|
|
1064
1064
|
// src/elements/daw-track.ts
|
|
1065
|
+
var TRACK_PROPS = [
|
|
1066
|
+
"volume",
|
|
1067
|
+
"pan",
|
|
1068
|
+
"muted",
|
|
1069
|
+
"soloed",
|
|
1070
|
+
"src",
|
|
1071
|
+
"name",
|
|
1072
|
+
"kind",
|
|
1073
|
+
"renderMode",
|
|
1074
|
+
"spectrogramConfig"
|
|
1075
|
+
];
|
|
1065
1076
|
var DawTrackElement = class extends import_lit5.LitElement {
|
|
1066
1077
|
constructor() {
|
|
1067
1078
|
super(...arguments);
|
|
@@ -1192,24 +1203,14 @@ var DawTrackElement = class extends import_lit5.LitElement {
|
|
|
1192
1203
|
this._hasRendered = true;
|
|
1193
1204
|
return;
|
|
1194
1205
|
}
|
|
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) {
|
|
1206
|
+
const trackChanged = TRACK_PROPS.filter((p) => changed.has(p));
|
|
1207
|
+
if (trackChanged.length > 0) {
|
|
1208
|
+
const detail = { trackId: this.trackId, changed: trackChanged };
|
|
1208
1209
|
this.dispatchEvent(
|
|
1209
1210
|
new CustomEvent("daw-track-update", {
|
|
1210
1211
|
bubbles: true,
|
|
1211
1212
|
composed: true,
|
|
1212
|
-
detail
|
|
1213
|
+
detail
|
|
1213
1214
|
})
|
|
1214
1215
|
);
|
|
1215
1216
|
}
|
|
@@ -2279,7 +2280,7 @@ DawStopButtonElement = __decorateClass([
|
|
|
2279
2280
|
// src/elements/daw-editor.ts
|
|
2280
2281
|
var import_lit19 = require("lit");
|
|
2281
2282
|
var import_decorators16 = require("lit/decorators.js");
|
|
2282
|
-
var
|
|
2283
|
+
var import_core17 = require("@waveform-playlist/core");
|
|
2283
2284
|
|
|
2284
2285
|
// src/workers/peaksWorker.ts
|
|
2285
2286
|
var import_waveform_data = __toESM(require("waveform-data"));
|
|
@@ -3023,9 +3024,39 @@ DawRulerElement = __decorateClass([
|
|
|
3023
3024
|
(0, import_decorators13.customElement)("daw-ruler")
|
|
3024
3025
|
], DawRulerElement);
|
|
3025
3026
|
|
|
3027
|
+
// src/utils/track-mix.ts
|
|
3028
|
+
var DEFAULT_TRACK_MIX = Object.freeze({
|
|
3029
|
+
volume: 1,
|
|
3030
|
+
pan: 0,
|
|
3031
|
+
muted: false,
|
|
3032
|
+
soloed: false
|
|
3033
|
+
});
|
|
3034
|
+
function mixOfTrack(track) {
|
|
3035
|
+
return { volume: track.volume, pan: track.pan, muted: track.muted, soloed: track.soloed };
|
|
3036
|
+
}
|
|
3037
|
+
function mixOfElement(el) {
|
|
3038
|
+
return { volume: el.volume, pan: el.pan, muted: el.muted, soloed: el.soloed };
|
|
3039
|
+
}
|
|
3040
|
+
function pickMix(mix, names) {
|
|
3041
|
+
const named = new Set(names);
|
|
3042
|
+
return {
|
|
3043
|
+
...named.has("volume") && { volume: mix.volume },
|
|
3044
|
+
...named.has("pan") && { pan: mix.pan },
|
|
3045
|
+
...named.has("muted") && { muted: mix.muted },
|
|
3046
|
+
...named.has("soloed") && { soloed: mix.soloed }
|
|
3047
|
+
};
|
|
3048
|
+
}
|
|
3049
|
+
function withMix(track, mix) {
|
|
3050
|
+
return { ...track, ...mixOfElement(mix) };
|
|
3051
|
+
}
|
|
3052
|
+
function clampNumber(value, min, max) {
|
|
3053
|
+
return Math.max(min, Math.min(max, Number(value)));
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3026
3056
|
// src/elements/daw-track-controls.ts
|
|
3027
3057
|
var import_lit15 = require("lit");
|
|
3028
3058
|
var import_decorators14 = require("lit/decorators.js");
|
|
3059
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
3029
3060
|
var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
3030
3061
|
constructor() {
|
|
3031
3062
|
super(...arguments);
|
|
@@ -3034,19 +3065,30 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3034
3065
|
this.volume = 1;
|
|
3035
3066
|
this.pan = 0;
|
|
3036
3067
|
this.muted = false;
|
|
3068
|
+
this.recording = false;
|
|
3037
3069
|
this.soloed = false;
|
|
3038
3070
|
this.reorderable = false;
|
|
3039
3071
|
this.trackIndex = 0;
|
|
3040
3072
|
this.trackCount = 1;
|
|
3073
|
+
/**
|
|
3074
|
+
* One gesture per slider (#843): the `daw-track-control` events of one
|
|
3075
|
+
* drag, or of one key press (a held key included), carry the same
|
|
3076
|
+
* `gesture` id, and the editor makes them one undo step. Each gesture is
|
|
3077
|
+
* attached to its range input while the element is connected.
|
|
3078
|
+
*/
|
|
3079
|
+
this._volumeGesture = (0, import_core4.createMixerGesture)();
|
|
3080
|
+
this._panGesture = (0, import_core4.createMixerGesture)();
|
|
3081
|
+
this._detachGestures = [];
|
|
3041
3082
|
this._onVolumeInput = (e) => {
|
|
3042
3083
|
const value = Number(e.target.value);
|
|
3043
|
-
if (Number.isFinite(value)) this._dispatchControl("volume", value);
|
|
3084
|
+
if (Number.isFinite(value)) this._dispatchControl("volume", value, this._volumeGesture.id);
|
|
3044
3085
|
};
|
|
3045
3086
|
this._onPanInput = (e) => {
|
|
3046
3087
|
const value = Number(e.target.value);
|
|
3047
|
-
if (Number.isFinite(value)) this._dispatchControl("pan", value);
|
|
3088
|
+
if (Number.isFinite(value)) this._dispatchControl("pan", value, this._panGesture.id);
|
|
3048
3089
|
};
|
|
3049
3090
|
this._onMuteClick = () => {
|
|
3091
|
+
if (this.recording) return;
|
|
3050
3092
|
this._dispatchControl("muted", !this.muted);
|
|
3051
3093
|
};
|
|
3052
3094
|
this._onSoloClick = () => {
|
|
@@ -3080,7 +3122,29 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3080
3122
|
);
|
|
3081
3123
|
};
|
|
3082
3124
|
}
|
|
3125
|
+
connectedCallback() {
|
|
3126
|
+
super.connectedCallback();
|
|
3127
|
+
if (this.hasUpdated) this._attachGestures();
|
|
3128
|
+
}
|
|
3129
|
+
disconnectedCallback() {
|
|
3130
|
+
super.disconnectedCallback();
|
|
3131
|
+
this._detachAllGestures();
|
|
3132
|
+
}
|
|
3133
|
+
_attachGestures() {
|
|
3134
|
+
this._detachAllGestures();
|
|
3135
|
+
const volumeInput = this.shadowRoot?.querySelector(".vol-row input");
|
|
3136
|
+
const panInput = this.shadowRoot?.querySelector(".pan-row input");
|
|
3137
|
+
const detach = [];
|
|
3138
|
+
if (volumeInput) detach.push(this._volumeGesture.attach(volumeInput));
|
|
3139
|
+
if (panInput) detach.push(this._panGesture.attach(panInput));
|
|
3140
|
+
this._detachGestures = detach;
|
|
3141
|
+
}
|
|
3142
|
+
_detachAllGestures() {
|
|
3143
|
+
for (const detach of this._detachGestures) detach();
|
|
3144
|
+
this._detachGestures = [];
|
|
3145
|
+
}
|
|
3083
3146
|
firstUpdated() {
|
|
3147
|
+
this._attachGestures();
|
|
3084
3148
|
requestAnimationFrame(() => {
|
|
3085
3149
|
if (!this.isConnected) return;
|
|
3086
3150
|
const rect = this.getBoundingClientRect();
|
|
@@ -3091,13 +3155,15 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3091
3155
|
}
|
|
3092
3156
|
});
|
|
3093
3157
|
}
|
|
3094
|
-
|
|
3158
|
+
/** `gesture` for the sliders only: each mute or solo click is a step. */
|
|
3159
|
+
_dispatchControl(prop, value, gesture) {
|
|
3095
3160
|
if (!this.trackId) return;
|
|
3161
|
+
const detail = gesture === void 0 ? { trackId: this.trackId, prop, value } : { trackId: this.trackId, prop, value, gesture };
|
|
3096
3162
|
this.dispatchEvent(
|
|
3097
3163
|
new CustomEvent("daw-track-control", {
|
|
3098
3164
|
bubbles: true,
|
|
3099
3165
|
composed: true,
|
|
3100
|
-
detail
|
|
3166
|
+
detail
|
|
3101
3167
|
})
|
|
3102
3168
|
);
|
|
3103
3169
|
}
|
|
@@ -3134,6 +3200,7 @@ var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
|
3134
3200
|
<button
|
|
3135
3201
|
class="btn ${this.muted ? "muted-active" : ""}"
|
|
3136
3202
|
@click=${this._onMuteClick}
|
|
3203
|
+
?disabled=${this.recording}
|
|
3137
3204
|
title="Mute"
|
|
3138
3205
|
>
|
|
3139
3206
|
M
|
|
@@ -3375,6 +3442,9 @@ __decorateClass([
|
|
|
3375
3442
|
__decorateClass([
|
|
3376
3443
|
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3377
3444
|
], DawTrackControlsElement.prototype, "muted", 2);
|
|
3445
|
+
__decorateClass([
|
|
3446
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3447
|
+
], DawTrackControlsElement.prototype, "recording", 2);
|
|
3378
3448
|
__decorateClass([
|
|
3379
3449
|
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3380
3450
|
], DawTrackControlsElement.prototype, "soloed", 2);
|
|
@@ -3394,7 +3464,7 @@ DawTrackControlsElement = __decorateClass([
|
|
|
3394
3464
|
// src/elements/daw-grid.ts
|
|
3395
3465
|
var import_lit16 = require("lit");
|
|
3396
3466
|
var import_decorators15 = require("lit/decorators.js");
|
|
3397
|
-
var
|
|
3467
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
3398
3468
|
var MAX_CANVAS_WIDTH4 = 1e3;
|
|
3399
3469
|
var DawGridElement = class extends import_lit16.LitElement {
|
|
3400
3470
|
constructor() {
|
|
@@ -3471,7 +3541,7 @@ var DawGridElement = class extends import_lit16.LitElement {
|
|
|
3471
3541
|
ctx.resetTransform();
|
|
3472
3542
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
3473
3543
|
ctx.scale(dpr, dpr);
|
|
3474
|
-
if (pixelsPerQuarterNote * 4 >=
|
|
3544
|
+
if (pixelsPerQuarterNote * 4 >= import_core5.MIN_PIXELS_PER_UNIT) {
|
|
3475
3545
|
ctx.fillStyle = barHighlight;
|
|
3476
3546
|
const majorTicks = ticks.filter((t) => t.type === "major");
|
|
3477
3547
|
for (let i = 0; i < majorTicks.length; i++) {
|
|
@@ -3807,7 +3877,7 @@ function installCommand(...names) {
|
|
|
3807
3877
|
}
|
|
3808
3878
|
|
|
3809
3879
|
// src/controllers/recording-controller.ts
|
|
3810
|
-
var
|
|
3880
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
3811
3881
|
var RecordingController = class {
|
|
3812
3882
|
constructor(host) {
|
|
3813
3883
|
this._sessions = /* @__PURE__ */ new Map();
|
|
@@ -3901,7 +3971,7 @@ var RecordingController = class {
|
|
|
3901
3971
|
}
|
|
3902
3972
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
3903
3973
|
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
3904
|
-
const latencySamples = (0,
|
|
3974
|
+
const latencySamples = (0, import_core6.resolveRecordingOffsetSamples)({
|
|
3905
3975
|
overrideSeconds: options.latencyOffset,
|
|
3906
3976
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
3907
3977
|
lookAhead: 0,
|
|
@@ -3939,7 +4009,6 @@ var RecordingController = class {
|
|
|
3939
4009
|
isFirstMessage: true,
|
|
3940
4010
|
latencySamples,
|
|
3941
4011
|
clipName: options.clipName,
|
|
3942
|
-
armedPrevMuted: null,
|
|
3943
4012
|
wasOverdub: options.overdub ?? false,
|
|
3944
4013
|
_onTrackEnded: onTrackEnded,
|
|
3945
4014
|
_audioTrack: audioTrack,
|
|
@@ -3956,11 +4025,7 @@ var RecordingController = class {
|
|
|
3956
4025
|
if (audioTrack && onTrackEnded) {
|
|
3957
4026
|
audioTrack.addEventListener("ended", onTrackEnded);
|
|
3958
4027
|
}
|
|
3959
|
-
|
|
3960
|
-
if (engine) {
|
|
3961
|
-
session.armedPrevMuted = engine.getState().tracks.find((t) => t.id === trackId)?.muted ?? false;
|
|
3962
|
-
engine.setTrackMute(trackId, true);
|
|
3963
|
-
}
|
|
4028
|
+
this._host._engine?.setTrackRecording(trackId, true);
|
|
3964
4029
|
this._host.dispatchEvent(
|
|
3965
4030
|
new CustomEvent("daw-recording-start", {
|
|
3966
4031
|
bubbles: true,
|
|
@@ -4075,8 +4140,8 @@ var RecordingController = class {
|
|
|
4075
4140
|
return;
|
|
4076
4141
|
}
|
|
4077
4142
|
const stopCtx = this._host.audioContext;
|
|
4078
|
-
const channelData = session.chunks.map((chunkArr) => (0,
|
|
4079
|
-
const audioBuffer = (0,
|
|
4143
|
+
const channelData = session.chunks.map((chunkArr) => (0, import_core6.concatenateAudioData)(chunkArr));
|
|
4144
|
+
const audioBuffer = (0, import_core6.createAudioBuffer)(
|
|
4080
4145
|
stopCtx,
|
|
4081
4146
|
channelData,
|
|
4082
4147
|
session.captureSampleRate,
|
|
@@ -4106,7 +4171,7 @@ var RecordingController = class {
|
|
|
4106
4171
|
}
|
|
4107
4172
|
});
|
|
4108
4173
|
const notPrevented = this._host.dispatchEvent(event);
|
|
4109
|
-
this.
|
|
4174
|
+
this._clearTakeMute(session);
|
|
4110
4175
|
this._sessions.delete(id);
|
|
4111
4176
|
this._host.requestUpdate();
|
|
4112
4177
|
if (notPrevented) {
|
|
@@ -4170,7 +4235,7 @@ var RecordingController = class {
|
|
|
4170
4235
|
for (let ch = 0; ch < session.channelCount; ch++) {
|
|
4171
4236
|
if (!channels[ch]) continue;
|
|
4172
4237
|
const oldPeakCount = Math.floor(session.peaks[ch].length / 2);
|
|
4173
|
-
session.peaks[ch] = (0,
|
|
4238
|
+
session.peaks[ch] = (0, import_core6.appendPeaks)(
|
|
4174
4239
|
session.peaks[ch],
|
|
4175
4240
|
channels[ch],
|
|
4176
4241
|
// Render-space scale — in beats mode this differs from
|
|
@@ -4234,22 +4299,23 @@ var RecordingController = class {
|
|
|
4234
4299
|
);
|
|
4235
4300
|
}
|
|
4236
4301
|
/** Shared teardown for finalize paths that end without a take (no data
|
|
4237
|
-
* captured / too short after latency compensation):
|
|
4238
|
-
*
|
|
4239
|
-
*
|
|
4302
|
+
* captured / too short after latency compensation): clear the take's mute, drop
|
|
4303
|
+
* the session, and notify via daw-recording-error so record buttons reset
|
|
4304
|
+
* their state. */
|
|
4240
4305
|
_abandonFinalize(id, session, warnMessage, errorMessage = warnMessage) {
|
|
4241
4306
|
console.warn("[dawcore] RecordingController: " + warnMessage);
|
|
4242
|
-
this.
|
|
4307
|
+
this._clearTakeMute(session);
|
|
4243
4308
|
this._sessions.delete(id);
|
|
4244
4309
|
this._host.requestUpdate();
|
|
4245
4310
|
this._dispatchRecordingError(id, new Error(errorMessage));
|
|
4246
4311
|
}
|
|
4247
|
-
/**
|
|
4248
|
-
*
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4312
|
+
/** Clear the take's mute on the session's track, by its id. Each teardown
|
|
4313
|
+
* path calls this once, right before it drops the session from the map, so
|
|
4314
|
+
* a later path never reaches the same session; clearing an id that is not
|
|
4315
|
+
* set is a no-op in the engine. Another session's mute on another track is
|
|
4316
|
+
* left alone. */
|
|
4317
|
+
_clearTakeMute(session) {
|
|
4318
|
+
this._host._engine?.setTrackRecording(session.trackId, false);
|
|
4253
4319
|
}
|
|
4254
4320
|
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
4255
4321
|
* disposal paths that would otherwise discard the session silently. The
|
|
@@ -4258,7 +4324,7 @@ var RecordingController = class {
|
|
|
4258
4324
|
const session = this._sessions.get(trackId);
|
|
4259
4325
|
if (!session) return;
|
|
4260
4326
|
try {
|
|
4261
|
-
this.
|
|
4327
|
+
this._clearTakeMute(session);
|
|
4262
4328
|
this._removeTrackEndedListener(session);
|
|
4263
4329
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
4264
4330
|
session.source.disconnect();
|
|
@@ -4465,7 +4531,7 @@ var AnnotationController = class {
|
|
|
4465
4531
|
|
|
4466
4532
|
// src/controllers/spectrogram-controller.ts
|
|
4467
4533
|
var import_spectrogram = require("@dawcore/spectrogram");
|
|
4468
|
-
var
|
|
4534
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
4469
4535
|
var SpectrogramController = class {
|
|
4470
4536
|
constructor(host, workerFactory) {
|
|
4471
4537
|
this.orchestrator = null;
|
|
@@ -4574,18 +4640,18 @@ var SpectrogramController = class {
|
|
|
4574
4640
|
track = c;
|
|
4575
4641
|
break;
|
|
4576
4642
|
}
|
|
4577
|
-
return { ...
|
|
4643
|
+
return { ...import_core7.SPECTROGRAM_DEFAULTS, ...this.editorConfig ?? {}, ...track ?? {} };
|
|
4578
4644
|
}
|
|
4579
4645
|
mergedColorMap() {
|
|
4580
4646
|
for (const c of this.trackColorMaps.values()) {
|
|
4581
|
-
return c ??
|
|
4647
|
+
return c ?? import_core7.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
4582
4648
|
}
|
|
4583
|
-
return this.editorColorMap ??
|
|
4649
|
+
return this.editorColorMap ?? import_core7.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
4584
4650
|
}
|
|
4585
4651
|
};
|
|
4586
4652
|
|
|
4587
4653
|
// src/interactions/pointer-handler.ts
|
|
4588
|
-
var
|
|
4654
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
4589
4655
|
|
|
4590
4656
|
// src/interactions/constants.ts
|
|
4591
4657
|
var DRAG_THRESHOLD = 3;
|
|
@@ -4742,10 +4808,10 @@ var PointerHandler = class {
|
|
|
4742
4808
|
const h = this._host;
|
|
4743
4809
|
if (h.scaleMode === "beats") {
|
|
4744
4810
|
let tick = px * h.ticksPerPixel;
|
|
4745
|
-
tick = (0,
|
|
4811
|
+
tick = (0, import_core8.snapTickToGrid)(tick, h.snapTo, h._meterEntries, h.ppqn);
|
|
4746
4812
|
return h._ticksToSeconds(tick);
|
|
4747
4813
|
}
|
|
4748
|
-
return (0,
|
|
4814
|
+
return (0, import_core8.pixelsToSeconds)(px, h.samplesPerPixel, h.effectiveSampleRate);
|
|
4749
4815
|
}
|
|
4750
4816
|
_timeToPx(time) {
|
|
4751
4817
|
const h = this._host;
|
|
@@ -4864,7 +4930,7 @@ var PointerHandler = class {
|
|
|
4864
4930
|
};
|
|
4865
4931
|
|
|
4866
4932
|
// src/interactions/clip-pointer-handler.ts
|
|
4867
|
-
var
|
|
4933
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
4868
4934
|
var ClipPointerHandler = class {
|
|
4869
4935
|
constructor(host) {
|
|
4870
4936
|
this._mode = null;
|
|
@@ -4898,7 +4964,7 @@ var ClipPointerHandler = class {
|
|
|
4898
4964
|
const anchorTick = h._secondsToTicks(anchorSeconds);
|
|
4899
4965
|
const deltaTicks = totalDeltaPx * h.ticksPerPixel;
|
|
4900
4966
|
const targetTick = anchorTick + deltaTicks;
|
|
4901
|
-
const snappedTick = h.snapTo !== "off" ? (0,
|
|
4967
|
+
const snappedTick = h.snapTo !== "off" ? (0, import_core9.snapTickToGrid)(targetTick, h.snapTo, h._meterEntries, h.ppqn) : targetTick;
|
|
4902
4968
|
const snappedSeconds = h._ticksToSeconds(snappedTick);
|
|
4903
4969
|
const snappedSample = Math.round(snappedSeconds * h.effectiveSampleRate);
|
|
4904
4970
|
return snappedSample - anchorSample;
|
|
@@ -5183,8 +5249,8 @@ var ClipPointerHandler = class {
|
|
|
5183
5249
|
};
|
|
5184
5250
|
|
|
5185
5251
|
// src/interactions/annotation-drag.ts
|
|
5186
|
-
var import_core9 = require("@waveform-playlist/core");
|
|
5187
5252
|
var import_core10 = require("@waveform-playlist/core");
|
|
5253
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
5188
5254
|
var AnnotationDragHandler = class {
|
|
5189
5255
|
constructor(host) {
|
|
5190
5256
|
this._drag = null;
|
|
@@ -5246,7 +5312,7 @@ var AnnotationDragHandler = class {
|
|
|
5246
5312
|
) - drag.edgeTime;
|
|
5247
5313
|
let newTick = drag.edgeTime + deltaTicks;
|
|
5248
5314
|
if (this._host.scaleMode === "beats" && this._host.snapTo !== "off") {
|
|
5249
|
-
newTick = (0,
|
|
5315
|
+
newTick = (0, import_core10.snapTickToGrid)(
|
|
5250
5316
|
newTick,
|
|
5251
5317
|
this._host.snapTo,
|
|
5252
5318
|
this._host._meterEntries,
|
|
@@ -5254,7 +5320,7 @@ var AnnotationDragHandler = class {
|
|
|
5254
5320
|
);
|
|
5255
5321
|
}
|
|
5256
5322
|
const clamp = this._host._annotationClampDuration;
|
|
5257
|
-
const updated2 = (0,
|
|
5323
|
+
const updated2 = (0, import_core10.updateAnnotationBoundaries)(
|
|
5258
5324
|
{
|
|
5259
5325
|
annotationIndex: index,
|
|
5260
5326
|
newTime: newTick,
|
|
@@ -5264,15 +5330,15 @@ var AnnotationDragHandler = class {
|
|
|
5264
5330
|
linkEndpoints: drag.track.linkEndpoints
|
|
5265
5331
|
},
|
|
5266
5332
|
{
|
|
5267
|
-
linkThreshold:
|
|
5268
|
-
minDuration: (0,
|
|
5333
|
+
linkThreshold: import_core11.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
5334
|
+
minDuration: (0, import_core11.annotationMinDurationTicks)(this._host.ppqn)
|
|
5269
5335
|
}
|
|
5270
5336
|
);
|
|
5271
5337
|
applyTickBoundaryResults(elements, updated2, (t) => this._host._ticksToSeconds(t));
|
|
5272
5338
|
return;
|
|
5273
5339
|
}
|
|
5274
5340
|
const deltaSeconds = deltaPx * this._host._renderSpp / this._host.effectiveSampleRate;
|
|
5275
|
-
const updated = (0,
|
|
5341
|
+
const updated = (0, import_core10.updateAnnotationBoundaries)({
|
|
5276
5342
|
annotationIndex: index,
|
|
5277
5343
|
newTime: drag.edgeTime + deltaSeconds,
|
|
5278
5344
|
isDraggingStart: drag.edge === "start",
|
|
@@ -5692,7 +5758,7 @@ function stringifyReason(reason) {
|
|
|
5692
5758
|
}
|
|
5693
5759
|
|
|
5694
5760
|
// src/interactions/recording-clip.ts
|
|
5695
|
-
var
|
|
5761
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
5696
5762
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
5697
5763
|
let trimmedBuf = buf;
|
|
5698
5764
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -5707,7 +5773,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5707
5773
|
}
|
|
5708
5774
|
trimmedBuf = trimmed;
|
|
5709
5775
|
}
|
|
5710
|
-
const clip = (0,
|
|
5776
|
+
const clip = (0, import_core12.createClip)({
|
|
5711
5777
|
audioBuffer: trimmedBuf,
|
|
5712
5778
|
startSample,
|
|
5713
5779
|
durationSamples: durSamples,
|
|
@@ -5734,7 +5800,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5734
5800
|
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
5735
5801
|
// startSample + durSamples) — carve overlapped content out of the
|
|
5736
5802
|
// existing clips before inserting (parity with the React provider).
|
|
5737
|
-
clips: [...(0,
|
|
5803
|
+
clips: [...(0, import_core12.carveClipRange)(t.clips, startSample, startSample + durSamples), clip]
|
|
5738
5804
|
});
|
|
5739
5805
|
const desc = host._tracks.get(trackId);
|
|
5740
5806
|
if (desc) {
|
|
@@ -6176,10 +6242,10 @@ function loadFaustModule(feature) {
|
|
|
6176
6242
|
}
|
|
6177
6243
|
|
|
6178
6244
|
// src/effects/effects-manager.ts
|
|
6179
|
-
var
|
|
6245
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
6180
6246
|
|
|
6181
6247
|
// src/effects/effect-registry.ts
|
|
6182
|
-
var
|
|
6248
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
6183
6249
|
var MAX_DELAY_SECONDS = 10;
|
|
6184
6250
|
function singleNode(node, applyParams) {
|
|
6185
6251
|
return { input: node, output: node, applyParams };
|
|
@@ -6255,8 +6321,8 @@ function biquadDefinition(spec) {
|
|
|
6255
6321
|
};
|
|
6256
6322
|
}
|
|
6257
6323
|
function registerBuiltIn(type, definition) {
|
|
6258
|
-
if (!(0,
|
|
6259
|
-
(0,
|
|
6324
|
+
if (!(0, import_core13.getEffectDefinitions)().has(type)) {
|
|
6325
|
+
(0, import_core13.registerEffect)(type, { ...definition, builtIn: true });
|
|
6260
6326
|
}
|
|
6261
6327
|
}
|
|
6262
6328
|
function registerBuiltIns() {
|
|
@@ -6411,7 +6477,7 @@ var EffectsManager = class {
|
|
|
6411
6477
|
/** Run a registered effect's async `prepare` hook on the adapter's
|
|
6412
6478
|
* context, so the synchronous addEffect() can create it. */
|
|
6413
6479
|
async prepareEffect(type) {
|
|
6414
|
-
await (0,
|
|
6480
|
+
await (0, import_core14.prepareEffect)(type, this._requireWiring().audioContext);
|
|
6415
6481
|
}
|
|
6416
6482
|
// --- Track chains ---
|
|
6417
6483
|
addTrackEffect(trackId, target, type, params) {
|
|
@@ -6616,7 +6682,7 @@ var EffectsManager = class {
|
|
|
6616
6682
|
this._runOp(chain, target, "setParams", effectId, { [paramId]: value });
|
|
6617
6683
|
};
|
|
6618
6684
|
if (entry.kind === "native") {
|
|
6619
|
-
const definition = (0,
|
|
6685
|
+
const definition = (0, import_core14.getEffectDefinitions)().get(entry.type);
|
|
6620
6686
|
if (!definition) {
|
|
6621
6687
|
throw new Error(
|
|
6622
6688
|
PREFIX2 + 'openEffectGui: no registry definition for effect type "' + entry.type + '"'
|
|
@@ -6675,7 +6741,7 @@ var EffectsManager = class {
|
|
|
6675
6741
|
}
|
|
6676
6742
|
_addToChain(chain, target, type, params) {
|
|
6677
6743
|
const audioContext = this._requireWiring().audioContext;
|
|
6678
|
-
const created = (0,
|
|
6744
|
+
const created = (0, import_core14.createEffectInstance)(type, audioContext, params);
|
|
6679
6745
|
const effectId = chain.add({
|
|
6680
6746
|
kind: "native",
|
|
6681
6747
|
type,
|
|
@@ -6847,8 +6913,8 @@ var EffectsManager = class {
|
|
|
6847
6913
|
if (entry.kind === "native") {
|
|
6848
6914
|
try {
|
|
6849
6915
|
const liveContext = this._requireWiring().audioContext;
|
|
6850
|
-
if ((0,
|
|
6851
|
-
await (0,
|
|
6916
|
+
if ((0, import_core14.needsPrepare)(entry.type, liveContext)) {
|
|
6917
|
+
await (0, import_core14.ensureEffectPrepared)(entry.type, liveContext);
|
|
6852
6918
|
if (superseded() || chain.disposed) return;
|
|
6853
6919
|
}
|
|
6854
6920
|
const id = this._addToChain(chain, target, entry.type, entry.params);
|
|
@@ -7023,8 +7089,8 @@ function toWamParameterMap(params) {
|
|
|
7023
7089
|
}
|
|
7024
7090
|
|
|
7025
7091
|
// src/interactions/export-audio.ts
|
|
7026
|
-
var import_core14 = require("@waveform-playlist/core");
|
|
7027
7092
|
var import_core15 = require("@waveform-playlist/core");
|
|
7093
|
+
var import_core16 = require("@waveform-playlist/core");
|
|
7028
7094
|
var PREFIX3 = "[waveform-playlist] ";
|
|
7029
7095
|
async function exportAudioImpl(host, options = {}) {
|
|
7030
7096
|
const sampleRate = options.sampleRate ?? host.effectiveSampleRate;
|
|
@@ -7059,7 +7125,7 @@ async function exportAudioImpl(host, options = {}) {
|
|
|
7059
7125
|
cleanups.push(chain.dispose);
|
|
7060
7126
|
const volume = ctx.createGain();
|
|
7061
7127
|
volume.gain.value = track.volume;
|
|
7062
|
-
const panStage = (0,
|
|
7128
|
+
const panStage = (0, import_core15.createPanStage)(ctx, track.pan, (0, import_core15.trackChannelCount)(track));
|
|
7063
7129
|
cleanups.push(panStage.dispose);
|
|
7064
7130
|
chain.output.connect(volume);
|
|
7065
7131
|
volume.connect(panStage.input);
|
|
@@ -7141,12 +7207,12 @@ async function buildOfflineChain(ctx, entries) {
|
|
|
7141
7207
|
continue;
|
|
7142
7208
|
}
|
|
7143
7209
|
if (entry.kind === "native") {
|
|
7144
|
-
const definition = (0,
|
|
7210
|
+
const definition = (0, import_core16.getEffectDefinitions)().get(entry.type);
|
|
7145
7211
|
if (entry.bypassed && definition && !definition.wetParam) {
|
|
7146
7212
|
continue;
|
|
7147
7213
|
}
|
|
7148
|
-
await (0,
|
|
7149
|
-
const created = (0,
|
|
7214
|
+
await (0, import_core16.ensureEffectPrepared)(entry.type, ctx);
|
|
7215
|
+
const created = (0, import_core16.createEffectInstance)(entry.type, ctx, entry.params);
|
|
7150
7216
|
if (entry.bypassed && created.wetParam) {
|
|
7151
7217
|
created.instance.applyParams({ [created.wetParam]: 0 });
|
|
7152
7218
|
}
|
|
@@ -7450,6 +7516,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7450
7516
|
/** Resolved sample rate — falls back to sampleRate property until first audio decode. */
|
|
7451
7517
|
this._resolvedSampleRate = null;
|
|
7452
7518
|
this._tracks = /* @__PURE__ */ new Map();
|
|
7519
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
7453
7520
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
7454
7521
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
7455
7522
|
this._isPlaying = false;
|
|
@@ -7572,6 +7639,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7572
7639
|
}
|
|
7573
7640
|
const descriptor = this._readTrackDescriptor(trackEl);
|
|
7574
7641
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7642
|
+
this._setSeedMix(trackId, mixOfElement(trackEl));
|
|
7575
7643
|
this._trackElements.set(trackId, trackEl);
|
|
7576
7644
|
this._loadTrack(trackId, descriptor);
|
|
7577
7645
|
};
|
|
@@ -7597,15 +7665,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7597
7665
|
});
|
|
7598
7666
|
}
|
|
7599
7667
|
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
|
-
}
|
|
7668
|
+
const changed = Array.isArray(e.detail.changed) ? e.detail.changed : [];
|
|
7669
|
+
this._writeMixFields(trackId, pickMix(mixOfElement(trackEl), changed));
|
|
7609
7670
|
if (oldDescriptor?.src !== descriptor.src) {
|
|
7610
7671
|
this._loadTrack(trackId, descriptor);
|
|
7611
7672
|
}
|
|
@@ -7631,7 +7692,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7631
7692
|
}
|
|
7632
7693
|
};
|
|
7633
7694
|
this._onTrackControl = (e) => {
|
|
7634
|
-
const { trackId, prop, value } = e.detail ?? {};
|
|
7695
|
+
const { trackId, prop, value, gesture } = e.detail ?? {};
|
|
7635
7696
|
if (!trackId || !prop || !DawEditorElement._CONTROL_PROPS.has(prop)) return;
|
|
7636
7697
|
if (this._selectedTrackId !== trackId) {
|
|
7637
7698
|
this._setSelectedTrackId(trackId);
|
|
@@ -7646,18 +7707,12 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
7646
7707
|
})
|
|
7647
7708
|
);
|
|
7648
7709
|
}
|
|
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
|
-
}
|
|
7710
|
+
if (this._tracks.has(trackId)) {
|
|
7711
|
+
const options = typeof gesture === "string" ? { gesture } : void 0;
|
|
7712
|
+
if (prop === "volume") this._writeMix(trackId, "volume", clampNumber(value, 0, 1), options);
|
|
7713
|
+
if (prop === "pan") this._writeMix(trackId, "pan", clampNumber(value, -1, 1), options);
|
|
7714
|
+
if (prop === "muted") this._writeMix(trackId, "muted", Boolean(value), options);
|
|
7715
|
+
if (prop === "soloed") this._writeMix(trackId, "soloed", Boolean(value), options);
|
|
7661
7716
|
}
|
|
7662
7717
|
};
|
|
7663
7718
|
this._onTrackRemoveRequest = (e) => {
|
|
@@ -8278,9 +8333,69 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8278
8333
|
get tracks() {
|
|
8279
8334
|
return [...this._tracks.entries()].map(([trackId, descriptor]) => ({
|
|
8280
8335
|
trackId,
|
|
8281
|
-
...descriptor
|
|
8336
|
+
...descriptor,
|
|
8337
|
+
...this._mixOf(trackId)
|
|
8282
8338
|
}));
|
|
8283
8339
|
}
|
|
8340
|
+
/**
|
|
8341
|
+
* A track's mix, from its one owner: the arrangement (through
|
|
8342
|
+
* `_engineTracks`, which follows `mixerVersion`) for a track the engine
|
|
8343
|
+
* holds, the seed for one still on its way in (#843).
|
|
8344
|
+
*/
|
|
8345
|
+
_mixOf(trackId) {
|
|
8346
|
+
const seed = this._seedMix.get(trackId);
|
|
8347
|
+
if (seed) return seed;
|
|
8348
|
+
const track = this._engineTracks.get(trackId);
|
|
8349
|
+
return track ? mixOfTrack(track) : DEFAULT_TRACK_MIX;
|
|
8350
|
+
}
|
|
8351
|
+
/** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
|
|
8352
|
+
_setSeedMix(trackId, mix) {
|
|
8353
|
+
this._seedMix = new Map(this._seedMix).set(trackId, mix);
|
|
8354
|
+
}
|
|
8355
|
+
_deleteSeedMix(trackIds) {
|
|
8356
|
+
let next = null;
|
|
8357
|
+
for (const id of trackIds) {
|
|
8358
|
+
if (!this._seedMix.has(id)) continue;
|
|
8359
|
+
next ?? (next = new Map(this._seedMix));
|
|
8360
|
+
next.delete(id);
|
|
8361
|
+
}
|
|
8362
|
+
if (next) this._seedMix = next;
|
|
8363
|
+
}
|
|
8364
|
+
/**
|
|
8365
|
+
* Change one mixer field of a track: the seed while the track is loading
|
|
8366
|
+
* (not an undo step, nothing sent), else the engine's setter with
|
|
8367
|
+
* `options` (an undo step; changes with one `gesture` id are one step).
|
|
8368
|
+
*/
|
|
8369
|
+
_writeMix(trackId, field, value, options) {
|
|
8370
|
+
const seed = this._seedMix.get(trackId);
|
|
8371
|
+
if (seed) {
|
|
8372
|
+
if (seed[field] !== value) this._setSeedMix(trackId, { ...seed, [field]: value });
|
|
8373
|
+
return;
|
|
8374
|
+
}
|
|
8375
|
+
if (!this._engine) return;
|
|
8376
|
+
if (field === "volume") this._engine.setTrackVolume(trackId, value, options);
|
|
8377
|
+
else if (field === "pan") this._engine.setTrackPan(trackId, value, options);
|
|
8378
|
+
else if (field === "muted") this._engine.setTrackMute(trackId, value, options);
|
|
8379
|
+
else this._engine.setTrackSolo(trackId, value, options);
|
|
8380
|
+
}
|
|
8381
|
+
/**
|
|
8382
|
+
* Change the given mixer fields of a track as ONE undo step (#843): all
|
|
8383
|
+
* of them carry one fresh gesture id. A field left out is not sent.
|
|
8384
|
+
*/
|
|
8385
|
+
_writeMixFields(trackId, mix) {
|
|
8386
|
+
const options = { gesture: (0, import_core17.createMixerGesture)().id };
|
|
8387
|
+
if (mix.volume !== void 0) this._writeMix(trackId, "volume", mix.volume, options);
|
|
8388
|
+
if (mix.pan !== void 0) this._writeMix(trackId, "pan", mix.pan, options);
|
|
8389
|
+
if (mix.muted !== void 0) this._writeMix(trackId, "muted", mix.muted, options);
|
|
8390
|
+
if (mix.soloed !== void 0) this._writeMix(trackId, "soloed", mix.soloed, options);
|
|
8391
|
+
}
|
|
8392
|
+
/** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
|
|
8393
|
+
_tracksForEngine() {
|
|
8394
|
+
return this._getOrderedTracks().map(([trackId, track]) => {
|
|
8395
|
+
const seed = this._seedMix.get(trackId);
|
|
8396
|
+
return seed ? withMix(track, seed) : track;
|
|
8397
|
+
});
|
|
8398
|
+
}
|
|
8284
8399
|
get selectedTrackId() {
|
|
8285
8400
|
return this._selectedTrackId;
|
|
8286
8401
|
}
|
|
@@ -8404,6 +8519,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8404
8519
|
this._adapterConsumedByDispose = true;
|
|
8405
8520
|
}
|
|
8406
8521
|
this._tracks = /* @__PURE__ */ new Map();
|
|
8522
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
8407
8523
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
8408
8524
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
8409
8525
|
this._loadingTracks.clear();
|
|
@@ -8477,6 +8593,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8477
8593
|
const nextTracks = new Map(this._tracks);
|
|
8478
8594
|
nextTracks.delete(trackId);
|
|
8479
8595
|
this._tracks = nextTracks;
|
|
8596
|
+
this._deleteSeedMix([trackId]);
|
|
8480
8597
|
const nextEngine = new Map(this._engineTracks);
|
|
8481
8598
|
nextEngine.delete(trackId);
|
|
8482
8599
|
this._engineTracks = nextEngine;
|
|
@@ -8538,12 +8655,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8538
8655
|
next.set(track.id, {
|
|
8539
8656
|
name: track.name ?? "",
|
|
8540
8657
|
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"),
|
|
8658
|
+
kind: (0, import_core17.trackKind)(track),
|
|
8659
|
+
renderMode: trackDescriptorRenderMode((0, import_core17.trackKind)(track), "waveform"),
|
|
8547
8660
|
clips: []
|
|
8548
8661
|
});
|
|
8549
8662
|
}
|
|
@@ -8700,7 +8813,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8700
8813
|
let clip;
|
|
8701
8814
|
if (waveformData) {
|
|
8702
8815
|
const wdRate = waveformData.sample_rate;
|
|
8703
|
-
clip = (0,
|
|
8816
|
+
clip = (0, import_core17.createClip)({
|
|
8704
8817
|
audioBuffer,
|
|
8705
8818
|
waveformData,
|
|
8706
8819
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
@@ -8713,7 +8826,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8713
8826
|
});
|
|
8714
8827
|
this._peakPipeline.cacheWaveformData(audioBuffer, waveformData);
|
|
8715
8828
|
} else {
|
|
8716
|
-
clip = (0,
|
|
8829
|
+
clip = (0, import_core17.createClipFromSeconds)({
|
|
8717
8830
|
audioBuffer,
|
|
8718
8831
|
startTime: clipDesc.start,
|
|
8719
8832
|
duration: clipDesc.duration || audioBuffer.duration,
|
|
@@ -8792,7 +8905,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8792
8905
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
8793
8906
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipDesc.duration, 1) * sr);
|
|
8794
8907
|
const requestedDurationSamples = clipDesc.duration > 0 ? Math.round(clipDesc.duration * sr) : sourceDurationSamples;
|
|
8795
|
-
const clip = (0,
|
|
8908
|
+
const clip = (0, import_core17.createClip)({
|
|
8796
8909
|
startSample: Math.round(clipDesc.start * sr),
|
|
8797
8910
|
durationSamples: requestedDurationSamples,
|
|
8798
8911
|
offsetSamples: Math.round(clipDesc.offset * sr),
|
|
@@ -8828,8 +8941,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8828
8941
|
_commitTrackChange(trackId, updatedTrack) {
|
|
8829
8942
|
this._recomputeDuration();
|
|
8830
8943
|
if (this._engine?.updateTrack) this._engine.updateTrack(trackId, updatedTrack);
|
|
8831
|
-
else if (this._engine)
|
|
8832
|
-
this._engine.setTracks(this._getOrderedTracks().map(([, track]) => track));
|
|
8944
|
+
else if (this._engine) this._engine.setTracks(this._tracksForEngine());
|
|
8833
8945
|
}
|
|
8834
8946
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
8835
8947
|
const t = this._engineTracks.get(trackId);
|
|
@@ -8848,7 +8960,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8848
8960
|
const sr = oldClip.sampleRate ?? this.effectiveSampleRate;
|
|
8849
8961
|
const isMidiNow = clipEl.midiNotes != null && !clipEl.src;
|
|
8850
8962
|
const wasMidi = oldClip.midiNotes != null;
|
|
8851
|
-
if (isMidiNow && (0,
|
|
8963
|
+
if (isMidiNow && (0, import_core17.trackKind)(t) !== "midi") {
|
|
8852
8964
|
const kindError = this._clipKindError(t.name, "audio", true, clipEl.name || clipId);
|
|
8853
8965
|
console.warn("[dawcore] _applyClipUpdate: " + kindError?.message);
|
|
8854
8966
|
this.dispatchEvent(
|
|
@@ -8991,10 +9103,6 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8991
9103
|
return {
|
|
8992
9104
|
name: trackEl.name || "Untitled",
|
|
8993
9105
|
src: trackEl.src,
|
|
8994
|
-
volume: trackEl.volume,
|
|
8995
|
-
pan: trackEl.pan,
|
|
8996
|
-
muted: trackEl.muted,
|
|
8997
|
-
soloed: trackEl.soloed,
|
|
8998
9106
|
kind: trackEl.kind,
|
|
8999
9107
|
renderMode: trackDescriptorRenderMode(trackEl.kind, trackEl.renderMode),
|
|
9000
9108
|
clips
|
|
@@ -9053,7 +9161,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9053
9161
|
const waveformData = await waveformDataPromise;
|
|
9054
9162
|
if (waveformData) {
|
|
9055
9163
|
const wdRate = waveformData.sample_rate;
|
|
9056
|
-
const clip2 = (0,
|
|
9164
|
+
const clip2 = (0, import_core17.createClip)({
|
|
9057
9165
|
waveformData,
|
|
9058
9166
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
9059
9167
|
durationSamples: Math.round((clipDesc.duration || waveformData.duration) * wdRate),
|
|
@@ -9079,14 +9187,11 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9079
9187
|
this._peaksData = new Map(this._peaksData).set(clip2.id, peakData);
|
|
9080
9188
|
this._raiseZoomFloor(waveformData.scale);
|
|
9081
9189
|
if (this._tracks.has(trackId)) {
|
|
9082
|
-
const previewTrack = (0,
|
|
9190
|
+
const previewTrack = (0, import_core17.createTrack)({
|
|
9083
9191
|
name: descriptor.name,
|
|
9084
9192
|
kind: descriptor.kind,
|
|
9085
9193
|
clips: [clip2],
|
|
9086
|
-
|
|
9087
|
-
pan: descriptor.pan,
|
|
9088
|
-
muted: descriptor.muted,
|
|
9089
|
-
soloed: descriptor.soloed
|
|
9194
|
+
...this._mixOf(trackId)
|
|
9090
9195
|
});
|
|
9091
9196
|
previewTrack.id = trackId;
|
|
9092
9197
|
this._engineTracks = new Map(this._engineTracks).set(trackId, previewTrack);
|
|
@@ -9157,14 +9262,11 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9157
9262
|
trackWasRemoved ? "removed" : "disconnected"
|
|
9158
9263
|
);
|
|
9159
9264
|
}
|
|
9160
|
-
const track = (0,
|
|
9265
|
+
const track = (0, import_core17.createTrack)({
|
|
9161
9266
|
name: descriptor.name,
|
|
9162
9267
|
kind: descriptor.kind,
|
|
9163
9268
|
clips,
|
|
9164
|
-
|
|
9165
|
-
pan: descriptor.pan,
|
|
9166
|
-
muted: descriptor.muted,
|
|
9167
|
-
soloed: descriptor.soloed
|
|
9269
|
+
...this._mixOf(trackId)
|
|
9168
9270
|
});
|
|
9169
9271
|
const requestedClips = descriptor.clips.filter((c) => c.src).length + refusedMidiClips;
|
|
9170
9272
|
if (requestedClips > 0 && clips.length === 0) {
|
|
@@ -9179,7 +9281,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9179
9281
|
this._maybeRegisterSpectrogramClipAudio(trackId, c);
|
|
9180
9282
|
}
|
|
9181
9283
|
const engine = await this._ensureEngine();
|
|
9182
|
-
engine.setTracks(this.
|
|
9284
|
+
engine.setTracks(this._tracksForEngine());
|
|
9183
9285
|
this.dispatchEvent(
|
|
9184
9286
|
new CustomEvent("daw-track-ready", {
|
|
9185
9287
|
bubbles: true,
|
|
@@ -9304,6 +9406,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9304
9406
|
nextTracks.set(track.id, track);
|
|
9305
9407
|
}
|
|
9306
9408
|
this._engineTracks = nextTracks;
|
|
9409
|
+
this._deleteSeedMix(nextTracks.keys());
|
|
9307
9410
|
this._reconcileDescriptorsWithEngineTracks(engineState.tracks);
|
|
9308
9411
|
}
|
|
9309
9412
|
if (structuralChange) {
|
|
@@ -9311,7 +9414,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9311
9414
|
this._syncDomToEngineOrder(engineState.tracks);
|
|
9312
9415
|
}
|
|
9313
9416
|
this._effectsManager?.rewireTrackChains();
|
|
9314
|
-
const audioTracks = engineState.tracks.filter((t) => (0,
|
|
9417
|
+
const audioTracks = engineState.tracks.filter((t) => (0, import_core17.trackKind)(t) !== "midi");
|
|
9315
9418
|
syncPeaksForChangedClips(this, audioTracks);
|
|
9316
9419
|
}
|
|
9317
9420
|
if (engineState.bpm !== this._lastAnnotationBpm) {
|
|
@@ -9477,14 +9580,22 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9477
9580
|
}
|
|
9478
9581
|
}
|
|
9479
9582
|
/**
|
|
9480
|
-
* Update reflected attributes on a track.
|
|
9481
|
-
*
|
|
9482
|
-
*
|
|
9483
|
-
*
|
|
9583
|
+
* Update reflected attributes on a track. The mixer fields go to their
|
|
9584
|
+
* owner as one undo step (#843): the engine, or while the track is loading
|
|
9585
|
+
* the values it will enter with (not a step). For DOM-element tracks the
|
|
9586
|
+
* changes are also written to the `<daw-track>` element; for tracks
|
|
9587
|
+
* without a DOM element (file drops) the descriptor is updated in place.
|
|
9484
9588
|
*/
|
|
9485
9589
|
updateTrack(trackId, partial) {
|
|
9590
|
+
const mix = {
|
|
9591
|
+
volume: partial.volume,
|
|
9592
|
+
pan: partial.pan,
|
|
9593
|
+
muted: partial.muted,
|
|
9594
|
+
soloed: partial.soloed
|
|
9595
|
+
};
|
|
9486
9596
|
const trackEl = this._trackElements.get(trackId);
|
|
9487
9597
|
if (trackEl) {
|
|
9598
|
+
this._writeMixFields(trackId, mix);
|
|
9488
9599
|
if (partial.name !== void 0) trackEl.setAttribute("name", partial.name);
|
|
9489
9600
|
if (partial.volume !== void 0) trackEl.volume = partial.volume;
|
|
9490
9601
|
if (partial.pan !== void 0) trackEl.pan = partial.pan;
|
|
@@ -9511,21 +9622,12 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9511
9622
|
const newDesc = {
|
|
9512
9623
|
...oldDesc,
|
|
9513
9624
|
...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
9625
|
...normalizedRenderMode !== void 0 && {
|
|
9519
9626
|
renderMode: trackDescriptorRenderMode(oldDesc.kind, normalizedRenderMode)
|
|
9520
9627
|
}
|
|
9521
9628
|
};
|
|
9522
9629
|
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
|
-
}
|
|
9630
|
+
this._writeMixFields(trackId, mix);
|
|
9529
9631
|
}
|
|
9530
9632
|
/**
|
|
9531
9633
|
* Append a clip to an existing track. Builds a `<daw-clip>` from `config`
|
|
@@ -10153,22 +10255,24 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10153
10255
|
<span class="annotation-lane-name">${track.name}</span>
|
|
10154
10256
|
</div>`
|
|
10155
10257
|
)}
|
|
10156
|
-
${orderedTracks.map(
|
|
10157
|
-
|
|
10258
|
+
${orderedTracks.map((t, i) => {
|
|
10259
|
+
const mix = this._mixOf(t.trackId);
|
|
10260
|
+
return import_lit19.html`
|
|
10158
10261
|
<daw-track-controls
|
|
10159
10262
|
style="height: ${t.trackHeight}px;"
|
|
10160
10263
|
.trackId=${t.trackId}
|
|
10161
10264
|
.trackName=${t.descriptor?.name ?? "Untitled"}
|
|
10162
|
-
.volume=${
|
|
10163
|
-
.pan=${
|
|
10164
|
-
.muted=${
|
|
10165
|
-
.
|
|
10265
|
+
.volume=${mix.volume}
|
|
10266
|
+
.pan=${mix.pan}
|
|
10267
|
+
.muted=${mix.muted}
|
|
10268
|
+
.recording=${this._engine?.recordingTrackIds.has(t.trackId) ?? false}
|
|
10269
|
+
.soloed=${mix.soloed}
|
|
10166
10270
|
.reorderable=${this.trackReordering}
|
|
10167
10271
|
.trackIndex=${i}
|
|
10168
10272
|
.trackCount=${orderedTracks.length}
|
|
10169
10273
|
></daw-track-controls>
|
|
10170
|
-
|
|
10171
|
-
)}
|
|
10274
|
+
`;
|
|
10275
|
+
})}
|
|
10172
10276
|
</div>
|
|
10173
10277
|
</div>` : ""}
|
|
10174
10278
|
<div class="scroll-area">
|
|
@@ -10220,7 +10324,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10220
10324
|
width = Math.round(endTick / this.ticksPerPixel) - clipLeft;
|
|
10221
10325
|
} else {
|
|
10222
10326
|
clipLeft = Math.floor(clip.startSample / spp);
|
|
10223
|
-
width = (0,
|
|
10327
|
+
width = (0, import_core17.clipPixelWidth)(clip.startSample, clip.durationSamples, spp);
|
|
10224
10328
|
}
|
|
10225
10329
|
let clipSegments;
|
|
10226
10330
|
let segmentChannels;
|
|
@@ -10578,6 +10682,9 @@ __decorateClass([
|
|
|
10578
10682
|
__decorateClass([
|
|
10579
10683
|
(0, import_decorators16.state)()
|
|
10580
10684
|
], DawEditorElement.prototype, "_tracks", 2);
|
|
10685
|
+
__decorateClass([
|
|
10686
|
+
(0, import_decorators16.state)()
|
|
10687
|
+
], DawEditorElement.prototype, "_seedMix", 2);
|
|
10581
10688
|
__decorateClass([
|
|
10582
10689
|
(0, import_decorators16.state)()
|
|
10583
10690
|
], DawEditorElement.prototype, "_engineTracks", 2);
|
|
@@ -10745,7 +10852,7 @@ DawRecordButtonElement = __decorateClass([
|
|
|
10745
10852
|
// src/elements/daw-keyboard-shortcuts.ts
|
|
10746
10853
|
var import_lit22 = require("lit");
|
|
10747
10854
|
var import_decorators19 = require("lit/decorators.js");
|
|
10748
|
-
var
|
|
10855
|
+
var import_core18 = require("@waveform-playlist/core");
|
|
10749
10856
|
var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
10750
10857
|
constructor() {
|
|
10751
10858
|
super(...arguments);
|
|
@@ -10770,7 +10877,7 @@ var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
|
10770
10877
|
const shortcuts = this.shortcuts;
|
|
10771
10878
|
if (shortcuts.length === 0) return;
|
|
10772
10879
|
try {
|
|
10773
|
-
(0,
|
|
10880
|
+
(0, import_core18.handleKeyboardEvent)(e, shortcuts, true);
|
|
10774
10881
|
} catch (err) {
|
|
10775
10882
|
console.warn("[dawcore] Keyboard shortcut failed (key=" + e.key + "): " + String(err));
|
|
10776
10883
|
const target = this._editor ?? this;
|
|
@@ -10960,7 +11067,7 @@ DawKeyboardShortcutsElement = __decorateClass([
|
|
|
10960
11067
|
// src/elements/daw-spectrogram.ts
|
|
10961
11068
|
var import_lit23 = require("lit");
|
|
10962
11069
|
var import_decorators20 = require("lit/decorators.js");
|
|
10963
|
-
var
|
|
11070
|
+
var import_core19 = require("@waveform-playlist/core");
|
|
10964
11071
|
var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
10965
11072
|
constructor() {
|
|
10966
11073
|
super(...arguments);
|
|
@@ -11025,11 +11132,11 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11025
11132
|
this._unregisterAllCanvases();
|
|
11026
11133
|
this._canvases = [];
|
|
11027
11134
|
if (this.length <= 0) return;
|
|
11028
|
-
const chunkCount = Math.ceil(this.length /
|
|
11135
|
+
const chunkCount = Math.ceil(this.length / import_core19.MAX_CANVAS_WIDTH);
|
|
11029
11136
|
for (let i = 0; i < chunkCount; i++) {
|
|
11030
|
-
const widthPx = Math.min(
|
|
11137
|
+
const widthPx = Math.min(import_core19.MAX_CANVAS_WIDTH, this.length - i * import_core19.MAX_CANVAS_WIDTH);
|
|
11031
11138
|
const canvas = document.createElement("canvas");
|
|
11032
|
-
canvas.style.left = i *
|
|
11139
|
+
canvas.style.left = i * import_core19.MAX_CANVAS_WIDTH + "px";
|
|
11033
11140
|
canvas.style.width = widthPx + "px";
|
|
11034
11141
|
const dpr = window.devicePixelRatio || 1;
|
|
11035
11142
|
canvas.width = widthPx * dpr;
|
|
@@ -11055,7 +11162,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11055
11162
|
}
|
|
11056
11163
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
11057
11164
|
const canvas = this._canvases[i];
|
|
11058
|
-
const canvasId = (0,
|
|
11165
|
+
const canvasId = (0, import_core19.buildSpectrogramCanvasId)({
|
|
11059
11166
|
clipId: this.clipId,
|
|
11060
11167
|
channelIndex: this.channelIndex,
|
|
11061
11168
|
chunkIndex: i
|
|
@@ -11076,7 +11183,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
11076
11183
|
trackId: this.trackId,
|
|
11077
11184
|
channelIndex: this.channelIndex,
|
|
11078
11185
|
chunkIndex: i,
|
|
11079
|
-
globalPixelOffset: this.originX + i *
|
|
11186
|
+
globalPixelOffset: this.originX + i * import_core19.MAX_CANVAS_WIDTH,
|
|
11080
11187
|
widthPx: parseFloat(canvas.style.width),
|
|
11081
11188
|
heightPx: this.waveHeight
|
|
11082
11189
|
});
|