@dawcore/components 0.0.39-next.19 → 0.0.39-next.20
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/dist/index.d.mts +36 -10
- package/dist/index.d.ts +36 -10
- package/dist/index.js +274 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +212 -42
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
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.14", "@dawcore/transport": "@dawcore/transport@^0.0.16-next.13", "@dawcore/wam": "@dawcore/wam@^0.0.5-next.0", "@waveform-playlist/core": "@waveform-playlist/core@^13.0.0-next.13", "@waveform-playlist/engine": "@waveform-playlist/engine@^14.0.0-next.10", "@waveform-playlist/worklets": "@waveform-playlist/worklets@^13.0.1-next.0", "@waveform-playlist/playout": "@waveform-playlist/playout@^13.0.0-next.13" };
|
|
86
86
|
|
|
87
87
|
// src/elements/daw-annotation.ts
|
|
88
88
|
var import_lit = require("lit");
|
|
@@ -2568,7 +2568,7 @@ DawStopButtonElement = __decorateClass([
|
|
|
2568
2568
|
var import_lit19 = require("lit");
|
|
2569
2569
|
var import_decorators16 = require("lit/decorators.js");
|
|
2570
2570
|
var import_repeat = require("lit/directives/repeat.js");
|
|
2571
|
-
var
|
|
2571
|
+
var import_core23 = require("@waveform-playlist/core");
|
|
2572
2572
|
|
|
2573
2573
|
// src/workers/peaksWorker.ts
|
|
2574
2574
|
var import_waveform_data = __toESM(require("waveform-data"));
|
|
@@ -3312,7 +3312,7 @@ DawRulerElement = __decorateClass([
|
|
|
3312
3312
|
], DawRulerElement);
|
|
3313
3313
|
|
|
3314
3314
|
// src/elements/daw-editor.ts
|
|
3315
|
-
var
|
|
3315
|
+
var import_engine4 = require("@waveform-playlist/engine");
|
|
3316
3316
|
|
|
3317
3317
|
// src/elements/daw-track-controls.ts
|
|
3318
3318
|
var import_lit15 = require("lit");
|
|
@@ -5239,6 +5239,7 @@ var PointerHandler = class {
|
|
|
5239
5239
|
|
|
5240
5240
|
// src/interactions/clip-pointer-handler.ts
|
|
5241
5241
|
var import_core10 = require("@waveform-playlist/core");
|
|
5242
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
5242
5243
|
var import_engine = require("@waveform-playlist/engine");
|
|
5243
5244
|
var ClipPointerHandler = class {
|
|
5244
5245
|
constructor(host) {
|
|
@@ -5256,9 +5257,13 @@ var ClipPointerHandler = class {
|
|
|
5256
5257
|
this._originalOffsetSamples = 0;
|
|
5257
5258
|
this._originalDurationSamples = 0;
|
|
5258
5259
|
this._originalStartSample = 0;
|
|
5259
|
-
// Move: the dragged clip and
|
|
5260
|
+
// Move: the dragged clip and what it collides with on its track, sorted
|
|
5260
5261
|
this._moveClip = null;
|
|
5261
5262
|
this._moveSorted = [];
|
|
5263
|
+
// The pointer's distance from the drag's start at the last move, and the
|
|
5264
|
+
// function that stops following the arrangement (set while dragging).
|
|
5265
|
+
this._lastDeltaPx = 0;
|
|
5266
|
+
this._stopFollowing = null;
|
|
5262
5267
|
this._committing = false;
|
|
5263
5268
|
this._host = host;
|
|
5264
5269
|
}
|
|
@@ -5372,13 +5377,8 @@ var ClipPointerHandler = class {
|
|
|
5372
5377
|
this._originalStartSample = bounds.startSample;
|
|
5373
5378
|
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5374
5379
|
this._originalDurationSamples = bounds.durationSamples;
|
|
5375
|
-
if (this._mode === "move")
|
|
5376
|
-
|
|
5377
|
-
const clip = track?.clips.find((c) => c.id === clipId) ?? null;
|
|
5378
|
-
if (!track || !clip) return false;
|
|
5379
|
-
this._moveClip = clip;
|
|
5380
|
-
this._moveSorted = [...track.clips].sort((a, b) => a.startSample - b.startSample);
|
|
5381
|
-
}
|
|
5380
|
+
if (this._mode === "move" && !this._readMoveNeighbours()) return false;
|
|
5381
|
+
this._stopFollowing = this._host.arrangement.subscribe(() => this._onArrangementChange());
|
|
5382
5382
|
} else {
|
|
5383
5383
|
console.warn("[dawcore] drag start: engine unavailable, the drag will not be applied");
|
|
5384
5384
|
}
|
|
@@ -5396,6 +5396,23 @@ var ClipPointerHandler = class {
|
|
|
5396
5396
|
}
|
|
5397
5397
|
return true;
|
|
5398
5398
|
}
|
|
5399
|
+
/** The dragged clip and its neighbours, read from the arrangement now. False when gone. */
|
|
5400
|
+
_readMoveNeighbours() {
|
|
5401
|
+
const track = this._host.arrangement.getTracks().find((t) => t.id === this._trackId);
|
|
5402
|
+
const clip = track?.clips.find(
|
|
5403
|
+
(c) => c.id === this._clipId && !(0, import_core11.isLoadingClip)(c)
|
|
5404
|
+
);
|
|
5405
|
+
if (!track || !clip) return false;
|
|
5406
|
+
this._moveClip = clip;
|
|
5407
|
+
this._moveSorted = (0, import_engine.trackClipSpans)(track.clips, clip.sampleRate);
|
|
5408
|
+
return true;
|
|
5409
|
+
}
|
|
5410
|
+
/** The tracks changed under the drag: draw it again from the last pointer position. */
|
|
5411
|
+
_onArrangementChange() {
|
|
5412
|
+
if (!this._isDragging || this._committing) return;
|
|
5413
|
+
if (this._mode === "move") this._readMoveNeighbours();
|
|
5414
|
+
this._applyDrag(this._lastDeltaPx);
|
|
5415
|
+
}
|
|
5399
5416
|
/** Processes pointermove events during an active drag. */
|
|
5400
5417
|
onPointerMove(e) {
|
|
5401
5418
|
if (this._mode === null) return;
|
|
@@ -5411,6 +5428,11 @@ var ClipPointerHandler = class {
|
|
|
5411
5428
|
}
|
|
5412
5429
|
}
|
|
5413
5430
|
if (!this._isDragging) return;
|
|
5431
|
+
this._applyDrag(totalDeltaPx);
|
|
5432
|
+
}
|
|
5433
|
+
/** Draw the drag `totalDeltaPx` from its start, constrained as the release will be. */
|
|
5434
|
+
_applyDrag(totalDeltaPx) {
|
|
5435
|
+
this._lastDeltaPx = totalDeltaPx;
|
|
5414
5436
|
const engine = this._host.engine;
|
|
5415
5437
|
if (!engine) return;
|
|
5416
5438
|
if (this._mode === "move") {
|
|
@@ -5597,12 +5619,15 @@ var ClipPointerHandler = class {
|
|
|
5597
5619
|
this._originalStartSample = 0;
|
|
5598
5620
|
this._moveClip = null;
|
|
5599
5621
|
this._moveSorted = [];
|
|
5622
|
+
this._lastDeltaPx = 0;
|
|
5623
|
+
this._stopFollowing?.();
|
|
5624
|
+
this._stopFollowing = null;
|
|
5600
5625
|
}
|
|
5601
5626
|
};
|
|
5602
5627
|
|
|
5603
5628
|
// src/interactions/annotation-drag.ts
|
|
5604
|
-
var import_core11 = require("@waveform-playlist/core");
|
|
5605
5629
|
var import_core12 = require("@waveform-playlist/core");
|
|
5630
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
5606
5631
|
var AnnotationDragHandler = class {
|
|
5607
5632
|
constructor(host) {
|
|
5608
5633
|
this._drag = null;
|
|
@@ -5668,7 +5693,7 @@ var AnnotationDragHandler = class {
|
|
|
5668
5693
|
) - drag.edgeTime;
|
|
5669
5694
|
let newTick = drag.edgeTime + deltaTicks;
|
|
5670
5695
|
if (this._host.scaleMode === "beats" && this._host.snapTo !== "off") {
|
|
5671
|
-
newTick = (0,
|
|
5696
|
+
newTick = (0, import_core12.snapTickToGrid)(
|
|
5672
5697
|
newTick,
|
|
5673
5698
|
this._host.snapTo,
|
|
5674
5699
|
this._host._meterEntries,
|
|
@@ -5676,7 +5701,7 @@ var AnnotationDragHandler = class {
|
|
|
5676
5701
|
);
|
|
5677
5702
|
}
|
|
5678
5703
|
const clamp = this._host._annotationClampDuration;
|
|
5679
|
-
const updated2 = (0,
|
|
5704
|
+
const updated2 = (0, import_core12.updateAnnotationBoundaries)(
|
|
5680
5705
|
{
|
|
5681
5706
|
annotationIndex: index,
|
|
5682
5707
|
newTime: newTick,
|
|
@@ -5686,15 +5711,15 @@ var AnnotationDragHandler = class {
|
|
|
5686
5711
|
linkEndpoints: drag.track.linkEndpoints
|
|
5687
5712
|
},
|
|
5688
5713
|
{
|
|
5689
|
-
linkThreshold:
|
|
5690
|
-
minDuration: (0,
|
|
5714
|
+
linkThreshold: import_core13.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
5715
|
+
minDuration: (0, import_core13.annotationMinDurationTicks)(this._host.ppqn)
|
|
5691
5716
|
}
|
|
5692
5717
|
);
|
|
5693
5718
|
applyTickBoundaryResults(elements, updated2, (t) => this._host._ticksToSeconds(t));
|
|
5694
5719
|
return;
|
|
5695
5720
|
}
|
|
5696
5721
|
const deltaSeconds = deltaPx * this._host._renderSpp / this._host.effectiveSampleRate;
|
|
5697
|
-
const updated = (0,
|
|
5722
|
+
const updated = (0, import_core12.updateAnnotationBoundaries)({
|
|
5698
5723
|
annotationIndex: index,
|
|
5699
5724
|
newTime: drag.edgeTime + deltaSeconds,
|
|
5700
5725
|
isDraggingStart: drag.edge === "start",
|
|
@@ -6229,7 +6254,7 @@ function stringifyReason(reason) {
|
|
|
6229
6254
|
}
|
|
6230
6255
|
|
|
6231
6256
|
// src/interactions/recording-clip.ts
|
|
6232
|
-
var
|
|
6257
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
6233
6258
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
6234
6259
|
let trimmedBuf = buf;
|
|
6235
6260
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -6244,7 +6269,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6244
6269
|
}
|
|
6245
6270
|
trimmedBuf = trimmed;
|
|
6246
6271
|
}
|
|
6247
|
-
const clip = (0,
|
|
6272
|
+
const clip = (0, import_core14.createClip)({
|
|
6248
6273
|
audioBuffer: trimmedBuf,
|
|
6249
6274
|
startSample,
|
|
6250
6275
|
durationSamples: durSamples,
|
|
@@ -6264,16 +6289,41 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6264
6289
|
return;
|
|
6265
6290
|
}
|
|
6266
6291
|
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6292
|
+
try {
|
|
6293
|
+
host._arrangement.updateTrack(trackId, (current) => ({
|
|
6294
|
+
...current,
|
|
6295
|
+
clips: [
|
|
6296
|
+
...(0, import_core14.carveTrackClipRange)(
|
|
6297
|
+
current.clips,
|
|
6298
|
+
startSample,
|
|
6299
|
+
startSample + durSamples,
|
|
6300
|
+
clip.sampleRate
|
|
6301
|
+
),
|
|
6302
|
+
clip
|
|
6303
|
+
]
|
|
6304
|
+
}));
|
|
6305
|
+
} catch (refusal) {
|
|
6306
|
+
forgetClip(host, clip.id);
|
|
6307
|
+
const cause = refusal instanceof Error ? refusal : new Error(String(refusal));
|
|
6308
|
+
const error = Object.assign(
|
|
6309
|
+
new Error(
|
|
6310
|
+
'Recording completed but the take could not be saved on track "' + trackId + '": ' + cause.message
|
|
6273
6311
|
),
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6312
|
+
{ cause }
|
|
6313
|
+
);
|
|
6314
|
+
console.warn("[dawcore] " + error.message);
|
|
6315
|
+
if (host.isConnected) {
|
|
6316
|
+
host.dispatchEvent(
|
|
6317
|
+
new CustomEvent("daw-recording-error", {
|
|
6318
|
+
bubbles: true,
|
|
6319
|
+
composed: true,
|
|
6320
|
+
detail: { trackId, error }
|
|
6321
|
+
})
|
|
6322
|
+
);
|
|
6323
|
+
}
|
|
6324
|
+
return;
|
|
6325
|
+
}
|
|
6326
|
+
host._raiseZoomFloor(host._peakPipeline.getCachedScale(trimmedBuf));
|
|
6277
6327
|
if (host.isConnected) {
|
|
6278
6328
|
host.dispatchEvent(
|
|
6279
6329
|
new CustomEvent("daw-recording-clip-add", {
|
|
@@ -6285,10 +6335,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6285
6335
|
}
|
|
6286
6336
|
}).catch((err) => {
|
|
6287
6337
|
console.warn("[dawcore] Failed to generate peaks for recorded clip: " + String(err));
|
|
6288
|
-
|
|
6289
|
-
next.delete(clip.id);
|
|
6290
|
-
host._clipBuffers = next;
|
|
6291
|
-
host._clipOffsets.delete(clip.id);
|
|
6338
|
+
forgetClip(host, clip.id);
|
|
6292
6339
|
if (host.isConnected) {
|
|
6293
6340
|
host.dispatchEvent(
|
|
6294
6341
|
new CustomEvent("daw-error", {
|
|
@@ -6300,6 +6347,17 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6300
6347
|
}
|
|
6301
6348
|
});
|
|
6302
6349
|
}
|
|
6350
|
+
function forgetClip(host, clipId) {
|
|
6351
|
+
const next = new Map(host._clipBuffers);
|
|
6352
|
+
next.delete(clipId);
|
|
6353
|
+
host._clipBuffers = next;
|
|
6354
|
+
host._clipOffsets.delete(clipId);
|
|
6355
|
+
if (host._peaksData.has(clipId)) {
|
|
6356
|
+
const peaks = new Map(host._peaksData);
|
|
6357
|
+
peaks.delete(clipId);
|
|
6358
|
+
host._peaksData = peaks;
|
|
6359
|
+
}
|
|
6360
|
+
}
|
|
6303
6361
|
|
|
6304
6362
|
// src/interactions/split-handler.ts
|
|
6305
6363
|
function splitAtPlayhead(host) {
|
|
@@ -6467,7 +6525,8 @@ function findAudioBufferForClip(host, clip, track) {
|
|
|
6467
6525
|
}
|
|
6468
6526
|
|
|
6469
6527
|
// src/interactions/track-entry.ts
|
|
6470
|
-
var
|
|
6528
|
+
var import_core15 = require("@waveform-playlist/core");
|
|
6529
|
+
var import_engine2 = require("@waveform-playlist/engine");
|
|
6471
6530
|
function validMidiNotes(notes) {
|
|
6472
6531
|
return notes.filter((n) => {
|
|
6473
6532
|
const ok = Number.isFinite(n.time) && n.time >= 0 && Number.isFinite(n.duration) && n.duration > 0 && Number.isInteger(n.midi) && n.midi >= 0 && n.midi <= 127 && Number.isFinite(n.velocity) && n.velocity >= 0 && n.velocity <= 1;
|
|
@@ -6503,8 +6562,8 @@ function buildMidiClip(clipDesc, sampleRate) {
|
|
|
6503
6562
|
const sourceDurationSamples = Math.ceil(
|
|
6504
6563
|
Math.max(noteSpanSeconds, clipDesc.duration, 1) * sampleRate
|
|
6505
6564
|
);
|
|
6506
|
-
const requestedDurationSamples = clipDesc.duration > 0 ?
|
|
6507
|
-
const clip = (0,
|
|
6565
|
+
const requestedDurationSamples = clipDesc.duration > 0 ? (0, import_core15.durationSamplesFromSeconds)(clipDesc.start, clipDesc.duration, sampleRate) : sourceDurationSamples;
|
|
6566
|
+
const clip = (0, import_core15.createClip)({
|
|
6508
6567
|
startSample: Math.round(clipDesc.start * sampleRate),
|
|
6509
6568
|
durationSamples: requestedDurationSamples,
|
|
6510
6569
|
offsetSamples: Math.round(clipDesc.offset * sampleRate),
|
|
@@ -6534,8 +6593,20 @@ function withClipId(clipDesc) {
|
|
|
6534
6593
|
if (clipDesc.clipId) return clipDesc;
|
|
6535
6594
|
return { ...clipDesc, clipId: crypto.randomUUID() };
|
|
6536
6595
|
}
|
|
6537
|
-
function
|
|
6596
|
+
function clipOverlapError(trackName, clips, clip, clipLabel) {
|
|
6597
|
+
const overlap = (0, import_engine2.findClipOverlap)([...clips, clip]);
|
|
6598
|
+
if (!overlap) return null;
|
|
6599
|
+
const other = overlap.first === clip.id ? overlap.second : overlap.first;
|
|
6600
|
+
return new Error(
|
|
6601
|
+
'clip "' + clipLabel + '" overlaps clip "' + other + '" on track "' + trackName + '". Clips on a track cannot overlap: give it a start after the other ends.'
|
|
6602
|
+
);
|
|
6603
|
+
}
|
|
6604
|
+
function isMidiClip(clip) {
|
|
6605
|
+
return "midiNotes" in clip && clip.midiNotes != null;
|
|
6606
|
+
}
|
|
6607
|
+
function buildArrangementTrack(trackId, descriptor, mix, sampleRate, heldOf = () => void 0) {
|
|
6538
6608
|
const clips = [];
|
|
6609
|
+
const placed = [];
|
|
6539
6610
|
const refused = [];
|
|
6540
6611
|
let changed = false;
|
|
6541
6612
|
const descClips = descriptor.clips.map((clipDesc) => {
|
|
@@ -6546,15 +6617,31 @@ function buildArrangementTrack(trackId, descriptor, mix, sampleRate) {
|
|
|
6546
6617
|
const sourceName = typeof source === "string" ? source : source instanceof File ? source.name : "";
|
|
6547
6618
|
const label = identified.name || sourceName || identified.clipId;
|
|
6548
6619
|
const kindError = clipKindError(descriptor.name, descriptor.kind, isMidi, label);
|
|
6549
|
-
if (kindError)
|
|
6550
|
-
|
|
6620
|
+
if (kindError) {
|
|
6621
|
+
refused.push({ clipId: identified.clipId, error: kindError });
|
|
6622
|
+
return identified;
|
|
6623
|
+
}
|
|
6624
|
+
const clip = isMidi ? buildMidiClip(identified, sampleRate) : buildLoadingClip(identified);
|
|
6625
|
+
const held = heldOf(identified.clipId);
|
|
6626
|
+
if (held && isMidiClip(held) !== (descriptor.kind === "midi")) {
|
|
6627
|
+
clips.push(clip);
|
|
6628
|
+
return identified;
|
|
6629
|
+
}
|
|
6630
|
+
const where = held ?? clip;
|
|
6631
|
+
const overlapError = clipOverlapError(descriptor.name, placed, where, label);
|
|
6632
|
+
if (overlapError) {
|
|
6633
|
+
refused.push({ clipId: identified.clipId, error: overlapError });
|
|
6634
|
+
} else {
|
|
6635
|
+
clips.push(clip);
|
|
6636
|
+
placed.push(where);
|
|
6637
|
+
}
|
|
6551
6638
|
return identified;
|
|
6552
6639
|
});
|
|
6553
6640
|
const { panLaw, ...fields } = mix;
|
|
6554
6641
|
const base = {
|
|
6555
|
-
...(0,
|
|
6642
|
+
...(0, import_core15.createTrack)({ name: descriptor.name, kind: descriptor.kind, clips: [], ...fields }),
|
|
6556
6643
|
// The law the track enters with (#684); 'auto' is the arrangement's default.
|
|
6557
|
-
...(0,
|
|
6644
|
+
...(0, import_core15.isDecidedPanLaw)(panLaw) && { panLaw }
|
|
6558
6645
|
};
|
|
6559
6646
|
const track = { ...base, id: trackId, clips };
|
|
6560
6647
|
return { track, descriptor: changed ? { ...descriptor, clips: descClips } : descriptor, refused };
|
|
@@ -6569,7 +6656,7 @@ function entryIndex(trackEls, trackId, arrangementIds) {
|
|
|
6569
6656
|
}
|
|
6570
6657
|
|
|
6571
6658
|
// src/interactions/load-announcer.ts
|
|
6572
|
-
var
|
|
6659
|
+
var import_core16 = require("@waveform-playlist/core");
|
|
6573
6660
|
var LoadAnnouncer = class {
|
|
6574
6661
|
constructor(_dispatch) {
|
|
6575
6662
|
this._dispatch = _dispatch;
|
|
@@ -6623,7 +6710,7 @@ var LoadAnnouncer = class {
|
|
|
6623
6710
|
let loaded = 0;
|
|
6624
6711
|
let firstError = null;
|
|
6625
6712
|
for (const clip of track.clips) {
|
|
6626
|
-
if (!(0,
|
|
6713
|
+
if (!(0, import_core16.isLoadingClip)(clip)) {
|
|
6627
6714
|
loaded++;
|
|
6628
6715
|
if (this._loadingClips.delete(clip.id)) {
|
|
6629
6716
|
this._clipErrors.delete(clip.id);
|
|
@@ -6671,7 +6758,7 @@ var LoadAnnouncer = class {
|
|
|
6671
6758
|
};
|
|
6672
6759
|
|
|
6673
6760
|
// src/interactions/arrangement-view.ts
|
|
6674
|
-
var
|
|
6761
|
+
var import_core17 = require("@waveform-playlist/core");
|
|
6675
6762
|
var views = /* @__PURE__ */ new WeakMap();
|
|
6676
6763
|
function sameMix(a, b) {
|
|
6677
6764
|
return a.volume === b.volume && a.pan === b.pan && a.muted === b.muted && a.soloed === b.soloed && a.panLaw === b.panLaw;
|
|
@@ -6681,7 +6768,7 @@ function loadedTrack(track, mix, recording) {
|
|
|
6681
6768
|
if (cached && cached.recording === recording && sameMix(cached.mix, mix)) return cached.view;
|
|
6682
6769
|
const view = {
|
|
6683
6770
|
...track,
|
|
6684
|
-
clips: track.clips.filter((c) => !(0,
|
|
6771
|
+
clips: track.clips.filter((c) => !(0, import_core17.isLoadingClip)(c)),
|
|
6685
6772
|
volume: mix.volume,
|
|
6686
6773
|
pan: mix.pan,
|
|
6687
6774
|
muted: mix.muted || recording,
|
|
@@ -6698,7 +6785,7 @@ function mixOf(arrangement, trackId) {
|
|
|
6698
6785
|
return arrangement.recordingTrackIds.has(trackId) ? { ...mix, muted: true } : mix;
|
|
6699
6786
|
}
|
|
6700
6787
|
function clipSeconds(clip, fallbackSampleRate) {
|
|
6701
|
-
if ((0,
|
|
6788
|
+
if ((0, import_core17.isLoadingClip)(clip)) {
|
|
6702
6789
|
return { start: clip.start ?? 0, duration: clip.duration ?? 0, offset: clip.offset ?? 0 };
|
|
6703
6790
|
}
|
|
6704
6791
|
const sr = clip.sampleRate ?? fallbackSampleRate;
|
|
@@ -6710,10 +6797,10 @@ function clipSeconds(clip, fallbackSampleRate) {
|
|
|
6710
6797
|
}
|
|
6711
6798
|
|
|
6712
6799
|
// src/interactions/arrangement-swap.ts
|
|
6713
|
-
var
|
|
6800
|
+
var import_engine3 = require("@waveform-playlist/engine");
|
|
6714
6801
|
function normalizeHandedIn(value, own) {
|
|
6715
6802
|
if (value === null || value === void 0 || value === own) return null;
|
|
6716
|
-
if (!(0,
|
|
6803
|
+
if (!(0, import_engine3.isArrangement)(value)) {
|
|
6717
6804
|
throw new TypeError(
|
|
6718
6805
|
"[dawcore] editor.arrangement must be an arrangement made by createArrangement() (@waveform-playlist/engine), or null for the editor's own."
|
|
6719
6806
|
);
|
|
@@ -6739,10 +6826,10 @@ function swapArrangement(host, next) {
|
|
|
6739
6826
|
}
|
|
6740
6827
|
|
|
6741
6828
|
// src/interactions/drag-watch.ts
|
|
6742
|
-
var
|
|
6829
|
+
var import_core18 = require("@waveform-playlist/core");
|
|
6743
6830
|
function clipDragChanged(arrangement, drag) {
|
|
6744
6831
|
const clip = arrangement.getTracks().find((t) => t.id === drag.trackId)?.clips.find((c) => c.id === drag.clipId);
|
|
6745
|
-
if (!clip || (0,
|
|
6832
|
+
if (!clip || (0, import_core18.isLoadingClip)(clip)) return true;
|
|
6746
6833
|
return clip.startSample !== drag.startSample || clip.durationSamples !== drag.durationSamples || clip.offsetSamples !== drag.offsetSamples;
|
|
6747
6834
|
}
|
|
6748
6835
|
function trackDragChanged(arrangement, drag) {
|
|
@@ -6992,10 +7079,10 @@ function loadFaustModule(feature) {
|
|
|
6992
7079
|
}
|
|
6993
7080
|
|
|
6994
7081
|
// src/effects/effects-manager.ts
|
|
6995
|
-
var
|
|
7082
|
+
var import_core20 = require("@waveform-playlist/core");
|
|
6996
7083
|
|
|
6997
7084
|
// src/effects/effect-registry.ts
|
|
6998
|
-
var
|
|
7085
|
+
var import_core19 = require("@waveform-playlist/core");
|
|
6999
7086
|
var MAX_DELAY_SECONDS = 10;
|
|
7000
7087
|
function singleNode(node, applyParams) {
|
|
7001
7088
|
return { input: node, output: node, applyParams };
|
|
@@ -7071,8 +7158,8 @@ function biquadDefinition(spec) {
|
|
|
7071
7158
|
};
|
|
7072
7159
|
}
|
|
7073
7160
|
function registerBuiltIn(type, definition) {
|
|
7074
|
-
if (!(0,
|
|
7075
|
-
(0,
|
|
7161
|
+
if (!(0, import_core19.getEffectDefinitions)().has(type)) {
|
|
7162
|
+
(0, import_core19.registerEffect)(type, { ...definition, builtIn: true });
|
|
7076
7163
|
}
|
|
7077
7164
|
}
|
|
7078
7165
|
function registerBuiltIns() {
|
|
@@ -7227,7 +7314,7 @@ var EffectsManager = class {
|
|
|
7227
7314
|
/** Run a registered effect's async `prepare` hook on the adapter's
|
|
7228
7315
|
* context, so the synchronous addEffect() can create it. */
|
|
7229
7316
|
async prepareEffect(type) {
|
|
7230
|
-
await (0,
|
|
7317
|
+
await (0, import_core20.prepareEffect)(type, this._requireWiring().audioContext);
|
|
7231
7318
|
}
|
|
7232
7319
|
// --- Track chains ---
|
|
7233
7320
|
addTrackEffect(trackId, target, type, params) {
|
|
@@ -7432,7 +7519,7 @@ var EffectsManager = class {
|
|
|
7432
7519
|
this._runOp(chain, target, "setParams", effectId, { [paramId]: value });
|
|
7433
7520
|
};
|
|
7434
7521
|
if (entry.kind === "native") {
|
|
7435
|
-
const definition = (0,
|
|
7522
|
+
const definition = (0, import_core20.getEffectDefinitions)().get(entry.type);
|
|
7436
7523
|
if (!definition) {
|
|
7437
7524
|
throw new Error(
|
|
7438
7525
|
PREFIX2 + 'openEffectGui: no registry definition for effect type "' + entry.type + '"'
|
|
@@ -7491,7 +7578,7 @@ var EffectsManager = class {
|
|
|
7491
7578
|
}
|
|
7492
7579
|
_addToChain(chain, target, type, params) {
|
|
7493
7580
|
const audioContext = this._requireWiring().audioContext;
|
|
7494
|
-
const created = (0,
|
|
7581
|
+
const created = (0, import_core20.createEffectInstance)(type, audioContext, params);
|
|
7495
7582
|
const effectId = chain.add({
|
|
7496
7583
|
kind: "native",
|
|
7497
7584
|
type,
|
|
@@ -7663,8 +7750,8 @@ var EffectsManager = class {
|
|
|
7663
7750
|
if (entry.kind === "native") {
|
|
7664
7751
|
try {
|
|
7665
7752
|
const liveContext = this._requireWiring().audioContext;
|
|
7666
|
-
if ((0,
|
|
7667
|
-
await (0,
|
|
7753
|
+
if ((0, import_core20.needsPrepare)(entry.type, liveContext)) {
|
|
7754
|
+
await (0, import_core20.ensureEffectPrepared)(entry.type, liveContext);
|
|
7668
7755
|
if (superseded() || chain.disposed) return;
|
|
7669
7756
|
}
|
|
7670
7757
|
const id = this._addToChain(chain, target, entry.type, entry.params);
|
|
@@ -7839,8 +7926,8 @@ function toWamParameterMap(params) {
|
|
|
7839
7926
|
}
|
|
7840
7927
|
|
|
7841
7928
|
// src/interactions/export-audio.ts
|
|
7842
|
-
var import_core20 = require("@waveform-playlist/core");
|
|
7843
7929
|
var import_core21 = require("@waveform-playlist/core");
|
|
7930
|
+
var import_core22 = require("@waveform-playlist/core");
|
|
7844
7931
|
var PREFIX3 = "[waveform-playlist] ";
|
|
7845
7932
|
async function exportAudioImpl(host, options = {}) {
|
|
7846
7933
|
const sampleRate = options.sampleRate ?? host.effectiveSampleRate;
|
|
@@ -7875,7 +7962,7 @@ async function exportAudioImpl(host, options = {}) {
|
|
|
7875
7962
|
cleanups.push(chain.dispose);
|
|
7876
7963
|
const volume = ctx.createGain();
|
|
7877
7964
|
volume.gain.value = track.volume;
|
|
7878
|
-
const panStage = (0,
|
|
7965
|
+
const panStage = (0, import_core21.createPanStage)(ctx, track.pan, (0, import_core21.trackPanLaw)(track));
|
|
7879
7966
|
cleanups.push(panStage.dispose);
|
|
7880
7967
|
chain.output.connect(volume);
|
|
7881
7968
|
volume.connect(panStage.input);
|
|
@@ -7957,12 +8044,12 @@ async function buildOfflineChain(ctx, entries) {
|
|
|
7957
8044
|
continue;
|
|
7958
8045
|
}
|
|
7959
8046
|
if (entry.kind === "native") {
|
|
7960
|
-
const definition = (0,
|
|
8047
|
+
const definition = (0, import_core22.getEffectDefinitions)().get(entry.type);
|
|
7961
8048
|
if (entry.bypassed && definition && !definition.wetParam) {
|
|
7962
8049
|
continue;
|
|
7963
8050
|
}
|
|
7964
|
-
await (0,
|
|
7965
|
-
const created = (0,
|
|
8051
|
+
await (0, import_core22.ensureEffectPrepared)(entry.type, ctx);
|
|
8052
|
+
const created = (0, import_core22.createEffectInstance)(entry.type, ctx, entry.params);
|
|
7966
8053
|
if (entry.bypassed && created.wetParam) {
|
|
7967
8054
|
created.instance.applyParams({ [created.wetParam]: 0 });
|
|
7968
8055
|
}
|
|
@@ -8300,7 +8387,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8300
8387
|
* clips, the mix, the undo history and loading of what the `<daw-track>`
|
|
8301
8388
|
* children declare. Made with the editor, kept across a disconnect.
|
|
8302
8389
|
*/
|
|
8303
|
-
this._ownArrangement = (0,
|
|
8390
|
+
this._ownArrangement = (0, import_engine4.createArrangement)();
|
|
8304
8391
|
/** An arrangement the app handed in (`editor.arrangement`), played alone; null: the own one. */
|
|
8305
8392
|
this._handedIn = null;
|
|
8306
8393
|
/** Sends the load events, read from the arrangement played (#848; a new one per swap). */
|
|
@@ -8856,7 +8943,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8856
8943
|
this.requestUpdate();
|
|
8857
8944
|
});
|
|
8858
8945
|
let tracksVersion = arrangement.tracksVersion;
|
|
8859
|
-
const stopTracks = arrangement.subscribe(() => {
|
|
8946
|
+
const stopTracks = arrangement.subscribe((info) => {
|
|
8947
|
+
if (info.removedClips) this._reportRemovedOnArrival(info.removedClips);
|
|
8860
8948
|
this._watchDrags();
|
|
8861
8949
|
if (arrangement.tracksVersion === tracksVersion) return;
|
|
8862
8950
|
tracksVersion = arrangement.tracksVersion;
|
|
@@ -8867,6 +8955,23 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
8867
8955
|
stopTracks();
|
|
8868
8956
|
};
|
|
8869
8957
|
}
|
|
8958
|
+
/**
|
|
8959
|
+
* The clips the arrangement took out by itself because nothing of their
|
|
8960
|
+
* audio was left after their offset (#859, maintainer's choice "remove"),
|
|
8961
|
+
* as its change says (`removedClips`), reported with `daw-clip-error`
|
|
8962
|
+
* (maintainer, "a"). Their `<daw-clip>` stays on the page.
|
|
8963
|
+
*/
|
|
8964
|
+
_reportRemovedOnArrival(removed) {
|
|
8965
|
+
for (const { trackId, clipId } of removed) {
|
|
8966
|
+
this.dispatchEvent(
|
|
8967
|
+
new CustomEvent("daw-clip-error", {
|
|
8968
|
+
bubbles: true,
|
|
8969
|
+
composed: true,
|
|
8970
|
+
detail: { trackId, clipId, error: removedOnArrival(clipId) }
|
|
8971
|
+
})
|
|
8972
|
+
);
|
|
8973
|
+
}
|
|
8974
|
+
}
|
|
8870
8975
|
/**
|
|
8871
8976
|
* A change to the arrangement while a drag is in progress came from
|
|
8872
8977
|
* elsewhere (a drag writes nothing until its release): cancel the drag
|
|
@@ -9164,7 +9269,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9164
9269
|
_loadedClip(trackId, clipId) {
|
|
9165
9270
|
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
9166
9271
|
const clip = track?.clips.find((c) => c.id === clipId);
|
|
9167
|
-
return clip && !(0,
|
|
9272
|
+
return clip && !(0, import_core23.isLoadingClip)(clip) ? clip : void 0;
|
|
9168
9273
|
}
|
|
9169
9274
|
get effectiveSampleRate() {
|
|
9170
9275
|
return this.sampleRate;
|
|
@@ -9265,7 +9370,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9265
9370
|
const clips = track.clips.map((clip) => {
|
|
9266
9371
|
const el = clipEls.get(clip.id);
|
|
9267
9372
|
const times = clipSeconds(clip, sr);
|
|
9268
|
-
const midi = (0,
|
|
9373
|
+
const midi = (0, import_core23.isLoadingClip)(clip) ? null : clip;
|
|
9269
9374
|
const base = {
|
|
9270
9375
|
src: typeof clip.src === "string" ? clip.src : "",
|
|
9271
9376
|
peaksSrc: extras?.peaksSrc.get(clip.id) ?? this._takenPeaksSrc(clip.id) ?? "",
|
|
@@ -9285,7 +9390,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9285
9390
|
trackId: track.id,
|
|
9286
9391
|
name: track.name ?? "",
|
|
9287
9392
|
src: extras?.src ?? "",
|
|
9288
|
-
kind: (0,
|
|
9393
|
+
kind: (0, import_core23.trackKind)(track),
|
|
9289
9394
|
renderMode: this._renderModeOf(track.id),
|
|
9290
9395
|
spectrogramConfig: extras?.spectrogramConfig ?? null,
|
|
9291
9396
|
clips,
|
|
@@ -9304,7 +9409,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9304
9409
|
_defaultExtras(trackId) {
|
|
9305
9410
|
const track = this._arrangementOf(trackId).getTracks().find((t) => t.id === trackId);
|
|
9306
9411
|
if (!track) return null;
|
|
9307
|
-
const kind = (0,
|
|
9412
|
+
const kind = (0, import_core23.trackKind)(track);
|
|
9308
9413
|
return {
|
|
9309
9414
|
kind,
|
|
9310
9415
|
renderMode: trackDescriptorRenderMode(kind, "waveform"),
|
|
@@ -9317,7 +9422,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9317
9422
|
const extras = this._extras.get(trackId);
|
|
9318
9423
|
if (extras) return extras.renderMode;
|
|
9319
9424
|
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
9320
|
-
return trackDescriptorRenderMode(track ? (0,
|
|
9425
|
+
return trackDescriptorRenderMode(track ? (0, import_core23.trackKind)(track) : "audio", "waveform");
|
|
9321
9426
|
}
|
|
9322
9427
|
/**
|
|
9323
9428
|
* A track's mix, from its one owner, the arrangement (#843), as the engine
|
|
@@ -9359,7 +9464,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9359
9464
|
_clipValues(trackId, clipId) {
|
|
9360
9465
|
const clip = this._arrangement.getTracks().find((t) => t.id === this._clipHolderId(trackId, clipId))?.clips.find((c) => c.id === clipId);
|
|
9361
9466
|
if (!clip) return null;
|
|
9362
|
-
const midi = (0,
|
|
9467
|
+
const midi = (0, import_core23.isLoadingClip)(clip) ? null : clip;
|
|
9363
9468
|
return {
|
|
9364
9469
|
...clipSeconds(clip, this.effectiveSampleRate),
|
|
9365
9470
|
gain: clip.gain ?? 1,
|
|
@@ -9378,7 +9483,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9378
9483
|
_taskGesture(trackId) {
|
|
9379
9484
|
let id = this._taskGestures.get(trackId);
|
|
9380
9485
|
if (!id) {
|
|
9381
|
-
id = (0,
|
|
9486
|
+
id = (0, import_core23.createMixerGesture)().id;
|
|
9382
9487
|
this._taskGestures.set(trackId, id);
|
|
9383
9488
|
if (this._taskGestures.size === 1) queueMicrotask(() => this._taskGestures.clear());
|
|
9384
9489
|
}
|
|
@@ -9393,20 +9498,36 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9393
9498
|
const src = clip && typeof clip.src === "string" ? clip.src : "";
|
|
9394
9499
|
this._applyClipUpdate(holderId, clipId, { ...current, ...partial, src });
|
|
9395
9500
|
}
|
|
9501
|
+
/** The clip of that id another track of the arrangement holds (a `<daw-clip>` the page moved here), if any. */
|
|
9502
|
+
_heldElsewhere(trackId, clipId) {
|
|
9503
|
+
for (const t of this._arrangement.getTracks()) {
|
|
9504
|
+
if (t.id === trackId) continue;
|
|
9505
|
+
const held = t.clips.find((c) => c.id === clipId);
|
|
9506
|
+
if (held) return held;
|
|
9507
|
+
}
|
|
9508
|
+
return void 0;
|
|
9509
|
+
}
|
|
9396
9510
|
/**
|
|
9397
9511
|
* The clips of an entering track that another track of the arrangement
|
|
9398
9512
|
* holds (the page moved their `<daw-clip>` here while the track waited):
|
|
9399
9513
|
* the track takes the held clip as it is, and `from` names what leaves
|
|
9400
|
-
* where. A held clip of the other kind
|
|
9514
|
+
* where. A held clip of the other kind, or one that would overlap a clip of
|
|
9515
|
+
* the entering track (#859), is refused and stays.
|
|
9401
9516
|
*/
|
|
9402
9517
|
_takeOverMovedClips(trackId, track) {
|
|
9403
9518
|
const from = /* @__PURE__ */ new Map();
|
|
9404
9519
|
const movedIds = /* @__PURE__ */ new Set();
|
|
9405
9520
|
const refused = [];
|
|
9406
9521
|
const others = this._arrangement.getTracks().filter((t) => t.id !== trackId);
|
|
9407
|
-
const kind = (0,
|
|
9522
|
+
const kind = (0, import_core23.trackKind)(track);
|
|
9408
9523
|
const clips = [];
|
|
9409
|
-
|
|
9524
|
+
const isMidiOf = (c) => "midiNotes" in c && c.midiNotes != null;
|
|
9525
|
+
const finalOf = (c) => {
|
|
9526
|
+
const held = this._heldElsewhere(trackId, c.id);
|
|
9527
|
+
if (!held) return [c];
|
|
9528
|
+
return isMidiOf(held) === (kind === "midi") ? [held] : [];
|
|
9529
|
+
};
|
|
9530
|
+
for (const [i, clip] of track.clips.entries()) {
|
|
9410
9531
|
const holder = others.find((t) => t.clips.some((c) => c.id === clip.id));
|
|
9411
9532
|
const held = holder?.clips.find((c) => c.id === clip.id);
|
|
9412
9533
|
if (!holder || !held) {
|
|
@@ -9414,7 +9535,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9414
9535
|
continue;
|
|
9415
9536
|
}
|
|
9416
9537
|
const isMidi = "midiNotes" in held && held.midiNotes != null;
|
|
9417
|
-
const
|
|
9538
|
+
const neighbours = [...clips, ...track.clips.slice(i + 1).flatMap(finalOf)];
|
|
9539
|
+
const error = clipKindError(track.name ?? "", kind, isMidi, held.name || held.id) ?? clipOverlapError(track.name ?? "", neighbours, held, held.name || held.id);
|
|
9418
9540
|
if (error) {
|
|
9419
9541
|
refused.push({ clipId: clip.id, error });
|
|
9420
9542
|
continue;
|
|
@@ -9468,7 +9590,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9468
9590
|
/** @internal */
|
|
9469
9591
|
_trackKind(trackId) {
|
|
9470
9592
|
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
9471
|
-
return track ? (0,
|
|
9593
|
+
return track ? (0, import_core23.trackKind)(track) : null;
|
|
9472
9594
|
}
|
|
9473
9595
|
/** @internal */
|
|
9474
9596
|
_trackIndex(trackId) {
|
|
@@ -9493,7 +9615,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9493
9615
|
else if (field === "pan") arrangement.setTrackPan(trackId, value, options);
|
|
9494
9616
|
else if (field === "muted") arrangement.setTrackMute(trackId, value, options);
|
|
9495
9617
|
else if (field === "soloed") arrangement.setTrackSolo(trackId, value, options);
|
|
9496
|
-
else if (field === "panLaw" && (0,
|
|
9618
|
+
else if (field === "panLaw" && (0, import_core23.isDecidedPanLaw)(value)) {
|
|
9497
9619
|
arrangement.setTrackPanLaw(trackId, value, options);
|
|
9498
9620
|
}
|
|
9499
9621
|
}
|
|
@@ -9501,7 +9623,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9501
9623
|
* Change the given mixer fields of a track as ONE undo step (#843): all
|
|
9502
9624
|
* of them carry one fresh gesture id. A field left out is not sent.
|
|
9503
9625
|
*/
|
|
9504
|
-
_writeMixFields(trackId, mix, gesture = (0,
|
|
9626
|
+
_writeMixFields(trackId, mix, gesture = (0, import_core23.createMixerGesture)().id) {
|
|
9505
9627
|
const options = { gesture };
|
|
9506
9628
|
if (mix.volume !== void 0) this._writeMix(trackId, "volume", mix.volume, options);
|
|
9507
9629
|
if (mix.pan !== void 0) this._writeMix(trackId, "pan", mix.pan, options);
|
|
@@ -9995,11 +10117,33 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
9995
10117
|
* function form, so the track's loading clips stay as they are (#848).
|
|
9996
10118
|
*/
|
|
9997
10119
|
_replaceClip(trackId, clipId, clip) {
|
|
10120
|
+
if (this._refusedForOverlap(trackId, clip)) return;
|
|
9998
10121
|
this._arrangement.updateTrack(trackId, (current) => ({
|
|
9999
10122
|
...current,
|
|
10000
10123
|
clips: current.clips.map((c) => c.id === clipId ? clip : c)
|
|
10001
10124
|
}));
|
|
10002
10125
|
}
|
|
10126
|
+
/**
|
|
10127
|
+
* A clip change that would make `clip` overlap another clip of its track
|
|
10128
|
+
* (#859) changes nothing and is reported with `daw-clip-error`, as a change
|
|
10129
|
+
* that would give it the other kind is. True when refused.
|
|
10130
|
+
*/
|
|
10131
|
+
_refusedForOverlap(trackId, clip) {
|
|
10132
|
+
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
10133
|
+
if (!track) return false;
|
|
10134
|
+
const others = track.clips.filter((c) => c.id !== clip.id);
|
|
10135
|
+
const error = clipOverlapError(track.name ?? "", others, clip, clip.name || clip.id);
|
|
10136
|
+
if (!error) return false;
|
|
10137
|
+
console.warn("[dawcore] " + error.message);
|
|
10138
|
+
this.dispatchEvent(
|
|
10139
|
+
new CustomEvent("daw-clip-error", {
|
|
10140
|
+
bubbles: true,
|
|
10141
|
+
composed: true,
|
|
10142
|
+
detail: { trackId, clipId: clip.id, error }
|
|
10143
|
+
})
|
|
10144
|
+
);
|
|
10145
|
+
return true;
|
|
10146
|
+
}
|
|
10003
10147
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
10004
10148
|
const t = this._arrangement.getTracks().find((track) => track.id === trackId);
|
|
10005
10149
|
if (!t) {
|
|
@@ -10009,7 +10153,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10009
10153
|
const loadedClip = this._loadedClip(trackId, clipId);
|
|
10010
10154
|
if (!loadedClip) {
|
|
10011
10155
|
const loading = t.clips.find((c) => c.id === clipId);
|
|
10012
|
-
if (loading && (0,
|
|
10156
|
+
if (loading && (0, import_core23.isLoadingClip)(loading)) {
|
|
10013
10157
|
this._updateLoadingClip(trackId, loading, clipEl);
|
|
10014
10158
|
return;
|
|
10015
10159
|
}
|
|
@@ -10022,7 +10166,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10022
10166
|
const sr = oldClip.sampleRate ?? this.effectiveSampleRate;
|
|
10023
10167
|
const isMidiNow = clipEl.midiNotes != null && !clipEl.src;
|
|
10024
10168
|
const wasMidi = oldClip.midiNotes != null;
|
|
10025
|
-
if (isMidiNow && (0,
|
|
10169
|
+
if (isMidiNow && (0, import_core23.trackKind)(t) !== "midi") {
|
|
10026
10170
|
const kindError = clipKindError(t.name ?? "", "audio", true, clipEl.name || clipId);
|
|
10027
10171
|
console.warn("[dawcore] _applyClipUpdate: " + kindError?.message);
|
|
10028
10172
|
this.dispatchEvent(
|
|
@@ -10035,13 +10179,13 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10035
10179
|
return;
|
|
10036
10180
|
}
|
|
10037
10181
|
if (isMidiNow || wasMidi) {
|
|
10038
|
-
if (clipEl.midiNotes === oldClip.midiNotes && (clipEl.midiChannel ?? void 0) === oldClip.midiChannel && (clipEl.midiProgram ?? void 0) === oldClip.midiProgram && Math.round(clipEl.start * sr) === oldClip.startSample && Math.round(clipEl.offset * sr) === oldClip.offsetSamples && (clipEl.duration <= 0 ||
|
|
10182
|
+
if (clipEl.midiNotes === oldClip.midiNotes && (clipEl.midiChannel ?? void 0) === oldClip.midiChannel && (clipEl.midiProgram ?? void 0) === oldClip.midiProgram && Math.round(clipEl.start * sr) === oldClip.startSample && Math.round(clipEl.offset * sr) === oldClip.offsetSamples && (clipEl.duration <= 0 || (0, import_core23.durationSamplesFromSeconds)(clipEl.start, clipEl.duration, sr) === oldClip.durationSamples) && clipEl.gain === (oldClip.gain ?? 1) && (clipEl.name || oldClip.name) === oldClip.name) {
|
|
10039
10183
|
return;
|
|
10040
10184
|
}
|
|
10041
10185
|
const notes = validMidiNotes(clipEl.midiNotes ?? []);
|
|
10042
10186
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
10043
10187
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipEl.duration, 1) * sr);
|
|
10044
|
-
const requestedDurationSamples = clipEl.duration > 0 ?
|
|
10188
|
+
const requestedDurationSamples = clipEl.duration > 0 ? (0, import_core23.durationSamplesFromSeconds)(clipEl.start, clipEl.duration, sr) : sourceDurationSamples;
|
|
10045
10189
|
const updatedClip2 = {
|
|
10046
10190
|
...oldClip,
|
|
10047
10191
|
audioBuffer: void 0,
|
|
@@ -10060,7 +10204,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10060
10204
|
return;
|
|
10061
10205
|
}
|
|
10062
10206
|
const newStartSample = Math.round(clipEl.start * sr);
|
|
10063
|
-
const newDurationSamples = clipEl.duration > 0 ?
|
|
10207
|
+
const newDurationSamples = clipEl.duration > 0 ? (0, import_core23.durationSamplesFromSeconds)(clipEl.start, clipEl.duration, sr) : oldClip.durationSamples;
|
|
10064
10208
|
const newOffsetSamples = Math.round(clipEl.offset * sr);
|
|
10065
10209
|
const updatedClip = {
|
|
10066
10210
|
...oldClip,
|
|
@@ -10102,6 +10246,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10102
10246
|
if ((next.start ?? 0) === (clip.start ?? 0) && next.duration === clip.duration && (next.offset ?? 0) === (clip.offset ?? 0) && (next.gain ?? 1) === (clip.gain ?? 1) && next.name === clip.name) {
|
|
10103
10247
|
return;
|
|
10104
10248
|
}
|
|
10249
|
+
if (this._refusedForOverlap(trackId, next)) return;
|
|
10105
10250
|
this._arrangement.updateTrack(trackId, (current) => ({
|
|
10106
10251
|
...current,
|
|
10107
10252
|
clips: current.clips.map((c) => c.id === clip.id ? next : c)
|
|
@@ -10153,7 +10298,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10153
10298
|
this._previewPeaks = nextPreview;
|
|
10154
10299
|
}
|
|
10155
10300
|
this._forgetClip(trackId, clipId);
|
|
10156
|
-
const wasLoading = track.clips.some((c) => c.id === clipId && (0,
|
|
10301
|
+
const wasLoading = track.clips.some((c) => c.id === clipId && (0, import_core23.isLoadingClip)(c));
|
|
10157
10302
|
if (options.undoable === false) arrangement.removeClip(trackId, clipId, { undoable: false });
|
|
10158
10303
|
else
|
|
10159
10304
|
arrangement.updateTrack(trackId, (current) => ({
|
|
@@ -10293,7 +10438,8 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10293
10438
|
trackId,
|
|
10294
10439
|
descriptor,
|
|
10295
10440
|
this._mixOf(trackId),
|
|
10296
|
-
this.effectiveSampleRate
|
|
10441
|
+
this.effectiveSampleRate,
|
|
10442
|
+
(clipId) => this._heldElsewhere(trackId, clipId)
|
|
10297
10443
|
);
|
|
10298
10444
|
const nextPending = new Map(this._pending);
|
|
10299
10445
|
nextPending.delete(trackId);
|
|
@@ -10328,11 +10474,12 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10328
10474
|
}
|
|
10329
10475
|
this._announcer.expect(trackId, built.refused.length + moved.refused.length);
|
|
10330
10476
|
for (const clip of entering.clips) {
|
|
10331
|
-
if ((0,
|
|
10477
|
+
if ((0, import_core23.isLoadingClip)(clip)) this._announcer.expectClip(clip.id);
|
|
10332
10478
|
}
|
|
10479
|
+
const addEntering = () => this._arrangement.addTrack(entering, index === void 0 ? void 0 : { index });
|
|
10333
10480
|
try {
|
|
10334
10481
|
if (moved.from.size === 0) {
|
|
10335
|
-
|
|
10482
|
+
addEntering();
|
|
10336
10483
|
} else {
|
|
10337
10484
|
this._inOneStep([this._arrangement], () => {
|
|
10338
10485
|
for (const [fromId, clipIds] of moved.from) {
|
|
@@ -10342,7 +10489,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10342
10489
|
}));
|
|
10343
10490
|
for (const clipId of clipIds) this._forgetClip(fromId, clipId);
|
|
10344
10491
|
}
|
|
10345
|
-
|
|
10492
|
+
addEntering();
|
|
10346
10493
|
});
|
|
10347
10494
|
}
|
|
10348
10495
|
} catch (err) {
|
|
@@ -10412,7 +10559,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10412
10559
|
const waveformData = await this._resolvePeaks(peaksSrc);
|
|
10413
10560
|
if (!waveformData) return;
|
|
10414
10561
|
const clip = this._arrangement.getTracks().flatMap((t) => t.clips).find((c) => c.id === clipId);
|
|
10415
|
-
if (!clip || !(0,
|
|
10562
|
+
if (!clip || !(0, import_core23.isLoadingClip)(clip)) return;
|
|
10416
10563
|
const rate = waveformData.sample_rate;
|
|
10417
10564
|
const offset = clip.offset ?? 0;
|
|
10418
10565
|
const seconds = clip.duration ?? Math.max(0, waveformData.duration - offset);
|
|
@@ -10564,7 +10711,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10564
10711
|
}
|
|
10565
10712
|
const sources = this._arrangement.sources.getSnapshot().sources;
|
|
10566
10713
|
const failed = new Set(
|
|
10567
|
-
track.clips.filter(
|
|
10714
|
+
track.clips.filter(import_core23.isLoadingClip).map((clip) => clip.src).filter((src) => sources.get(src)?.status === "failed")
|
|
10568
10715
|
);
|
|
10569
10716
|
for (const src of failed) this._arrangement.retry(src);
|
|
10570
10717
|
}
|
|
@@ -10594,7 +10741,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10594
10741
|
}
|
|
10595
10742
|
for (const track of this._arrangement.getTracks()) {
|
|
10596
10743
|
for (const clip of track.clips) {
|
|
10597
|
-
if (!(0,
|
|
10744
|
+
if (!(0, import_core23.isLoadingClip)(clip)) continue;
|
|
10598
10745
|
const seconds = this._placeholderSeconds(clip);
|
|
10599
10746
|
if (seconds === null) continue;
|
|
10600
10747
|
maxSample = Math.max(maxSample, Math.round(((clip.start ?? 0) + seconds) * sr));
|
|
@@ -10668,7 +10815,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10668
10815
|
}
|
|
10669
10816
|
adapter.setPpqn?.(this._ppqn);
|
|
10670
10817
|
this.ppqn = adapter.ppqn;
|
|
10671
|
-
const engine = new
|
|
10818
|
+
const engine = new import_engine4.EditorEngine({
|
|
10672
10819
|
adapter,
|
|
10673
10820
|
arrangement: this._arrangement,
|
|
10674
10821
|
sampleRate: adapter.audioContext.sampleRate,
|
|
@@ -10728,7 +10875,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
10728
10875
|
if (structuralChange) {
|
|
10729
10876
|
this._recomputeDuration();
|
|
10730
10877
|
this._effectsManager?.rewireTrackChains();
|
|
10731
|
-
const audioTracks = engineState.tracks.filter((t) => (0,
|
|
10878
|
+
const audioTracks = engineState.tracks.filter((t) => (0, import_core23.trackKind)(t) !== "midi");
|
|
10732
10879
|
this._adoptLoadedClips(audioTracks);
|
|
10733
10880
|
syncPeaksForChangedClips(this, audioTracks);
|
|
10734
10881
|
this._announceLoading();
|
|
@@ -11061,13 +11208,25 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11061
11208
|
{ signal: call.signal }
|
|
11062
11209
|
);
|
|
11063
11210
|
const watched = pending && "element" in pending && !this._isEntered(trackId) ? this._ownArrangement : this._arrangement;
|
|
11064
|
-
|
|
11211
|
+
let settled = false;
|
|
11212
|
+
const stopWatching = watched.subscribe((info) => {
|
|
11213
|
+
if (settled) return;
|
|
11214
|
+
if (info.removedClips?.some((c) => c.trackId === trackId && c.clipId === clipId)) {
|
|
11215
|
+
settled = true;
|
|
11216
|
+
cleanup();
|
|
11217
|
+
reject(removedOnArrival(clipId));
|
|
11218
|
+
return;
|
|
11219
|
+
}
|
|
11065
11220
|
const present = watched.getTracks().some((t) => t.clips.some((c) => c.id === clipId));
|
|
11066
11221
|
if (present) {
|
|
11067
11222
|
seen = true;
|
|
11068
11223
|
} else if (seen) {
|
|
11069
|
-
|
|
11070
|
-
|
|
11224
|
+
queueMicrotask(() => {
|
|
11225
|
+
if (settled) return;
|
|
11226
|
+
settled = true;
|
|
11227
|
+
cleanup();
|
|
11228
|
+
reject(new Error('clip "' + clipId + '" was removed before its audio loaded'));
|
|
11229
|
+
});
|
|
11071
11230
|
}
|
|
11072
11231
|
});
|
|
11073
11232
|
call.signal.addEventListener("abort", stopWatching);
|
|
@@ -11447,7 +11606,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11447
11606
|
}
|
|
11448
11607
|
const targetId = options?.trackId ?? this._selectedTrackId;
|
|
11449
11608
|
const target = targetId ? this._arrangement.getTracks().find((t) => t.id === targetId) : void 0;
|
|
11450
|
-
if (targetId && target && (0,
|
|
11609
|
+
if (targetId && target && (0, import_core23.trackKind)(target) === "midi") {
|
|
11451
11610
|
const error = new Error(
|
|
11452
11611
|
'Cannot record onto MIDI track "' + target.name + '": a recording is audio. Select or create an audio track first.'
|
|
11453
11612
|
);
|
|
@@ -11587,7 +11746,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11587
11746
|
this._mixOf(track.id),
|
|
11588
11747
|
this._arrangement.recordingTrackIds.has(track.id)
|
|
11589
11748
|
);
|
|
11590
|
-
rows.push([track.id, loaded, track.clips.filter(
|
|
11749
|
+
rows.push([track.id, loaded, track.clips.filter(import_core23.isLoadingClip)]);
|
|
11591
11750
|
}
|
|
11592
11751
|
return rows;
|
|
11593
11752
|
}
|
|
@@ -11610,7 +11769,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11610
11769
|
} else {
|
|
11611
11770
|
const startSample = Math.round(startSec * sr);
|
|
11612
11771
|
left = Math.floor(startSample / spp);
|
|
11613
|
-
width = (0,
|
|
11772
|
+
width = (0, import_core23.clipPixelWidth)(startSample, Math.round(seconds * sr), spp);
|
|
11614
11773
|
}
|
|
11615
11774
|
const failed = this._arrangement.sources.getSnapshot().sources.get(clip.src)?.status === "failed";
|
|
11616
11775
|
const peakData = this._previewPeaks.get(clip.id);
|
|
@@ -11658,7 +11817,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11658
11817
|
const orderedTracks = this._getOrderedTracks().map(([trackId, track, loading]) => {
|
|
11659
11818
|
const descriptor = {
|
|
11660
11819
|
name: track.name ?? "",
|
|
11661
|
-
kind: (0,
|
|
11820
|
+
kind: (0, import_core23.trackKind)(track),
|
|
11662
11821
|
renderMode: this._renderModeOf(trackId)
|
|
11663
11822
|
};
|
|
11664
11823
|
const firstPeaks = [...track.clips, ...loading].map((c) => this._peaksData.get(c.id) ?? this._previewPeaks.get(c.id)).find((p) => p && p.data.length > 0);
|
|
@@ -11786,7 +11945,7 @@ var DawEditorElement = class extends import_lit19.LitElement {
|
|
|
11786
11945
|
width = Math.round(endTick / this.ticksPerPixel) - clipLeft;
|
|
11787
11946
|
} else {
|
|
11788
11947
|
clipLeft = Math.floor(clip.startSample / spp);
|
|
11789
|
-
width = (0,
|
|
11948
|
+
width = (0, import_core23.clipPixelWidth)(clip.startSample, clip.durationSamples, spp);
|
|
11790
11949
|
}
|
|
11791
11950
|
let clipSegments;
|
|
11792
11951
|
let segmentChannels;
|
|
@@ -12182,6 +12341,11 @@ __decorateClass([
|
|
|
12182
12341
|
DawEditorElement = __decorateClass([
|
|
12183
12342
|
(0, import_decorators16.customElement)("daw-editor")
|
|
12184
12343
|
], DawEditorElement);
|
|
12344
|
+
function removedOnArrival(clipId) {
|
|
12345
|
+
return new Error(
|
|
12346
|
+
'clip "' + clipId + '": its offset is at or past the end of its audio; the clip is removed'
|
|
12347
|
+
);
|
|
12348
|
+
}
|
|
12185
12349
|
|
|
12186
12350
|
// src/elements/daw-selection.ts
|
|
12187
12351
|
var import_lit20 = require("lit");
|
|
@@ -12325,7 +12489,7 @@ DawRecordButtonElement = __decorateClass([
|
|
|
12325
12489
|
// src/elements/daw-keyboard-shortcuts.ts
|
|
12326
12490
|
var import_lit22 = require("lit");
|
|
12327
12491
|
var import_decorators19 = require("lit/decorators.js");
|
|
12328
|
-
var
|
|
12492
|
+
var import_core24 = require("@waveform-playlist/core");
|
|
12329
12493
|
var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
12330
12494
|
constructor() {
|
|
12331
12495
|
super(...arguments);
|
|
@@ -12353,7 +12517,7 @@ var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
|
12353
12517
|
const shortcuts = this.shortcuts;
|
|
12354
12518
|
if (shortcuts.length === 0) return;
|
|
12355
12519
|
try {
|
|
12356
|
-
(0,
|
|
12520
|
+
(0, import_core24.handleKeyboardEvent)(e, shortcuts, true);
|
|
12357
12521
|
} catch (err) {
|
|
12358
12522
|
console.warn("[dawcore] Keyboard shortcut failed (key=" + e.key + "): " + String(err));
|
|
12359
12523
|
const target = this._editor ?? this;
|
|
@@ -12546,7 +12710,7 @@ DawKeyboardShortcutsElement = __decorateClass([
|
|
|
12546
12710
|
// src/elements/daw-spectrogram.ts
|
|
12547
12711
|
var import_lit23 = require("lit");
|
|
12548
12712
|
var import_decorators20 = require("lit/decorators.js");
|
|
12549
|
-
var
|
|
12713
|
+
var import_core25 = require("@waveform-playlist/core");
|
|
12550
12714
|
var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
12551
12715
|
constructor() {
|
|
12552
12716
|
super(...arguments);
|
|
@@ -12611,11 +12775,11 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
12611
12775
|
this._unregisterAllCanvases();
|
|
12612
12776
|
this._canvases = [];
|
|
12613
12777
|
if (this.length <= 0) return;
|
|
12614
|
-
const chunkCount = Math.ceil(this.length /
|
|
12778
|
+
const chunkCount = Math.ceil(this.length / import_core25.MAX_CANVAS_WIDTH);
|
|
12615
12779
|
for (let i = 0; i < chunkCount; i++) {
|
|
12616
|
-
const widthPx = Math.min(
|
|
12780
|
+
const widthPx = Math.min(import_core25.MAX_CANVAS_WIDTH, this.length - i * import_core25.MAX_CANVAS_WIDTH);
|
|
12617
12781
|
const canvas = document.createElement("canvas");
|
|
12618
|
-
canvas.style.left = i *
|
|
12782
|
+
canvas.style.left = i * import_core25.MAX_CANVAS_WIDTH + "px";
|
|
12619
12783
|
canvas.style.width = widthPx + "px";
|
|
12620
12784
|
const dpr = window.devicePixelRatio || 1;
|
|
12621
12785
|
canvas.width = widthPx * dpr;
|
|
@@ -12641,7 +12805,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
12641
12805
|
}
|
|
12642
12806
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
12643
12807
|
const canvas = this._canvases[i];
|
|
12644
|
-
const canvasId = (0,
|
|
12808
|
+
const canvasId = (0, import_core25.buildSpectrogramCanvasId)({
|
|
12645
12809
|
clipId: this.clipId,
|
|
12646
12810
|
channelIndex: this.channelIndex,
|
|
12647
12811
|
chunkIndex: i
|
|
@@ -12662,7 +12826,7 @@ var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
|
12662
12826
|
trackId: this.trackId,
|
|
12663
12827
|
channelIndex: this.channelIndex,
|
|
12664
12828
|
chunkIndex: i,
|
|
12665
|
-
globalPixelOffset: this.originX + i *
|
|
12829
|
+
globalPixelOffset: this.originX + i * import_core25.MAX_CANVAS_WIDTH,
|
|
12666
12830
|
widthPx: parseFloat(canvas.style.width),
|
|
12667
12831
|
heightPx: this.waveHeight
|
|
12668
12832
|
});
|