@dawcore/components 0.0.39-next.3 → 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.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// <define:__INSTALL_SPECS__>
|
|
13
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.
|
|
13
|
+
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" };
|
|
14
14
|
|
|
15
15
|
// src/elements/daw-annotation.ts
|
|
16
16
|
import { LitElement } from "lit";
|
|
@@ -997,6 +997,17 @@ function isDomClip(desc) {
|
|
|
997
997
|
}
|
|
998
998
|
|
|
999
999
|
// src/elements/daw-track.ts
|
|
1000
|
+
var TRACK_PROPS = [
|
|
1001
|
+
"volume",
|
|
1002
|
+
"pan",
|
|
1003
|
+
"muted",
|
|
1004
|
+
"soloed",
|
|
1005
|
+
"src",
|
|
1006
|
+
"name",
|
|
1007
|
+
"kind",
|
|
1008
|
+
"renderMode",
|
|
1009
|
+
"spectrogramConfig"
|
|
1010
|
+
];
|
|
1000
1011
|
var DawTrackElement = class extends LitElement5 {
|
|
1001
1012
|
constructor() {
|
|
1002
1013
|
super(...arguments);
|
|
@@ -1127,24 +1138,14 @@ var DawTrackElement = class extends LitElement5 {
|
|
|
1127
1138
|
this._hasRendered = true;
|
|
1128
1139
|
return;
|
|
1129
1140
|
}
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
"muted",
|
|
1134
|
-
"soloed",
|
|
1135
|
-
"src",
|
|
1136
|
-
"name",
|
|
1137
|
-
"kind",
|
|
1138
|
-
"renderMode",
|
|
1139
|
-
"spectrogramConfig"
|
|
1140
|
-
];
|
|
1141
|
-
const hasTrackChange = trackProps.some((p) => changed.has(p));
|
|
1142
|
-
if (hasTrackChange) {
|
|
1141
|
+
const trackChanged = TRACK_PROPS.filter((p) => changed.has(p));
|
|
1142
|
+
if (trackChanged.length > 0) {
|
|
1143
|
+
const detail = { trackId: this.trackId, changed: trackChanged };
|
|
1143
1144
|
this.dispatchEvent(
|
|
1144
1145
|
new CustomEvent("daw-track-update", {
|
|
1145
1146
|
bubbles: true,
|
|
1146
1147
|
composed: true,
|
|
1147
|
-
detail
|
|
1148
|
+
detail
|
|
1148
1149
|
})
|
|
1149
1150
|
);
|
|
1150
1151
|
}
|
|
@@ -2217,6 +2218,7 @@ import { customElement as customElement16, property as property12, state as stat
|
|
|
2217
2218
|
import {
|
|
2218
2219
|
createClip as createClip2,
|
|
2219
2220
|
createClipFromSeconds,
|
|
2221
|
+
createMixerGesture as createMixerGesture2,
|
|
2220
2222
|
createTrack,
|
|
2221
2223
|
clipPixelWidth,
|
|
2222
2224
|
trackKind
|
|
@@ -2964,9 +2966,39 @@ DawRulerElement = __decorateClass([
|
|
|
2964
2966
|
customElement13("daw-ruler")
|
|
2965
2967
|
], DawRulerElement);
|
|
2966
2968
|
|
|
2969
|
+
// src/utils/track-mix.ts
|
|
2970
|
+
var DEFAULT_TRACK_MIX = Object.freeze({
|
|
2971
|
+
volume: 1,
|
|
2972
|
+
pan: 0,
|
|
2973
|
+
muted: false,
|
|
2974
|
+
soloed: false
|
|
2975
|
+
});
|
|
2976
|
+
function mixOfTrack(track) {
|
|
2977
|
+
return { volume: track.volume, pan: track.pan, muted: track.muted, soloed: track.soloed };
|
|
2978
|
+
}
|
|
2979
|
+
function mixOfElement(el) {
|
|
2980
|
+
return { volume: el.volume, pan: el.pan, muted: el.muted, soloed: el.soloed };
|
|
2981
|
+
}
|
|
2982
|
+
function pickMix(mix, names) {
|
|
2983
|
+
const named = new Set(names);
|
|
2984
|
+
return {
|
|
2985
|
+
...named.has("volume") && { volume: mix.volume },
|
|
2986
|
+
...named.has("pan") && { pan: mix.pan },
|
|
2987
|
+
...named.has("muted") && { muted: mix.muted },
|
|
2988
|
+
...named.has("soloed") && { soloed: mix.soloed }
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
function withMix(track, mix) {
|
|
2992
|
+
return { ...track, ...mixOfElement(mix) };
|
|
2993
|
+
}
|
|
2994
|
+
function clampNumber(value, min, max) {
|
|
2995
|
+
return Math.max(min, Math.min(max, Number(value)));
|
|
2996
|
+
}
|
|
2997
|
+
|
|
2967
2998
|
// src/elements/daw-track-controls.ts
|
|
2968
2999
|
import { LitElement as LitElement12, html as html9, css as css8 } from "lit";
|
|
2969
3000
|
import { customElement as customElement14, property as property10 } from "lit/decorators.js";
|
|
3001
|
+
import { createMixerGesture } from "@waveform-playlist/core";
|
|
2970
3002
|
var DawTrackControlsElement = class extends LitElement12 {
|
|
2971
3003
|
constructor() {
|
|
2972
3004
|
super(...arguments);
|
|
@@ -2975,19 +3007,30 @@ var DawTrackControlsElement = class extends LitElement12 {
|
|
|
2975
3007
|
this.volume = 1;
|
|
2976
3008
|
this.pan = 0;
|
|
2977
3009
|
this.muted = false;
|
|
3010
|
+
this.recording = false;
|
|
2978
3011
|
this.soloed = false;
|
|
2979
3012
|
this.reorderable = false;
|
|
2980
3013
|
this.trackIndex = 0;
|
|
2981
3014
|
this.trackCount = 1;
|
|
3015
|
+
/**
|
|
3016
|
+
* One gesture per slider (#843): the `daw-track-control` events of one
|
|
3017
|
+
* drag, or of one key press (a held key included), carry the same
|
|
3018
|
+
* `gesture` id, and the editor makes them one undo step. Each gesture is
|
|
3019
|
+
* attached to its range input while the element is connected.
|
|
3020
|
+
*/
|
|
3021
|
+
this._volumeGesture = createMixerGesture();
|
|
3022
|
+
this._panGesture = createMixerGesture();
|
|
3023
|
+
this._detachGestures = [];
|
|
2982
3024
|
this._onVolumeInput = (e) => {
|
|
2983
3025
|
const value = Number(e.target.value);
|
|
2984
|
-
if (Number.isFinite(value)) this._dispatchControl("volume", value);
|
|
3026
|
+
if (Number.isFinite(value)) this._dispatchControl("volume", value, this._volumeGesture.id);
|
|
2985
3027
|
};
|
|
2986
3028
|
this._onPanInput = (e) => {
|
|
2987
3029
|
const value = Number(e.target.value);
|
|
2988
|
-
if (Number.isFinite(value)) this._dispatchControl("pan", value);
|
|
3030
|
+
if (Number.isFinite(value)) this._dispatchControl("pan", value, this._panGesture.id);
|
|
2989
3031
|
};
|
|
2990
3032
|
this._onMuteClick = () => {
|
|
3033
|
+
if (this.recording) return;
|
|
2991
3034
|
this._dispatchControl("muted", !this.muted);
|
|
2992
3035
|
};
|
|
2993
3036
|
this._onSoloClick = () => {
|
|
@@ -3021,7 +3064,29 @@ var DawTrackControlsElement = class extends LitElement12 {
|
|
|
3021
3064
|
);
|
|
3022
3065
|
};
|
|
3023
3066
|
}
|
|
3067
|
+
connectedCallback() {
|
|
3068
|
+
super.connectedCallback();
|
|
3069
|
+
if (this.hasUpdated) this._attachGestures();
|
|
3070
|
+
}
|
|
3071
|
+
disconnectedCallback() {
|
|
3072
|
+
super.disconnectedCallback();
|
|
3073
|
+
this._detachAllGestures();
|
|
3074
|
+
}
|
|
3075
|
+
_attachGestures() {
|
|
3076
|
+
this._detachAllGestures();
|
|
3077
|
+
const volumeInput = this.shadowRoot?.querySelector(".vol-row input");
|
|
3078
|
+
const panInput = this.shadowRoot?.querySelector(".pan-row input");
|
|
3079
|
+
const detach = [];
|
|
3080
|
+
if (volumeInput) detach.push(this._volumeGesture.attach(volumeInput));
|
|
3081
|
+
if (panInput) detach.push(this._panGesture.attach(panInput));
|
|
3082
|
+
this._detachGestures = detach;
|
|
3083
|
+
}
|
|
3084
|
+
_detachAllGestures() {
|
|
3085
|
+
for (const detach of this._detachGestures) detach();
|
|
3086
|
+
this._detachGestures = [];
|
|
3087
|
+
}
|
|
3024
3088
|
firstUpdated() {
|
|
3089
|
+
this._attachGestures();
|
|
3025
3090
|
requestAnimationFrame(() => {
|
|
3026
3091
|
if (!this.isConnected) return;
|
|
3027
3092
|
const rect = this.getBoundingClientRect();
|
|
@@ -3032,13 +3097,15 @@ var DawTrackControlsElement = class extends LitElement12 {
|
|
|
3032
3097
|
}
|
|
3033
3098
|
});
|
|
3034
3099
|
}
|
|
3035
|
-
|
|
3100
|
+
/** `gesture` for the sliders only: each mute or solo click is a step. */
|
|
3101
|
+
_dispatchControl(prop, value, gesture) {
|
|
3036
3102
|
if (!this.trackId) return;
|
|
3103
|
+
const detail = gesture === void 0 ? { trackId: this.trackId, prop, value } : { trackId: this.trackId, prop, value, gesture };
|
|
3037
3104
|
this.dispatchEvent(
|
|
3038
3105
|
new CustomEvent("daw-track-control", {
|
|
3039
3106
|
bubbles: true,
|
|
3040
3107
|
composed: true,
|
|
3041
|
-
detail
|
|
3108
|
+
detail
|
|
3042
3109
|
})
|
|
3043
3110
|
);
|
|
3044
3111
|
}
|
|
@@ -3075,6 +3142,7 @@ var DawTrackControlsElement = class extends LitElement12 {
|
|
|
3075
3142
|
<button
|
|
3076
3143
|
class="btn ${this.muted ? "muted-active" : ""}"
|
|
3077
3144
|
@click=${this._onMuteClick}
|
|
3145
|
+
?disabled=${this.recording}
|
|
3078
3146
|
title="Mute"
|
|
3079
3147
|
>
|
|
3080
3148
|
M
|
|
@@ -3316,6 +3384,9 @@ __decorateClass([
|
|
|
3316
3384
|
__decorateClass([
|
|
3317
3385
|
property10({ type: Boolean, attribute: false })
|
|
3318
3386
|
], DawTrackControlsElement.prototype, "muted", 2);
|
|
3387
|
+
__decorateClass([
|
|
3388
|
+
property10({ type: Boolean, attribute: false })
|
|
3389
|
+
], DawTrackControlsElement.prototype, "recording", 2);
|
|
3319
3390
|
__decorateClass([
|
|
3320
3391
|
property10({ type: Boolean, attribute: false })
|
|
3321
3392
|
], DawTrackControlsElement.prototype, "soloed", 2);
|
|
@@ -3885,7 +3956,6 @@ var RecordingController = class {
|
|
|
3885
3956
|
isFirstMessage: true,
|
|
3886
3957
|
latencySamples,
|
|
3887
3958
|
clipName: options.clipName,
|
|
3888
|
-
armedPrevMuted: null,
|
|
3889
3959
|
wasOverdub: options.overdub ?? false,
|
|
3890
3960
|
_onTrackEnded: onTrackEnded,
|
|
3891
3961
|
_audioTrack: audioTrack,
|
|
@@ -3902,11 +3972,7 @@ var RecordingController = class {
|
|
|
3902
3972
|
if (audioTrack && onTrackEnded) {
|
|
3903
3973
|
audioTrack.addEventListener("ended", onTrackEnded);
|
|
3904
3974
|
}
|
|
3905
|
-
|
|
3906
|
-
if (engine) {
|
|
3907
|
-
session.armedPrevMuted = engine.getState().tracks.find((t) => t.id === trackId)?.muted ?? false;
|
|
3908
|
-
engine.setTrackMute(trackId, true);
|
|
3909
|
-
}
|
|
3975
|
+
this._host._engine?.setTrackRecording(trackId, true);
|
|
3910
3976
|
this._host.dispatchEvent(
|
|
3911
3977
|
new CustomEvent("daw-recording-start", {
|
|
3912
3978
|
bubbles: true,
|
|
@@ -4052,7 +4118,7 @@ var RecordingController = class {
|
|
|
4052
4118
|
}
|
|
4053
4119
|
});
|
|
4054
4120
|
const notPrevented = this._host.dispatchEvent(event);
|
|
4055
|
-
this.
|
|
4121
|
+
this._clearTakeMute(session);
|
|
4056
4122
|
this._sessions.delete(id);
|
|
4057
4123
|
this._host.requestUpdate();
|
|
4058
4124
|
if (notPrevented) {
|
|
@@ -4180,22 +4246,23 @@ var RecordingController = class {
|
|
|
4180
4246
|
);
|
|
4181
4247
|
}
|
|
4182
4248
|
/** Shared teardown for finalize paths that end without a take (no data
|
|
4183
|
-
* captured / too short after latency compensation):
|
|
4184
|
-
*
|
|
4185
|
-
*
|
|
4249
|
+
* captured / too short after latency compensation): clear the take's mute, drop
|
|
4250
|
+
* the session, and notify via daw-recording-error so record buttons reset
|
|
4251
|
+
* their state. */
|
|
4186
4252
|
_abandonFinalize(id, session, warnMessage, errorMessage = warnMessage) {
|
|
4187
4253
|
console.warn("[dawcore] RecordingController: " + warnMessage);
|
|
4188
|
-
this.
|
|
4254
|
+
this._clearTakeMute(session);
|
|
4189
4255
|
this._sessions.delete(id);
|
|
4190
4256
|
this._host.requestUpdate();
|
|
4191
4257
|
this._dispatchRecordingError(id, new Error(errorMessage));
|
|
4192
4258
|
}
|
|
4193
|
-
/**
|
|
4194
|
-
*
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4259
|
+
/** Clear the take's mute on the session's track, by its id. Each teardown
|
|
4260
|
+
* path calls this once, right before it drops the session from the map, so
|
|
4261
|
+
* a later path never reaches the same session; clearing an id that is not
|
|
4262
|
+
* set is a no-op in the engine. Another session's mute on another track is
|
|
4263
|
+
* left alone. */
|
|
4264
|
+
_clearTakeMute(session) {
|
|
4265
|
+
this._host._engine?.setTrackRecording(session.trackId, false);
|
|
4199
4266
|
}
|
|
4200
4267
|
/** @param notifyError dispatch daw-recording-error after cleanup — used by
|
|
4201
4268
|
* disposal paths that would otherwise discard the session silently. The
|
|
@@ -4204,7 +4271,7 @@ var RecordingController = class {
|
|
|
4204
4271
|
const session = this._sessions.get(trackId);
|
|
4205
4272
|
if (!session) return;
|
|
4206
4273
|
try {
|
|
4207
|
-
this.
|
|
4274
|
+
this._clearTakeMute(session);
|
|
4208
4275
|
this._removeTrackEndedListener(session);
|
|
4209
4276
|
session.workletNode.port.postMessage({ command: "stop" });
|
|
4210
4277
|
session.source.disconnect();
|
|
@@ -7417,6 +7484,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7417
7484
|
/** Resolved sample rate — falls back to sampleRate property until first audio decode. */
|
|
7418
7485
|
this._resolvedSampleRate = null;
|
|
7419
7486
|
this._tracks = /* @__PURE__ */ new Map();
|
|
7487
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
7420
7488
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
7421
7489
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
7422
7490
|
this._isPlaying = false;
|
|
@@ -7539,6 +7607,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7539
7607
|
}
|
|
7540
7608
|
const descriptor = this._readTrackDescriptor(trackEl);
|
|
7541
7609
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7610
|
+
this._setSeedMix(trackId, mixOfElement(trackEl));
|
|
7542
7611
|
this._trackElements.set(trackId, trackEl);
|
|
7543
7612
|
this._loadTrack(trackId, descriptor);
|
|
7544
7613
|
};
|
|
@@ -7564,15 +7633,8 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7564
7633
|
});
|
|
7565
7634
|
}
|
|
7566
7635
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
this._engine.setTrackVolume(trackId, descriptor.volume);
|
|
7570
|
-
if (oldDescriptor?.pan !== descriptor.pan) this._engine.setTrackPan(trackId, descriptor.pan);
|
|
7571
|
-
if (oldDescriptor?.muted !== descriptor.muted)
|
|
7572
|
-
this._engine.setTrackMute(trackId, descriptor.muted);
|
|
7573
|
-
if (oldDescriptor?.soloed !== descriptor.soloed)
|
|
7574
|
-
this._engine.setTrackSolo(trackId, descriptor.soloed);
|
|
7575
|
-
}
|
|
7636
|
+
const changed = Array.isArray(e.detail.changed) ? e.detail.changed : [];
|
|
7637
|
+
this._writeMixFields(trackId, pickMix(mixOfElement(trackEl), changed));
|
|
7576
7638
|
if (oldDescriptor?.src !== descriptor.src) {
|
|
7577
7639
|
this._loadTrack(trackId, descriptor);
|
|
7578
7640
|
}
|
|
@@ -7598,7 +7660,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7598
7660
|
}
|
|
7599
7661
|
};
|
|
7600
7662
|
this._onTrackControl = (e) => {
|
|
7601
|
-
const { trackId, prop, value } = e.detail ?? {};
|
|
7663
|
+
const { trackId, prop, value, gesture } = e.detail ?? {};
|
|
7602
7664
|
if (!trackId || !prop || !DawEditorElement._CONTROL_PROPS.has(prop)) return;
|
|
7603
7665
|
if (this._selectedTrackId !== trackId) {
|
|
7604
7666
|
this._setSelectedTrackId(trackId);
|
|
@@ -7613,18 +7675,12 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7613
7675
|
})
|
|
7614
7676
|
);
|
|
7615
7677
|
}
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
|
|
7620
|
-
if (this.
|
|
7621
|
-
|
|
7622
|
-
this._engine.setTrackVolume(trackId, Math.max(0, Math.min(1, Number(value))));
|
|
7623
|
-
if (prop === "pan")
|
|
7624
|
-
this._engine.setTrackPan(trackId, Math.max(-1, Math.min(1, Number(value))));
|
|
7625
|
-
if (prop === "muted") this._engine.setTrackMute(trackId, Boolean(value));
|
|
7626
|
-
if (prop === "soloed") this._engine.setTrackSolo(trackId, Boolean(value));
|
|
7627
|
-
}
|
|
7678
|
+
if (this._tracks.has(trackId)) {
|
|
7679
|
+
const options = typeof gesture === "string" ? { gesture } : void 0;
|
|
7680
|
+
if (prop === "volume") this._writeMix(trackId, "volume", clampNumber(value, 0, 1), options);
|
|
7681
|
+
if (prop === "pan") this._writeMix(trackId, "pan", clampNumber(value, -1, 1), options);
|
|
7682
|
+
if (prop === "muted") this._writeMix(trackId, "muted", Boolean(value), options);
|
|
7683
|
+
if (prop === "soloed") this._writeMix(trackId, "soloed", Boolean(value), options);
|
|
7628
7684
|
}
|
|
7629
7685
|
};
|
|
7630
7686
|
this._onTrackRemoveRequest = (e) => {
|
|
@@ -8245,9 +8301,69 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8245
8301
|
get tracks() {
|
|
8246
8302
|
return [...this._tracks.entries()].map(([trackId, descriptor]) => ({
|
|
8247
8303
|
trackId,
|
|
8248
|
-
...descriptor
|
|
8304
|
+
...descriptor,
|
|
8305
|
+
...this._mixOf(trackId)
|
|
8249
8306
|
}));
|
|
8250
8307
|
}
|
|
8308
|
+
/**
|
|
8309
|
+
* A track's mix, from its one owner: the arrangement (through
|
|
8310
|
+
* `_engineTracks`, which follows `mixerVersion`) for a track the engine
|
|
8311
|
+
* holds, the seed for one still on its way in (#843).
|
|
8312
|
+
*/
|
|
8313
|
+
_mixOf(trackId) {
|
|
8314
|
+
const seed = this._seedMix.get(trackId);
|
|
8315
|
+
if (seed) return seed;
|
|
8316
|
+
const track = this._engineTracks.get(trackId);
|
|
8317
|
+
return track ? mixOfTrack(track) : DEFAULT_TRACK_MIX;
|
|
8318
|
+
}
|
|
8319
|
+
/** Replace a track's seed (a new Map: `_seedMix` is reactive state). */
|
|
8320
|
+
_setSeedMix(trackId, mix) {
|
|
8321
|
+
this._seedMix = new Map(this._seedMix).set(trackId, mix);
|
|
8322
|
+
}
|
|
8323
|
+
_deleteSeedMix(trackIds) {
|
|
8324
|
+
let next = null;
|
|
8325
|
+
for (const id of trackIds) {
|
|
8326
|
+
if (!this._seedMix.has(id)) continue;
|
|
8327
|
+
next ?? (next = new Map(this._seedMix));
|
|
8328
|
+
next.delete(id);
|
|
8329
|
+
}
|
|
8330
|
+
if (next) this._seedMix = next;
|
|
8331
|
+
}
|
|
8332
|
+
/**
|
|
8333
|
+
* Change one mixer field of a track: the seed while the track is loading
|
|
8334
|
+
* (not an undo step, nothing sent), else the engine's setter with
|
|
8335
|
+
* `options` (an undo step; changes with one `gesture` id are one step).
|
|
8336
|
+
*/
|
|
8337
|
+
_writeMix(trackId, field, value, options) {
|
|
8338
|
+
const seed = this._seedMix.get(trackId);
|
|
8339
|
+
if (seed) {
|
|
8340
|
+
if (seed[field] !== value) this._setSeedMix(trackId, { ...seed, [field]: value });
|
|
8341
|
+
return;
|
|
8342
|
+
}
|
|
8343
|
+
if (!this._engine) return;
|
|
8344
|
+
if (field === "volume") this._engine.setTrackVolume(trackId, value, options);
|
|
8345
|
+
else if (field === "pan") this._engine.setTrackPan(trackId, value, options);
|
|
8346
|
+
else if (field === "muted") this._engine.setTrackMute(trackId, value, options);
|
|
8347
|
+
else this._engine.setTrackSolo(trackId, value, options);
|
|
8348
|
+
}
|
|
8349
|
+
/**
|
|
8350
|
+
* Change the given mixer fields of a track as ONE undo step (#843): all
|
|
8351
|
+
* of them carry one fresh gesture id. A field left out is not sent.
|
|
8352
|
+
*/
|
|
8353
|
+
_writeMixFields(trackId, mix) {
|
|
8354
|
+
const options = { gesture: createMixerGesture2().id };
|
|
8355
|
+
if (mix.volume !== void 0) this._writeMix(trackId, "volume", mix.volume, options);
|
|
8356
|
+
if (mix.pan !== void 0) this._writeMix(trackId, "pan", mix.pan, options);
|
|
8357
|
+
if (mix.muted !== void 0) this._writeMix(trackId, "muted", mix.muted, options);
|
|
8358
|
+
if (mix.soloed !== void 0) this._writeMix(trackId, "soloed", mix.soloed, options);
|
|
8359
|
+
}
|
|
8360
|
+
/** The ordered tracks for `engine.setTracks`, a loading track with its seed. */
|
|
8361
|
+
_tracksForEngine() {
|
|
8362
|
+
return this._getOrderedTracks().map(([trackId, track]) => {
|
|
8363
|
+
const seed = this._seedMix.get(trackId);
|
|
8364
|
+
return seed ? withMix(track, seed) : track;
|
|
8365
|
+
});
|
|
8366
|
+
}
|
|
8251
8367
|
get selectedTrackId() {
|
|
8252
8368
|
return this._selectedTrackId;
|
|
8253
8369
|
}
|
|
@@ -8371,6 +8487,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8371
8487
|
this._adapterConsumedByDispose = true;
|
|
8372
8488
|
}
|
|
8373
8489
|
this._tracks = /* @__PURE__ */ new Map();
|
|
8490
|
+
this._seedMix = /* @__PURE__ */ new Map();
|
|
8374
8491
|
this._engineTracks = /* @__PURE__ */ new Map();
|
|
8375
8492
|
this._peaksData = /* @__PURE__ */ new Map();
|
|
8376
8493
|
this._loadingTracks.clear();
|
|
@@ -8444,6 +8561,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8444
8561
|
const nextTracks = new Map(this._tracks);
|
|
8445
8562
|
nextTracks.delete(trackId);
|
|
8446
8563
|
this._tracks = nextTracks;
|
|
8564
|
+
this._deleteSeedMix([trackId]);
|
|
8447
8565
|
const nextEngine = new Map(this._engineTracks);
|
|
8448
8566
|
nextEngine.delete(trackId);
|
|
8449
8567
|
this._engineTracks = nextEngine;
|
|
@@ -8505,10 +8623,6 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8505
8623
|
next.set(track.id, {
|
|
8506
8624
|
name: track.name ?? "",
|
|
8507
8625
|
src: "",
|
|
8508
|
-
volume: track.volume ?? 1,
|
|
8509
|
-
pan: track.pan ?? 0,
|
|
8510
|
-
muted: track.muted ?? false,
|
|
8511
|
-
soloed: track.soloed ?? false,
|
|
8512
8626
|
kind: trackKind(track),
|
|
8513
8627
|
renderMode: trackDescriptorRenderMode(trackKind(track), "waveform"),
|
|
8514
8628
|
clips: []
|
|
@@ -8795,8 +8909,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8795
8909
|
_commitTrackChange(trackId, updatedTrack) {
|
|
8796
8910
|
this._recomputeDuration();
|
|
8797
8911
|
if (this._engine?.updateTrack) this._engine.updateTrack(trackId, updatedTrack);
|
|
8798
|
-
else if (this._engine)
|
|
8799
|
-
this._engine.setTracks(this._getOrderedTracks().map(([, track]) => track));
|
|
8912
|
+
else if (this._engine) this._engine.setTracks(this._tracksForEngine());
|
|
8800
8913
|
}
|
|
8801
8914
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
8802
8915
|
const t = this._engineTracks.get(trackId);
|
|
@@ -8958,10 +9071,6 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8958
9071
|
return {
|
|
8959
9072
|
name: trackEl.name || "Untitled",
|
|
8960
9073
|
src: trackEl.src,
|
|
8961
|
-
volume: trackEl.volume,
|
|
8962
|
-
pan: trackEl.pan,
|
|
8963
|
-
muted: trackEl.muted,
|
|
8964
|
-
soloed: trackEl.soloed,
|
|
8965
9074
|
kind: trackEl.kind,
|
|
8966
9075
|
renderMode: trackDescriptorRenderMode(trackEl.kind, trackEl.renderMode),
|
|
8967
9076
|
clips
|
|
@@ -9050,10 +9159,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9050
9159
|
name: descriptor.name,
|
|
9051
9160
|
kind: descriptor.kind,
|
|
9052
9161
|
clips: [clip2],
|
|
9053
|
-
|
|
9054
|
-
pan: descriptor.pan,
|
|
9055
|
-
muted: descriptor.muted,
|
|
9056
|
-
soloed: descriptor.soloed
|
|
9162
|
+
...this._mixOf(trackId)
|
|
9057
9163
|
});
|
|
9058
9164
|
previewTrack.id = trackId;
|
|
9059
9165
|
this._engineTracks = new Map(this._engineTracks).set(trackId, previewTrack);
|
|
@@ -9128,10 +9234,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9128
9234
|
name: descriptor.name,
|
|
9129
9235
|
kind: descriptor.kind,
|
|
9130
9236
|
clips,
|
|
9131
|
-
|
|
9132
|
-
pan: descriptor.pan,
|
|
9133
|
-
muted: descriptor.muted,
|
|
9134
|
-
soloed: descriptor.soloed
|
|
9237
|
+
...this._mixOf(trackId)
|
|
9135
9238
|
});
|
|
9136
9239
|
const requestedClips = descriptor.clips.filter((c) => c.src).length + refusedMidiClips;
|
|
9137
9240
|
if (requestedClips > 0 && clips.length === 0) {
|
|
@@ -9146,7 +9249,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9146
9249
|
this._maybeRegisterSpectrogramClipAudio(trackId, c);
|
|
9147
9250
|
}
|
|
9148
9251
|
const engine = await this._ensureEngine();
|
|
9149
|
-
engine.setTracks(this.
|
|
9252
|
+
engine.setTracks(this._tracksForEngine());
|
|
9150
9253
|
this.dispatchEvent(
|
|
9151
9254
|
new CustomEvent("daw-track-ready", {
|
|
9152
9255
|
bubbles: true,
|
|
@@ -9271,6 +9374,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9271
9374
|
nextTracks.set(track.id, track);
|
|
9272
9375
|
}
|
|
9273
9376
|
this._engineTracks = nextTracks;
|
|
9377
|
+
this._deleteSeedMix(nextTracks.keys());
|
|
9274
9378
|
this._reconcileDescriptorsWithEngineTracks(engineState.tracks);
|
|
9275
9379
|
}
|
|
9276
9380
|
if (structuralChange) {
|
|
@@ -9444,14 +9548,22 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9444
9548
|
}
|
|
9445
9549
|
}
|
|
9446
9550
|
/**
|
|
9447
|
-
* Update reflected attributes on a track.
|
|
9448
|
-
*
|
|
9449
|
-
*
|
|
9450
|
-
*
|
|
9551
|
+
* Update reflected attributes on a track. The mixer fields go to their
|
|
9552
|
+
* owner as one undo step (#843): the engine, or while the track is loading
|
|
9553
|
+
* the values it will enter with (not a step). For DOM-element tracks the
|
|
9554
|
+
* changes are also written to the `<daw-track>` element; for tracks
|
|
9555
|
+
* without a DOM element (file drops) the descriptor is updated in place.
|
|
9451
9556
|
*/
|
|
9452
9557
|
updateTrack(trackId, partial) {
|
|
9558
|
+
const mix = {
|
|
9559
|
+
volume: partial.volume,
|
|
9560
|
+
pan: partial.pan,
|
|
9561
|
+
muted: partial.muted,
|
|
9562
|
+
soloed: partial.soloed
|
|
9563
|
+
};
|
|
9453
9564
|
const trackEl = this._trackElements.get(trackId);
|
|
9454
9565
|
if (trackEl) {
|
|
9566
|
+
this._writeMixFields(trackId, mix);
|
|
9455
9567
|
if (partial.name !== void 0) trackEl.setAttribute("name", partial.name);
|
|
9456
9568
|
if (partial.volume !== void 0) trackEl.volume = partial.volume;
|
|
9457
9569
|
if (partial.pan !== void 0) trackEl.pan = partial.pan;
|
|
@@ -9478,21 +9590,12 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9478
9590
|
const newDesc = {
|
|
9479
9591
|
...oldDesc,
|
|
9480
9592
|
...partial.name !== void 0 && { name: partial.name },
|
|
9481
|
-
...partial.volume !== void 0 && { volume: partial.volume },
|
|
9482
|
-
...partial.pan !== void 0 && { pan: partial.pan },
|
|
9483
|
-
...partial.muted !== void 0 && { muted: partial.muted },
|
|
9484
|
-
...partial.soloed !== void 0 && { soloed: partial.soloed },
|
|
9485
9593
|
...normalizedRenderMode !== void 0 && {
|
|
9486
9594
|
renderMode: trackDescriptorRenderMode(oldDesc.kind, normalizedRenderMode)
|
|
9487
9595
|
}
|
|
9488
9596
|
};
|
|
9489
9597
|
this._tracks = new Map(this._tracks).set(trackId, newDesc);
|
|
9490
|
-
|
|
9491
|
-
if (partial.volume !== void 0) this._engine.setTrackVolume(trackId, partial.volume);
|
|
9492
|
-
if (partial.pan !== void 0) this._engine.setTrackPan(trackId, partial.pan);
|
|
9493
|
-
if (partial.muted !== void 0) this._engine.setTrackMute(trackId, partial.muted);
|
|
9494
|
-
if (partial.soloed !== void 0) this._engine.setTrackSolo(trackId, partial.soloed);
|
|
9495
|
-
}
|
|
9598
|
+
this._writeMixFields(trackId, mix);
|
|
9496
9599
|
}
|
|
9497
9600
|
/**
|
|
9498
9601
|
* Append a clip to an existing track. Builds a `<daw-clip>` from `config`
|
|
@@ -10120,22 +10223,24 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10120
10223
|
<span class="annotation-lane-name">${track.name}</span>
|
|
10121
10224
|
</div>`
|
|
10122
10225
|
)}
|
|
10123
|
-
${orderedTracks.map(
|
|
10124
|
-
(t
|
|
10226
|
+
${orderedTracks.map((t, i) => {
|
|
10227
|
+
const mix = this._mixOf(t.trackId);
|
|
10228
|
+
return html12`
|
|
10125
10229
|
<daw-track-controls
|
|
10126
10230
|
style="height: ${t.trackHeight}px;"
|
|
10127
10231
|
.trackId=${t.trackId}
|
|
10128
10232
|
.trackName=${t.descriptor?.name ?? "Untitled"}
|
|
10129
|
-
.volume=${
|
|
10130
|
-
.pan=${
|
|
10131
|
-
.muted=${
|
|
10132
|
-
.
|
|
10233
|
+
.volume=${mix.volume}
|
|
10234
|
+
.pan=${mix.pan}
|
|
10235
|
+
.muted=${mix.muted}
|
|
10236
|
+
.recording=${this._engine?.recordingTrackIds.has(t.trackId) ?? false}
|
|
10237
|
+
.soloed=${mix.soloed}
|
|
10133
10238
|
.reorderable=${this.trackReordering}
|
|
10134
10239
|
.trackIndex=${i}
|
|
10135
10240
|
.trackCount=${orderedTracks.length}
|
|
10136
10241
|
></daw-track-controls>
|
|
10137
|
-
|
|
10138
|
-
)}
|
|
10242
|
+
`;
|
|
10243
|
+
})}
|
|
10139
10244
|
</div>
|
|
10140
10245
|
</div>` : ""}
|
|
10141
10246
|
<div class="scroll-area">
|
|
@@ -10545,6 +10650,9 @@ __decorateClass([
|
|
|
10545
10650
|
__decorateClass([
|
|
10546
10651
|
state4()
|
|
10547
10652
|
], DawEditorElement.prototype, "_tracks", 2);
|
|
10653
|
+
__decorateClass([
|
|
10654
|
+
state4()
|
|
10655
|
+
], DawEditorElement.prototype, "_seedMix", 2);
|
|
10548
10656
|
__decorateClass([
|
|
10549
10657
|
state4()
|
|
10550
10658
|
], DawEditorElement.prototype, "_engineTracks", 2);
|