@dawcore/components 0.0.37 → 0.0.39-next.0
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 +54 -10
- package/dist/index.d.mts +73 -65
- package/dist/index.d.ts +73 -65
- package/dist/index.js +393 -129
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +393 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
package/dist/index.mjs
CHANGED
|
@@ -171,6 +171,7 @@ import {
|
|
|
171
171
|
updateAnnotationBoundaries,
|
|
172
172
|
resolveAnnotationShortcuts,
|
|
173
173
|
matchesKeyBinding,
|
|
174
|
+
keyBelongsToFocusedControl,
|
|
174
175
|
ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
175
176
|
annotationMinDurationTicks
|
|
176
177
|
} from "@waveform-playlist/core";
|
|
@@ -237,10 +238,7 @@ var DawAnnotationTrackElement = class extends LitElement2 {
|
|
|
237
238
|
this._onKeyDownCapture = (e) => {
|
|
238
239
|
if (!this.keyboardControls) return;
|
|
239
240
|
if (e.repeat) return;
|
|
240
|
-
|
|
241
|
-
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
241
|
+
if (keyBelongsToFocusedControl(e)) return;
|
|
244
242
|
const match = this._shortcutEntries().find((entry) => matchesKeyBinding(e, entry.binding));
|
|
245
243
|
if (!match) return;
|
|
246
244
|
const hasSelection = this._activeAnnotationId !== null;
|
|
@@ -978,6 +976,24 @@ DawClipElement = __decorateClass([
|
|
|
978
976
|
// src/elements/daw-track.ts
|
|
979
977
|
import { LitElement as LitElement5 } from "lit";
|
|
980
978
|
import { customElement as customElement5, property as property5 } from "lit/decorators.js";
|
|
979
|
+
|
|
980
|
+
// src/types.ts
|
|
981
|
+
function normalizeRenderMode(value) {
|
|
982
|
+
if (value === null || value === void 0) return "waveform";
|
|
983
|
+
if (value === "waveform" || value === "spectrogram" || value === "both") return value;
|
|
984
|
+
console.warn(
|
|
985
|
+
'[dawcore] render-mode="' + String(value) + '" is not a render mode (waveform or spectrogram); using waveform.' + (value === "piano-roll" ? ' A piano roll is how a MIDI track is drawn: set kind="midi" on the track.' : "")
|
|
986
|
+
);
|
|
987
|
+
return "waveform";
|
|
988
|
+
}
|
|
989
|
+
function trackDescriptorRenderMode(kind, requested) {
|
|
990
|
+
return kind === "midi" ? "waveform" : requested;
|
|
991
|
+
}
|
|
992
|
+
function isDomClip(desc) {
|
|
993
|
+
return desc.kind === "dom";
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
// src/elements/daw-track.ts
|
|
981
997
|
var DawTrackElement = class extends LitElement5 {
|
|
982
998
|
constructor() {
|
|
983
999
|
super(...arguments);
|
|
@@ -987,6 +1003,7 @@ var DawTrackElement = class extends LitElement5 {
|
|
|
987
1003
|
this.pan = 0;
|
|
988
1004
|
this.muted = false;
|
|
989
1005
|
this.soloed = false;
|
|
1006
|
+
this._kind = "audio";
|
|
990
1007
|
this._renderMode = "waveform";
|
|
991
1008
|
this.spectrogramConfig = null;
|
|
992
1009
|
this.trackId = crypto.randomUUID();
|
|
@@ -995,12 +1012,26 @@ var DawTrackElement = class extends LitElement5 {
|
|
|
995
1012
|
// cannot bubble events to ancestors).
|
|
996
1013
|
this._hasRendered = false;
|
|
997
1014
|
}
|
|
1015
|
+
get kind() {
|
|
1016
|
+
return this._kind;
|
|
1017
|
+
}
|
|
1018
|
+
set kind(value) {
|
|
1019
|
+
if (value !== "audio" && value !== "midi") {
|
|
1020
|
+
console.warn(
|
|
1021
|
+
'[dawcore] <daw-track kind="' + String(value) + `"> is not a track kind ('audio' or 'midi'); keeping "` + this._kind + '"'
|
|
1022
|
+
);
|
|
1023
|
+
return;
|
|
1024
|
+
}
|
|
1025
|
+
const old = this._kind;
|
|
1026
|
+
this._kind = value;
|
|
1027
|
+
this.requestUpdate("kind", old);
|
|
1028
|
+
}
|
|
998
1029
|
get renderMode() {
|
|
999
1030
|
return this._renderMode;
|
|
1000
1031
|
}
|
|
1001
1032
|
set renderMode(value) {
|
|
1002
1033
|
const old = this._renderMode;
|
|
1003
|
-
let next = value;
|
|
1034
|
+
let next = normalizeRenderMode(value);
|
|
1004
1035
|
if (next === "both") {
|
|
1005
1036
|
console.warn(
|
|
1006
1037
|
`[dawcore] <daw-track render-mode="both"> is not yet supported; falling back to 'spectrogram'`
|
|
@@ -1100,6 +1131,7 @@ var DawTrackElement = class extends LitElement5 {
|
|
|
1100
1131
|
"soloed",
|
|
1101
1132
|
"src",
|
|
1102
1133
|
"name",
|
|
1134
|
+
"kind",
|
|
1103
1135
|
"renderMode",
|
|
1104
1136
|
"spectrogramConfig"
|
|
1105
1137
|
];
|
|
@@ -1133,6 +1165,9 @@ __decorateClass([
|
|
|
1133
1165
|
__decorateClass([
|
|
1134
1166
|
property5({ type: Boolean })
|
|
1135
1167
|
], DawTrackElement.prototype, "soloed", 2);
|
|
1168
|
+
__decorateClass([
|
|
1169
|
+
property5({ reflect: true, noAccessor: true })
|
|
1170
|
+
], DawTrackElement.prototype, "kind", 1);
|
|
1136
1171
|
__decorateClass([
|
|
1137
1172
|
property5({ attribute: "render-mode", noAccessor: true })
|
|
1138
1173
|
], DawTrackElement.prototype, "renderMode", 1);
|
|
@@ -1164,6 +1199,19 @@ function aggregatePeaks(data, bits, startIndex, endIndex) {
|
|
|
1164
1199
|
}
|
|
1165
1200
|
return { min: minPeak, max: maxPeak };
|
|
1166
1201
|
}
|
|
1202
|
+
function clampToFullScale(value) {
|
|
1203
|
+
return Math.max(-1, Math.min(1, value));
|
|
1204
|
+
}
|
|
1205
|
+
function scalePeakByGain(peak, gain) {
|
|
1206
|
+
if (gain === 1 || !Number.isFinite(gain)) {
|
|
1207
|
+
return peak;
|
|
1208
|
+
}
|
|
1209
|
+
const factor = Math.abs(gain);
|
|
1210
|
+
return {
|
|
1211
|
+
min: clampToFullScale(peak.min * factor),
|
|
1212
|
+
max: clampToFullScale(peak.max * factor)
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1167
1215
|
function calculateBarRects(x, barWidth, halfHeight, minPeak, maxPeak, drawMode) {
|
|
1168
1216
|
const min = Math.abs(minPeak * halfHeight);
|
|
1169
1217
|
const max = Math.abs(maxPeak * halfHeight);
|
|
@@ -1205,7 +1253,8 @@ var LAYOUT_PROPS = /* @__PURE__ */ new Set([
|
|
|
1205
1253
|
"barWidth",
|
|
1206
1254
|
"barGap",
|
|
1207
1255
|
"roundedBars",
|
|
1208
|
-
"segments"
|
|
1256
|
+
"segments",
|
|
1257
|
+
"gain"
|
|
1209
1258
|
]);
|
|
1210
1259
|
function groupDirtyByChunk(dirtyPixels, step, barWidth) {
|
|
1211
1260
|
const dirtyByChunk = /* @__PURE__ */ new Map();
|
|
@@ -1245,6 +1294,7 @@ var DawWaveformElement = class extends LitElement6 {
|
|
|
1245
1294
|
this.barWidth = 1;
|
|
1246
1295
|
this.barGap = 0;
|
|
1247
1296
|
this.roundedBars = false;
|
|
1297
|
+
this.gain = 1;
|
|
1248
1298
|
this.visibleStart = -Infinity;
|
|
1249
1299
|
this.visibleEnd = Infinity;
|
|
1250
1300
|
this.originX = 0;
|
|
@@ -1357,8 +1407,9 @@ var DawWaveformElement = class extends LitElement6 {
|
|
|
1357
1407
|
const barRadius = this.roundedBars ? this.barWidth / 2 : null;
|
|
1358
1408
|
if (barRadius !== null) ctx.beginPath();
|
|
1359
1409
|
for (let bar = Math.max(0, firstBar); bar < regionEnd; bar += step) {
|
|
1360
|
-
const
|
|
1361
|
-
if (!
|
|
1410
|
+
const source = aggregatePeaks(this._peaks, bits, bar, bar + step);
|
|
1411
|
+
if (!source) continue;
|
|
1412
|
+
const peak = scalePeakByGain(source, this.gain);
|
|
1362
1413
|
const rects = calculateBarRects(
|
|
1363
1414
|
bar - globalOffset,
|
|
1364
1415
|
this.barWidth,
|
|
@@ -1406,8 +1457,9 @@ var DawWaveformElement = class extends LitElement6 {
|
|
|
1406
1457
|
const pxInSeg = px + globalOffset - seg.pixelStart;
|
|
1407
1458
|
const peakPos = seg.peakStart + pxInSeg * peaksPerPixel;
|
|
1408
1459
|
const peakEnd = peakPos + step * peaksPerPixel;
|
|
1409
|
-
const
|
|
1410
|
-
if (!
|
|
1460
|
+
const source = aggregatePeaks(this._peaks, bits, Math.floor(peakPos), Math.ceil(peakEnd));
|
|
1461
|
+
if (!source) continue;
|
|
1462
|
+
const peak = scalePeakByGain(source, this.gain);
|
|
1411
1463
|
const rects = calculateBarRects(
|
|
1412
1464
|
px,
|
|
1413
1465
|
this.barWidth,
|
|
@@ -1509,6 +1561,9 @@ __decorateClass([
|
|
|
1509
1561
|
__decorateClass([
|
|
1510
1562
|
property6({ type: Boolean, attribute: false })
|
|
1511
1563
|
], DawWaveformElement.prototype, "roundedBars", 2);
|
|
1564
|
+
__decorateClass([
|
|
1565
|
+
property6({ type: Number, attribute: false })
|
|
1566
|
+
], DawWaveformElement.prototype, "gain", 2);
|
|
1512
1567
|
__decorateClass([
|
|
1513
1568
|
property6({ type: Number, attribute: false })
|
|
1514
1569
|
], DawWaveformElement.prototype, "visibleStart", 2);
|
|
@@ -2156,18 +2211,12 @@ DawStopButtonElement = __decorateClass([
|
|
|
2156
2211
|
// src/elements/daw-editor.ts
|
|
2157
2212
|
import { LitElement as LitElement14, html as html12, css as css11 } from "lit";
|
|
2158
2213
|
import { customElement as customElement16, property as property12, state as state4 } from "lit/decorators.js";
|
|
2159
|
-
|
|
2160
|
-
// src/types.ts
|
|
2161
|
-
function isDomClip(desc) {
|
|
2162
|
-
return desc.kind === "dom";
|
|
2163
|
-
}
|
|
2164
|
-
|
|
2165
|
-
// src/elements/daw-editor.ts
|
|
2166
2214
|
import {
|
|
2167
2215
|
createClip as createClip2,
|
|
2168
2216
|
createClipFromSeconds,
|
|
2169
2217
|
createTrack,
|
|
2170
|
-
clipPixelWidth
|
|
2218
|
+
clipPixelWidth,
|
|
2219
|
+
trackKind
|
|
2171
2220
|
} from "@waveform-playlist/core";
|
|
2172
2221
|
|
|
2173
2222
|
// src/workers/peaksWorker.ts
|
|
@@ -5518,7 +5567,7 @@ async function loadMidiImpl(host, source, options = {}) {
|
|
|
5518
5567
|
parsed.tracks.map(
|
|
5519
5568
|
(t) => host.addTrack({
|
|
5520
5569
|
name: t.name,
|
|
5521
|
-
|
|
5570
|
+
kind: "midi",
|
|
5522
5571
|
clips: [
|
|
5523
5572
|
{
|
|
5524
5573
|
midiNotes: t.notes,
|
|
@@ -5634,6 +5683,9 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5634
5683
|
const sr = host.effectiveSampleRate;
|
|
5635
5684
|
const clipDesc = {
|
|
5636
5685
|
kind: "drop",
|
|
5686
|
+
// The take has no <daw-clip> element — the engine id is the only
|
|
5687
|
+
// handle updateClip()/removeClip() can address it by (#659).
|
|
5688
|
+
clipId: clip.id,
|
|
5637
5689
|
src: "",
|
|
5638
5690
|
peaksSrc: "",
|
|
5639
5691
|
start: startSample / sr,
|
|
@@ -5660,6 +5712,15 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
5660
5712
|
} else {
|
|
5661
5713
|
host._engine?.setTracks([...host._engineTracks.values()]);
|
|
5662
5714
|
}
|
|
5715
|
+
if (host.isConnected) {
|
|
5716
|
+
host.dispatchEvent(
|
|
5717
|
+
new CustomEvent("daw-recording-clip-add", {
|
|
5718
|
+
bubbles: true,
|
|
5719
|
+
composed: true,
|
|
5720
|
+
detail: { trackId, clipId: clip.id }
|
|
5721
|
+
})
|
|
5722
|
+
);
|
|
5723
|
+
}
|
|
5663
5724
|
}).catch((err) => {
|
|
5664
5725
|
console.warn("[dawcore] Failed to generate peaks for recorded clip: " + String(err));
|
|
5665
5726
|
const next = new Map(host._clipBuffers);
|
|
@@ -6056,37 +6117,102 @@ function loadFaustModule(feature) {
|
|
|
6056
6117
|
return loadOptionalModule(() => import("@dawcore/faust"), "@dawcore/faust", feature);
|
|
6057
6118
|
}
|
|
6058
6119
|
|
|
6120
|
+
// src/effects/effects-manager.ts
|
|
6121
|
+
import {
|
|
6122
|
+
createEffectInstance,
|
|
6123
|
+
ensureEffectPrepared,
|
|
6124
|
+
getEffectDefinitions as getEffectDefinitions2,
|
|
6125
|
+
needsPrepare,
|
|
6126
|
+
prepareEffect
|
|
6127
|
+
} from "@waveform-playlist/core";
|
|
6128
|
+
|
|
6059
6129
|
// src/effects/effect-registry.ts
|
|
6130
|
+
import {
|
|
6131
|
+
getEffectDefinitions,
|
|
6132
|
+
registerEffect,
|
|
6133
|
+
unregisterEffect
|
|
6134
|
+
} from "@waveform-playlist/core";
|
|
6060
6135
|
var MAX_DELAY_SECONDS = 10;
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
if (registry.has(type)) {
|
|
6064
|
-
console.warn(
|
|
6065
|
-
'[waveform-playlist] registerEffect: overwriting existing effect type "' + type + '"'
|
|
6066
|
-
);
|
|
6067
|
-
}
|
|
6068
|
-
registry.set(type, definition);
|
|
6069
|
-
}
|
|
6070
|
-
function getEffectDefinitions() {
|
|
6071
|
-
return new Map(registry);
|
|
6136
|
+
function singleNode(node, applyParams) {
|
|
6137
|
+
return { input: node, output: node, applyParams };
|
|
6072
6138
|
}
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6139
|
+
var BIQUAD_PARAM_DEFS = {
|
|
6140
|
+
frequency: { min: 20, max: 2e4, step: 1, unit: "Hz" },
|
|
6141
|
+
q: { min: 0.1, max: 20, step: 0.1 },
|
|
6142
|
+
gain: { min: -24, max: 24, step: 0.5, unit: "dB" }
|
|
6143
|
+
};
|
|
6144
|
+
var RESONANCE_DB_PARAM_DEF = { min: -12, max: 24, step: 0.1, unit: "dB" };
|
|
6145
|
+
var BUTTERWORTH_RESONANCE_DB = -3;
|
|
6146
|
+
var BIQUAD_FILTERS = {
|
|
6147
|
+
// Unchanged since before #661 — including its q range, which predates the
|
|
6148
|
+
// dB reading above (q here is also resonance in dB; persisted chains rely
|
|
6149
|
+
// on these exact defaults and bounds).
|
|
6150
|
+
"native-filter": {
|
|
6151
|
+
label: "Lowpass Filter",
|
|
6152
|
+
biquadType: "lowpass",
|
|
6153
|
+
defaults: { frequency: 1e3, q: 1 }
|
|
6154
|
+
},
|
|
6155
|
+
"native-highpass": {
|
|
6156
|
+
label: "Highpass Filter",
|
|
6157
|
+
biquadType: "highpass",
|
|
6158
|
+
defaults: { frequency: 80, q: BUTTERWORTH_RESONANCE_DB },
|
|
6159
|
+
paramDefs: { q: RESONANCE_DB_PARAM_DEF }
|
|
6160
|
+
},
|
|
6161
|
+
"native-bandpass": {
|
|
6162
|
+
label: "Bandpass Filter",
|
|
6163
|
+
biquadType: "bandpass",
|
|
6164
|
+
defaults: { frequency: 1e3, q: 1 }
|
|
6165
|
+
},
|
|
6166
|
+
"native-notch": {
|
|
6167
|
+
label: "Notch Filter",
|
|
6168
|
+
biquadType: "notch",
|
|
6169
|
+
defaults: { frequency: 1e3, q: 1 }
|
|
6170
|
+
},
|
|
6171
|
+
"native-peaking": {
|
|
6172
|
+
label: "Peaking EQ",
|
|
6173
|
+
biquadType: "peaking",
|
|
6174
|
+
defaults: { frequency: 1e3, q: 1, gain: 0 }
|
|
6175
|
+
},
|
|
6176
|
+
"native-lowshelf": {
|
|
6177
|
+
label: "Low Shelf",
|
|
6178
|
+
biquadType: "lowshelf",
|
|
6179
|
+
defaults: { frequency: 200, gain: 0 }
|
|
6180
|
+
},
|
|
6181
|
+
"native-highshelf": {
|
|
6182
|
+
label: "High Shelf",
|
|
6183
|
+
biquadType: "highshelf",
|
|
6184
|
+
defaults: { frequency: 4e3, gain: 0 }
|
|
6079
6185
|
}
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
return {
|
|
6186
|
+
};
|
|
6187
|
+
function biquadDefinition(spec) {
|
|
6188
|
+
const names = Object.keys(spec.defaults);
|
|
6189
|
+
return {
|
|
6190
|
+
label: spec.label,
|
|
6191
|
+
category: "filter",
|
|
6192
|
+
defaults: { ...spec.defaults },
|
|
6193
|
+
params: Object.fromEntries(
|
|
6194
|
+
names.map((name) => [name, spec.paramDefs?.[name] ?? BIQUAD_PARAM_DEFS[name]])
|
|
6195
|
+
),
|
|
6196
|
+
create: (ctx) => {
|
|
6197
|
+
const node = ctx.createBiquadFilter();
|
|
6198
|
+
node.type = spec.biquadType;
|
|
6199
|
+
return singleNode(node, (p) => {
|
|
6200
|
+
if (names.includes("frequency") && p.frequency !== void 0) {
|
|
6201
|
+
node.frequency.value = p.frequency;
|
|
6202
|
+
}
|
|
6203
|
+
if (names.includes("q") && p.q !== void 0) node.Q.value = p.q;
|
|
6204
|
+
if (names.includes("gain") && p.gain !== void 0) node.gain.value = p.gain;
|
|
6205
|
+
});
|
|
6206
|
+
}
|
|
6207
|
+
};
|
|
6084
6208
|
}
|
|
6085
|
-
function
|
|
6086
|
-
|
|
6209
|
+
function registerBuiltIn(type, definition) {
|
|
6210
|
+
if (!getEffectDefinitions().has(type)) {
|
|
6211
|
+
registerEffect(type, { ...definition, builtIn: true });
|
|
6212
|
+
}
|
|
6087
6213
|
}
|
|
6088
6214
|
function registerBuiltIns() {
|
|
6089
|
-
|
|
6215
|
+
registerBuiltIn("native-gain", {
|
|
6090
6216
|
label: "Gain",
|
|
6091
6217
|
category: "dynamics",
|
|
6092
6218
|
defaults: { gain: 1 },
|
|
@@ -6098,24 +6224,10 @@ function registerBuiltIns() {
|
|
|
6098
6224
|
});
|
|
6099
6225
|
}
|
|
6100
6226
|
});
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
params: {
|
|
6106
|
-
frequency: { min: 20, max: 2e4, step: 1, unit: "Hz" },
|
|
6107
|
-
q: { min: 0.1, max: 20, step: 0.1 }
|
|
6108
|
-
},
|
|
6109
|
-
create: (ctx) => {
|
|
6110
|
-
const node = ctx.createBiquadFilter();
|
|
6111
|
-
node.type = "lowpass";
|
|
6112
|
-
return singleNode(node, (p) => {
|
|
6113
|
-
if (p.frequency !== void 0) node.frequency.value = p.frequency;
|
|
6114
|
-
if (p.q !== void 0) node.Q.value = p.q;
|
|
6115
|
-
});
|
|
6116
|
-
}
|
|
6117
|
-
});
|
|
6118
|
-
registry.set("native-compressor", {
|
|
6227
|
+
for (const [type, definition] of Object.entries(BIQUAD_FILTERS)) {
|
|
6228
|
+
registerBuiltIn(type, biquadDefinition(definition));
|
|
6229
|
+
}
|
|
6230
|
+
registerBuiltIn("native-compressor", {
|
|
6119
6231
|
label: "Compressor",
|
|
6120
6232
|
category: "dynamics",
|
|
6121
6233
|
defaults: { threshold: -24, knee: 30, ratio: 12, attack: 3e-3, release: 0.25 },
|
|
@@ -6137,7 +6249,7 @@ function registerBuiltIns() {
|
|
|
6137
6249
|
});
|
|
6138
6250
|
}
|
|
6139
6251
|
});
|
|
6140
|
-
|
|
6252
|
+
registerBuiltIn("native-stereo-panner", {
|
|
6141
6253
|
label: "Stereo Panner",
|
|
6142
6254
|
category: "spatial",
|
|
6143
6255
|
defaults: { pan: 0 },
|
|
@@ -6149,7 +6261,7 @@ function registerBuiltIns() {
|
|
|
6149
6261
|
});
|
|
6150
6262
|
}
|
|
6151
6263
|
});
|
|
6152
|
-
|
|
6264
|
+
registerBuiltIn("native-delay", {
|
|
6153
6265
|
label: "Delay",
|
|
6154
6266
|
category: "delay",
|
|
6155
6267
|
defaults: { delayTime: 0.25, feedback: 0.4, wet: 0.35 },
|
|
@@ -6248,6 +6360,11 @@ var EffectsManager = class {
|
|
|
6248
6360
|
validateSerializedEntries(entries);
|
|
6249
6361
|
await this._restoreChain(this._ensureMasterChain(), this._masterTarget, entries);
|
|
6250
6362
|
}
|
|
6363
|
+
/** Run a registered effect's async `prepare` hook on the adapter's
|
|
6364
|
+
* context, so the synchronous addEffect() can create it. */
|
|
6365
|
+
async prepareEffect(type) {
|
|
6366
|
+
await prepareEffect(type, this._requireWiring().audioContext);
|
|
6367
|
+
}
|
|
6251
6368
|
// --- Track chains ---
|
|
6252
6369
|
addTrackEffect(trackId, target, type, params) {
|
|
6253
6370
|
const chain = this._ensureTrackChain(trackId);
|
|
@@ -6299,8 +6416,7 @@ var EffectsManager = class {
|
|
|
6299
6416
|
const transport = this._getAdapter()?.transport;
|
|
6300
6417
|
if (!transport) return;
|
|
6301
6418
|
for (const [trackId, chain] of this._trackChains) {
|
|
6302
|
-
transport.
|
|
6303
|
-
chain.output.connect(transport.masterOutputNode);
|
|
6419
|
+
transport.connectTrackEffects(trackId, chain.input, chain.output);
|
|
6304
6420
|
}
|
|
6305
6421
|
}
|
|
6306
6422
|
disposeTrackChain(trackId) {
|
|
@@ -6311,7 +6427,7 @@ var EffectsManager = class {
|
|
|
6311
6427
|
this._destroyGui(entry.id);
|
|
6312
6428
|
}
|
|
6313
6429
|
try {
|
|
6314
|
-
this._getAdapter()?.transport?.
|
|
6430
|
+
this._getAdapter()?.transport?.disconnectTrackEffects(trackId);
|
|
6315
6431
|
} catch (err) {
|
|
6316
6432
|
console.warn(PREFIX2 + "EffectsManager: error disconnecting track output: " + String(err));
|
|
6317
6433
|
}
|
|
@@ -6346,9 +6462,10 @@ var EffectsManager = class {
|
|
|
6346
6462
|
);
|
|
6347
6463
|
}
|
|
6348
6464
|
const { audioContext, transport } = adapter;
|
|
6349
|
-
if (!audioContext || !transport || typeof transport.
|
|
6465
|
+
if (!audioContext || !transport || typeof transport.connectTrackEffects !== "function") {
|
|
6466
|
+
const outdated = typeof transport?.connectTrackOutput === "function";
|
|
6350
6467
|
throw new Error(
|
|
6351
|
-
PREFIX2 + "the current adapter does not expose effects hooks (transport.
|
|
6468
|
+
PREFIX2 + (outdated ? "the current adapter exposes the old post-fader effects hook (transport.connectTrackOutput). Track effects are pre-fader inserts now \u2014 upgrade @dawcore/transport (>= 0.0.16) or @waveform-playlist/playout (>= 13) for transport.connectTrackEffects." : "the current adapter does not expose effects hooks (transport.connectTrackEffects / connectMasterOutput).")
|
|
6352
6469
|
);
|
|
6353
6470
|
}
|
|
6354
6471
|
return { audioContext, transport };
|
|
@@ -6427,7 +6544,9 @@ var EffectsManager = class {
|
|
|
6427
6544
|
if (typeof instance.createGui === "function") {
|
|
6428
6545
|
try {
|
|
6429
6546
|
const element2 = await instance.createGui();
|
|
6430
|
-
|
|
6547
|
+
if (element2 instanceof HTMLElement) {
|
|
6548
|
+
return makeGuiRecord(element2, () => instance.destroyGui?.(element2));
|
|
6549
|
+
}
|
|
6431
6550
|
} catch (err) {
|
|
6432
6551
|
console.warn(
|
|
6433
6552
|
PREFIX2 + 'openEffectGui: plugin createGui failed for "' + effectId + '" \u2014 falling back to the generic parameter panel: ' + String(err)
|
|
@@ -6449,7 +6568,7 @@ var EffectsManager = class {
|
|
|
6449
6568
|
this._runOp(chain, target, "setParams", effectId, { [paramId]: value });
|
|
6450
6569
|
};
|
|
6451
6570
|
if (entry.kind === "native") {
|
|
6452
|
-
const definition =
|
|
6571
|
+
const definition = getEffectDefinitions2().get(entry.type);
|
|
6453
6572
|
if (!definition) {
|
|
6454
6573
|
throw new Error(
|
|
6455
6574
|
PREFIX2 + 'openEffectGui: no registry definition for effect type "' + entry.type + '"'
|
|
@@ -6502,8 +6621,7 @@ var EffectsManager = class {
|
|
|
6502
6621
|
if (existing) return existing;
|
|
6503
6622
|
const { audioContext, transport } = this._requireWiring();
|
|
6504
6623
|
const chain = new EffectsChainController(audioContext);
|
|
6505
|
-
transport.
|
|
6506
|
-
chain.output.connect(transport.masterOutputNode);
|
|
6624
|
+
transport.connectTrackEffects(trackId, chain.input, chain.output);
|
|
6507
6625
|
this._trackChains.set(trackId, chain);
|
|
6508
6626
|
return chain;
|
|
6509
6627
|
}
|
|
@@ -6680,6 +6798,11 @@ var EffectsManager = class {
|
|
|
6680
6798
|
if (superseded()) return;
|
|
6681
6799
|
if (entry.kind === "native") {
|
|
6682
6800
|
try {
|
|
6801
|
+
const liveContext = this._requireWiring().audioContext;
|
|
6802
|
+
if (needsPrepare(entry.type, liveContext)) {
|
|
6803
|
+
await ensureEffectPrepared(entry.type, liveContext);
|
|
6804
|
+
if (superseded() || chain.disposed) return;
|
|
6805
|
+
}
|
|
6683
6806
|
const id = this._addToChain(chain, target, entry.type, entry.params);
|
|
6684
6807
|
if (entry.bypassed) {
|
|
6685
6808
|
this._runOp(chain, target, "setBypassed", id, true);
|
|
@@ -6852,6 +6975,12 @@ function toWamParameterMap(params) {
|
|
|
6852
6975
|
}
|
|
6853
6976
|
|
|
6854
6977
|
// src/interactions/export-audio.ts
|
|
6978
|
+
import { createPanStage, trackChannelCount } from "@waveform-playlist/core";
|
|
6979
|
+
import {
|
|
6980
|
+
createEffectInstance as createEffectInstance2,
|
|
6981
|
+
ensureEffectPrepared as ensureEffectPrepared2,
|
|
6982
|
+
getEffectDefinitions as getEffectDefinitions3
|
|
6983
|
+
} from "@waveform-playlist/core";
|
|
6855
6984
|
var PREFIX3 = "[waveform-playlist] ";
|
|
6856
6985
|
async function exportAudioImpl(host, options = {}) {
|
|
6857
6986
|
const sampleRate = options.sampleRate ?? host.effectiveSampleRate;
|
|
@@ -6886,13 +7015,13 @@ async function exportAudioImpl(host, options = {}) {
|
|
|
6886
7015
|
cleanups.push(chain.dispose);
|
|
6887
7016
|
const volume = ctx.createGain();
|
|
6888
7017
|
volume.gain.value = track.volume;
|
|
6889
|
-
const
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
7018
|
+
const panStage = createPanStage(ctx, track.pan, trackChannelCount(track));
|
|
7019
|
+
cleanups.push(panStage.dispose);
|
|
7020
|
+
chain.output.connect(volume);
|
|
7021
|
+
volume.connect(panStage.input);
|
|
7022
|
+
panStage.output.connect(masterVolume);
|
|
6894
7023
|
for (const clip of track.clips) {
|
|
6895
|
-
scheduleClip(ctx, clip, startTime, duration,
|
|
7024
|
+
scheduleClip(ctx, clip, startTime, duration, chain.input);
|
|
6896
7025
|
}
|
|
6897
7026
|
}
|
|
6898
7027
|
return await ctx.startRendering();
|
|
@@ -6968,12 +7097,13 @@ async function buildOfflineChain(ctx, entries) {
|
|
|
6968
7097
|
continue;
|
|
6969
7098
|
}
|
|
6970
7099
|
if (entry.kind === "native") {
|
|
6971
|
-
const
|
|
6972
|
-
if (entry.bypassed) {
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
7100
|
+
const definition = getEffectDefinitions3().get(entry.type);
|
|
7101
|
+
if (entry.bypassed && definition && !definition.wetParam) {
|
|
7102
|
+
continue;
|
|
7103
|
+
}
|
|
7104
|
+
await ensureEffectPrepared2(entry.type, ctx);
|
|
7105
|
+
const created = createEffectInstance2(entry.type, ctx, entry.params);
|
|
7106
|
+
if (entry.bypassed && created.wetParam) {
|
|
6977
7107
|
created.instance.applyParams({ [created.wetParam]: 0 });
|
|
6978
7108
|
}
|
|
6979
7109
|
if (created.instance.dispose) {
|
|
@@ -7258,6 +7388,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7258
7388
|
this.roundedBars = false;
|
|
7259
7389
|
this.fileDrop = false;
|
|
7260
7390
|
this.clipHeaders = false;
|
|
7391
|
+
this.gainScaledWaveforms = false;
|
|
7261
7392
|
this.clipHeaderHeight = 20;
|
|
7262
7393
|
this.interactiveClips = false;
|
|
7263
7394
|
this.indefinitePlayback = false;
|
|
@@ -7285,11 +7416,11 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7285
7416
|
this._selectionEndTime = 0;
|
|
7286
7417
|
this._currentTime = 0;
|
|
7287
7418
|
// Bounded-playback watermark for the current play(start, end) call
|
|
7288
|
-
// (selection/annotation playback).
|
|
7289
|
-
//
|
|
7290
|
-
//
|
|
7291
|
-
//
|
|
7292
|
-
// as the whole-track _duration check.
|
|
7419
|
+
// (selection/annotation playback). Adapters with the engine's
|
|
7420
|
+
// onPlaybackEnded hook (Tone, and native since #636) report their
|
|
7421
|
+
// endTime self-stop through the engine's `stop` event; this watermark is
|
|
7422
|
+
// the fallback check in the _startPlayhead loop for adapters without the
|
|
7423
|
+
// hook, same pattern as the whole-track _duration check.
|
|
7293
7424
|
this._activePlayEndTime = null;
|
|
7294
7425
|
this._externalAdapter = null;
|
|
7295
7426
|
/** True after a disconnect disposed the consumer's adapter via the engine
|
|
@@ -7405,7 +7536,21 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7405
7536
|
const trackEl = e.target.closest("daw-track");
|
|
7406
7537
|
if (!trackEl) return;
|
|
7407
7538
|
const oldDescriptor = this._tracks.get(trackId);
|
|
7408
|
-
|
|
7539
|
+
let descriptor = this._readTrackDescriptor(trackEl);
|
|
7540
|
+
if (oldDescriptor && oldDescriptor.kind !== descriptor.kind) {
|
|
7541
|
+
console.warn(
|
|
7542
|
+
'[dawcore] <daw-track> "' + descriptor.name + '": kind cannot change after the track has loaded (still "' + oldDescriptor.kind + '"). Remove the track and add one of the other kind.'
|
|
7543
|
+
);
|
|
7544
|
+
descriptor = {
|
|
7545
|
+
...descriptor,
|
|
7546
|
+
kind: oldDescriptor.kind,
|
|
7547
|
+
renderMode: trackDescriptorRenderMode(oldDescriptor.kind, trackEl.renderMode)
|
|
7548
|
+
};
|
|
7549
|
+
const keptKind = oldDescriptor.kind;
|
|
7550
|
+
queueMicrotask(() => {
|
|
7551
|
+
trackEl.kind = keptKind;
|
|
7552
|
+
});
|
|
7553
|
+
}
|
|
7409
7554
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
7410
7555
|
if (this._engine) {
|
|
7411
7556
|
if (oldDescriptor?.volume !== descriptor.volume)
|
|
@@ -7807,6 +7952,16 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
7807
7952
|
}
|
|
7808
7953
|
return this._effectsManager;
|
|
7809
7954
|
}
|
|
7955
|
+
/**
|
|
7956
|
+
* Run a registered effect type's async `prepare` hook (e.g. an
|
|
7957
|
+
* `audioWorklet.addModule`) on this editor's audio context. Await it before
|
|
7958
|
+
* the synchronous `addEffect`/`addTrackEffect` for effect types that define
|
|
7959
|
+
* one; `setEffectsState()` and `exportAudio()` run it themselves. Idempotent
|
|
7960
|
+
* per context, and a no-op for types without a hook.
|
|
7961
|
+
*/
|
|
7962
|
+
prepareEffect(type) {
|
|
7963
|
+
return this._effects.prepareEffect(type);
|
|
7964
|
+
}
|
|
7810
7965
|
/** Master effects chain — inserted between the master bus and the destination. */
|
|
7811
7966
|
addEffect(type, params) {
|
|
7812
7967
|
return this._effects.addMasterEffect(type, params);
|
|
@@ -8342,7 +8497,8 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8342
8497
|
pan: track.pan ?? 0,
|
|
8343
8498
|
muted: track.muted ?? false,
|
|
8344
8499
|
soloed: track.soloed ?? false,
|
|
8345
|
-
|
|
8500
|
+
kind: trackKind(track),
|
|
8501
|
+
renderMode: trackDescriptorRenderMode(trackKind(track), "waveform"),
|
|
8346
8502
|
clips: []
|
|
8347
8503
|
});
|
|
8348
8504
|
}
|
|
@@ -8353,10 +8509,50 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8353
8509
|
next ?? (next = new Map(this._tracks));
|
|
8354
8510
|
next.delete(trackId);
|
|
8355
8511
|
}
|
|
8512
|
+
for (const track of tracks) {
|
|
8513
|
+
const desc = (next ?? this._tracks).get(track.id);
|
|
8514
|
+
if (!desc || !desc.clips.some((c) => !isDomClip(c) && c.clipId !== void 0)) continue;
|
|
8515
|
+
const reconciled = this._reconcileIdentifiedDropClips(desc.clips, track);
|
|
8516
|
+
if (reconciled === desc.clips) continue;
|
|
8517
|
+
next ?? (next = new Map(this._tracks));
|
|
8518
|
+
next.set(track.id, { ...desc, clips: reconciled });
|
|
8519
|
+
}
|
|
8356
8520
|
if (next) {
|
|
8357
8521
|
this._tracks = next;
|
|
8358
8522
|
}
|
|
8359
8523
|
}
|
|
8524
|
+
/** Prune id-bearing drop descriptors the engine no longer has, and refresh
|
|
8525
|
+
* the rest from their engine clip. Returns the SAME array when nothing
|
|
8526
|
+
* changed, so an unchanged track never triggers a re-render. */
|
|
8527
|
+
_reconcileIdentifiedDropClips(clips, track) {
|
|
8528
|
+
const engineClips = new Map(track.clips.map((c) => [c.id, c]));
|
|
8529
|
+
let changed = false;
|
|
8530
|
+
const result = [];
|
|
8531
|
+
for (const desc of clips) {
|
|
8532
|
+
if (isDomClip(desc) || desc.clipId === void 0) {
|
|
8533
|
+
result.push(desc);
|
|
8534
|
+
continue;
|
|
8535
|
+
}
|
|
8536
|
+
const clip = engineClips.get(desc.clipId);
|
|
8537
|
+
if (!clip) {
|
|
8538
|
+
changed = true;
|
|
8539
|
+
continue;
|
|
8540
|
+
}
|
|
8541
|
+
const sr = clip.sampleRate ?? this.effectiveSampleRate;
|
|
8542
|
+
const start = clip.startSample / sr;
|
|
8543
|
+
const duration = clip.durationSamples / sr;
|
|
8544
|
+
const offset = clip.offsetSamples / sr;
|
|
8545
|
+
const gain = clip.gain ?? desc.gain;
|
|
8546
|
+
const name = clip.name ?? desc.name;
|
|
8547
|
+
if (desc.start === start && desc.duration === duration && desc.offset === offset && desc.gain === gain && desc.name === name) {
|
|
8548
|
+
result.push(desc);
|
|
8549
|
+
continue;
|
|
8550
|
+
}
|
|
8551
|
+
changed = true;
|
|
8552
|
+
result.push({ ...desc, start, duration, offset, gain, name });
|
|
8553
|
+
}
|
|
8554
|
+
return changed ? result : clips;
|
|
8555
|
+
}
|
|
8360
8556
|
_onClipRemovedFromDom(clipEl) {
|
|
8361
8557
|
const clipId = clipEl.clipId;
|
|
8362
8558
|
for (const [trackId, t] of this._engineTracks.entries()) {
|
|
@@ -8377,6 +8573,9 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8377
8573
|
const clipId = clipDesc.clipId;
|
|
8378
8574
|
let insertedClipId = null;
|
|
8379
8575
|
try {
|
|
8576
|
+
const trackDesc = this._tracks.get(trackId);
|
|
8577
|
+
const kindError = trackDesc ? this._clipKindError(trackDesc.name, trackDesc.kind, false, clipDesc.name || clipDesc.src) : null;
|
|
8578
|
+
if (kindError) throw kindError;
|
|
8380
8579
|
const waveformDataPromise = clipDesc.peaksSrc ? this._resolvePeaks(clipDesc.peaksSrc) : Promise.resolve(null);
|
|
8381
8580
|
const audioPromise = this._fetchAndDecode(clipDesc.src);
|
|
8382
8581
|
const [waveformData, audioBuffer] = await Promise.all([waveformDataPromise, audioPromise]);
|
|
@@ -8602,8 +8801,20 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8602
8801
|
}
|
|
8603
8802
|
const oldClip = t.clips[idx];
|
|
8604
8803
|
const sr = oldClip.sampleRate ?? this.effectiveSampleRate;
|
|
8605
|
-
const isMidiNow = clipEl.midiNotes != null;
|
|
8804
|
+
const isMidiNow = clipEl.midiNotes != null && !clipEl.src;
|
|
8606
8805
|
const wasMidi = oldClip.midiNotes != null;
|
|
8806
|
+
if (isMidiNow && trackKind(t) !== "midi") {
|
|
8807
|
+
const kindError = this._clipKindError(t.name, "audio", true, clipEl.name || clipId);
|
|
8808
|
+
console.warn("[dawcore] _applyClipUpdate: " + kindError?.message);
|
|
8809
|
+
this.dispatchEvent(
|
|
8810
|
+
new CustomEvent("daw-clip-error", {
|
|
8811
|
+
bubbles: true,
|
|
8812
|
+
composed: true,
|
|
8813
|
+
detail: { trackId, clipId, error: kindError }
|
|
8814
|
+
})
|
|
8815
|
+
);
|
|
8816
|
+
return;
|
|
8817
|
+
}
|
|
8607
8818
|
if (isMidiNow || wasMidi) {
|
|
8608
8819
|
const notes = this._validMidiNotes(clipEl.midiNotes ?? []);
|
|
8609
8820
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
@@ -8684,9 +8895,9 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8684
8895
|
if (desc) {
|
|
8685
8896
|
this._tracks = new Map(this._tracks).set(trackId, {
|
|
8686
8897
|
...desc,
|
|
8687
|
-
//
|
|
8688
|
-
//
|
|
8689
|
-
clips: desc.clips.filter((c) =>
|
|
8898
|
+
// Descriptors without an id (file drops, the <daw-track src>
|
|
8899
|
+
// shorthand) are kept — their identity is the descriptor itself.
|
|
8900
|
+
clips: desc.clips.filter((c) => c.clipId !== clipId)
|
|
8690
8901
|
});
|
|
8691
8902
|
}
|
|
8692
8903
|
this._commitTrackChange(trackId, updatedTrack);
|
|
@@ -8739,18 +8950,55 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8739
8950
|
pan: trackEl.pan,
|
|
8740
8951
|
muted: trackEl.muted,
|
|
8741
8952
|
soloed: trackEl.soloed,
|
|
8742
|
-
|
|
8953
|
+
kind: trackEl.kind,
|
|
8954
|
+
renderMode: trackDescriptorRenderMode(trackEl.kind, trackEl.renderMode),
|
|
8743
8955
|
clips
|
|
8744
8956
|
};
|
|
8745
8957
|
}
|
|
8958
|
+
/**
|
|
8959
|
+
* The error for a clip whose kind is not its track's (#756), or null. A clip
|
|
8960
|
+
* with no `src` is a MIDI clip (see _isMidiDescriptor).
|
|
8961
|
+
*/
|
|
8962
|
+
_clipKindError(trackName, kind, clipIsMidi, clipLabel) {
|
|
8963
|
+
if (clipIsMidi === (kind === "midi")) return null;
|
|
8964
|
+
return new Error(
|
|
8965
|
+
clipIsMidi ? 'clip "' + clipLabel + '" is a MIDI clip (no src) on audio track "' + trackName + `". A track holds one kind of clip: set kind="midi" on the <daw-track> (or kind: 'midi' in addTrack) for a track of MIDI clips.` : 'clip "' + clipLabel + '" is an audio clip on MIDI track "' + trackName + '". A track holds one kind of clip: put the clip on an audio track.'
|
|
8966
|
+
);
|
|
8967
|
+
}
|
|
8746
8968
|
// --- Audio Loading ---
|
|
8747
8969
|
async _loadTrack(trackId, descriptor) {
|
|
8748
8970
|
this._loadingTracks.add(trackId);
|
|
8749
8971
|
const sppAtLoadStart = this._samplesPerPixel;
|
|
8750
8972
|
try {
|
|
8751
8973
|
const clips = [];
|
|
8974
|
+
let refusedMidiClips = 0;
|
|
8752
8975
|
for (const clipDesc of descriptor.clips) {
|
|
8753
|
-
|
|
8976
|
+
const clipIsMidi = this._isMidiDescriptor(clipDesc);
|
|
8977
|
+
const kindError = this._clipKindError(
|
|
8978
|
+
descriptor.name,
|
|
8979
|
+
descriptor.kind,
|
|
8980
|
+
clipIsMidi,
|
|
8981
|
+
clipDesc.name || clipDesc.src || (isDomClip(clipDesc) ? clipDesc.clipId : "")
|
|
8982
|
+
);
|
|
8983
|
+
if (kindError) {
|
|
8984
|
+
console.warn("[dawcore] _loadTrack: " + kindError.message);
|
|
8985
|
+
if (this.isConnected) {
|
|
8986
|
+
this.dispatchEvent(
|
|
8987
|
+
new CustomEvent("daw-clip-error", {
|
|
8988
|
+
bubbles: true,
|
|
8989
|
+
composed: true,
|
|
8990
|
+
detail: {
|
|
8991
|
+
trackId,
|
|
8992
|
+
clipId: isDomClip(clipDesc) ? clipDesc.clipId : "",
|
|
8993
|
+
error: kindError
|
|
8994
|
+
}
|
|
8995
|
+
})
|
|
8996
|
+
);
|
|
8997
|
+
}
|
|
8998
|
+
if (clipIsMidi) refusedMidiClips++;
|
|
8999
|
+
continue;
|
|
9000
|
+
}
|
|
9001
|
+
if (clipIsMidi) {
|
|
8754
9002
|
clips.push(this._buildMidiClip(clipDesc));
|
|
8755
9003
|
continue;
|
|
8756
9004
|
}
|
|
@@ -8788,6 +9036,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8788
9036
|
if (this._tracks.has(trackId)) {
|
|
8789
9037
|
const previewTrack = createTrack({
|
|
8790
9038
|
name: descriptor.name,
|
|
9039
|
+
kind: descriptor.kind,
|
|
8791
9040
|
clips: [clip2],
|
|
8792
9041
|
volume: descriptor.volume,
|
|
8793
9042
|
pan: descriptor.pan,
|
|
@@ -8865,13 +9114,14 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8865
9114
|
}
|
|
8866
9115
|
const track = createTrack({
|
|
8867
9116
|
name: descriptor.name,
|
|
9117
|
+
kind: descriptor.kind,
|
|
8868
9118
|
clips,
|
|
8869
9119
|
volume: descriptor.volume,
|
|
8870
9120
|
pan: descriptor.pan,
|
|
8871
9121
|
muted: descriptor.muted,
|
|
8872
9122
|
soloed: descriptor.soloed
|
|
8873
9123
|
});
|
|
8874
|
-
const requestedClips = descriptor.clips.filter((c) => c.src).length;
|
|
9124
|
+
const requestedClips = descriptor.clips.filter((c) => c.src).length + refusedMidiClips;
|
|
8875
9125
|
if (requestedClips > 0 && clips.length === 0) {
|
|
8876
9126
|
throw new Error(
|
|
8877
9127
|
"all " + requestedClips + " clip(s) failed to load \u2014 see prior daw-clip-error events"
|
|
@@ -9016,10 +9266,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9016
9266
|
this._syncDomToEngineOrder(engineState.tracks);
|
|
9017
9267
|
}
|
|
9018
9268
|
this._effectsManager?.rewireTrackChains();
|
|
9019
|
-
const audioTracks = engineState.tracks.filter((t) =>
|
|
9020
|
-
const desc = this._tracks.get(t.id);
|
|
9021
|
-
return desc?.renderMode !== "piano-roll";
|
|
9022
|
-
});
|
|
9269
|
+
const audioTracks = engineState.tracks.filter((t) => trackKind(t) !== "midi");
|
|
9023
9270
|
syncPeaksForChangedClips(this, audioTracks);
|
|
9024
9271
|
}
|
|
9025
9272
|
if (engineState.bpm !== this._lastAnnotationBpm) {
|
|
@@ -9119,8 +9366,9 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9119
9366
|
if (config.pan !== void 0) trackEl.pan = config.pan;
|
|
9120
9367
|
if (config.muted) trackEl.setAttribute("muted", "");
|
|
9121
9368
|
if (config.soloed) trackEl.setAttribute("soloed", "");
|
|
9122
|
-
const
|
|
9123
|
-
if (
|
|
9369
|
+
const kind = config.kind ?? (config.midi ? "midi" : void 0);
|
|
9370
|
+
if (kind !== void 0) trackEl.setAttribute("kind", kind);
|
|
9371
|
+
if (config.renderMode !== void 0) trackEl.setAttribute("render-mode", config.renderMode);
|
|
9124
9372
|
const clipConfigs = [...config.clips ?? []];
|
|
9125
9373
|
if (config.midi) {
|
|
9126
9374
|
clipConfigs.push({
|
|
@@ -9208,7 +9456,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9208
9456
|
}
|
|
9209
9457
|
const oldDesc = this._tracks.get(trackId);
|
|
9210
9458
|
if (!oldDesc) return;
|
|
9211
|
-
let normalizedRenderMode = partial.renderMode;
|
|
9459
|
+
let normalizedRenderMode = partial.renderMode === void 0 ? void 0 : normalizeRenderMode(partial.renderMode);
|
|
9212
9460
|
if (normalizedRenderMode === "both") {
|
|
9213
9461
|
console.warn(
|
|
9214
9462
|
`[dawcore] render-mode="both" is not yet supported; falling back to 'spectrogram'`
|
|
@@ -9222,7 +9470,9 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9222
9470
|
...partial.pan !== void 0 && { pan: partial.pan },
|
|
9223
9471
|
...partial.muted !== void 0 && { muted: partial.muted },
|
|
9224
9472
|
...partial.soloed !== void 0 && { soloed: partial.soloed },
|
|
9225
|
-
...normalizedRenderMode !== void 0 && {
|
|
9473
|
+
...normalizedRenderMode !== void 0 && {
|
|
9474
|
+
renderMode: trackDescriptorRenderMode(oldDesc.kind, normalizedRenderMode)
|
|
9475
|
+
}
|
|
9226
9476
|
};
|
|
9227
9477
|
this._tracks = new Map(this._tracks).set(trackId, newDesc);
|
|
9228
9478
|
if (this._engine) {
|
|
@@ -9343,6 +9593,22 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9343
9593
|
updatedClips[idx] = updatedClip;
|
|
9344
9594
|
const updatedTrack = { ...t, clips: updatedClips };
|
|
9345
9595
|
this._engineTracks = new Map(this._engineTracks).set(trackId, updatedTrack);
|
|
9596
|
+
const desc = this._tracks.get(trackId);
|
|
9597
|
+
if (desc?.clips.some((c) => c.clipId === clipId)) {
|
|
9598
|
+
this._tracks = new Map(this._tracks).set(trackId, {
|
|
9599
|
+
...desc,
|
|
9600
|
+
clips: desc.clips.map(
|
|
9601
|
+
(c) => c.clipId === clipId ? {
|
|
9602
|
+
...c,
|
|
9603
|
+
start: updatedClip.startSample / sr,
|
|
9604
|
+
duration: updatedClip.durationSamples / sr,
|
|
9605
|
+
offset: updatedClip.offsetSamples / sr,
|
|
9606
|
+
...partial.gain !== void 0 && { gain: partial.gain },
|
|
9607
|
+
...partial.name !== void 0 && { name: partial.name }
|
|
9608
|
+
} : c
|
|
9609
|
+
)
|
|
9610
|
+
});
|
|
9611
|
+
}
|
|
9346
9612
|
this._commitTrackChange(trackId, updatedTrack);
|
|
9347
9613
|
}
|
|
9348
9614
|
_buildClipElement(config) {
|
|
@@ -9595,6 +9861,22 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9595
9861
|
console.warn("[dawcore] startRecording: no stream provided and recordingStream is null");
|
|
9596
9862
|
return;
|
|
9597
9863
|
}
|
|
9864
|
+
const targetId = options?.trackId ?? this._selectedTrackId;
|
|
9865
|
+
const target = targetId ? this._tracks.get(targetId) : void 0;
|
|
9866
|
+
if (targetId && target?.kind === "midi") {
|
|
9867
|
+
const error = new Error(
|
|
9868
|
+
'Cannot record onto MIDI track "' + target.name + '": a recording is audio. Select or create an audio track first.'
|
|
9869
|
+
);
|
|
9870
|
+
console.warn("[dawcore] startRecording: " + error.message);
|
|
9871
|
+
this.dispatchEvent(
|
|
9872
|
+
new CustomEvent("daw-recording-error", {
|
|
9873
|
+
bubbles: true,
|
|
9874
|
+
composed: true,
|
|
9875
|
+
detail: { trackId: targetId, error }
|
|
9876
|
+
})
|
|
9877
|
+
);
|
|
9878
|
+
return;
|
|
9879
|
+
}
|
|
9598
9880
|
await this._recordingController.startRecording(s, options);
|
|
9599
9881
|
}
|
|
9600
9882
|
/** Live-recording preview left/width. Beats mode uses the same tick-space
|
|
@@ -9953,7 +10235,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9953
10235
|
>
|
|
9954
10236
|
<span>${clip.name || t.descriptor?.name || ""}</span>
|
|
9955
10237
|
</div>` : ""}
|
|
9956
|
-
${t.descriptor?.
|
|
10238
|
+
${t.descriptor?.kind === "midi" ? html12`<daw-piano-roll
|
|
9957
10239
|
style="position:absolute;left:0;top:${hdrH}px;"
|
|
9958
10240
|
.midiNotes=${clip.midiNotes ?? []}
|
|
9959
10241
|
.length=${peakData?.length ?? width}
|
|
@@ -9989,6 +10271,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9989
10271
|
.barWidth=${this.barWidth}
|
|
9990
10272
|
.barGap=${this.barGap}
|
|
9991
10273
|
.roundedBars=${this.roundedBars}
|
|
10274
|
+
.gain=${this.gainScaledWaveforms ? clip.gain ?? 1 : 1}
|
|
9992
10275
|
.visibleStart=${this._viewport.visibleStart}
|
|
9993
10276
|
.visibleEnd=${this._viewport.visibleEnd}
|
|
9994
10277
|
.originX=${clipLeft}
|
|
@@ -10196,6 +10479,9 @@ __decorateClass([
|
|
|
10196
10479
|
__decorateClass([
|
|
10197
10480
|
property12({ type: Boolean, attribute: "clip-headers" })
|
|
10198
10481
|
], DawEditorElement.prototype, "clipHeaders", 2);
|
|
10482
|
+
__decorateClass([
|
|
10483
|
+
property12({ type: Boolean, attribute: "gain-scaled-waveforms" })
|
|
10484
|
+
], DawEditorElement.prototype, "gainScaledWaveforms", 2);
|
|
10199
10485
|
__decorateClass([
|
|
10200
10486
|
property12({ type: Number, attribute: "clip-header-height" })
|
|
10201
10487
|
], DawEditorElement.prototype, "clipHeaderHeight", 2);
|
|
@@ -11382,13 +11668,10 @@ export {
|
|
|
11382
11668
|
RecordingController,
|
|
11383
11669
|
SpectrogramController,
|
|
11384
11670
|
TIME_DISPLAY_FORMATS,
|
|
11385
|
-
createEffectInstance,
|
|
11386
11671
|
formatDisplayTime,
|
|
11387
|
-
getEffectDefinitions,
|
|
11388
11672
|
isDomClip,
|
|
11389
11673
|
isTimeDisplayFormat,
|
|
11390
11674
|
parseDisplayTime,
|
|
11391
|
-
registerEffect,
|
|
11392
11675
|
resolveTransportTarget,
|
|
11393
11676
|
splitAtPlayhead,
|
|
11394
11677
|
targetSupports,
|