@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.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// <define:__INSTALL_SPECS__>
|
|
13
|
-
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.
|
|
13
|
+
var define_INSTALL_SPECS_default = { "@dawcore/faust": "@dawcore/faust@^0.0.2-next.1", "@dawcore/midi": "@dawcore/midi@^0.0.6-next.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" };
|
|
14
14
|
|
|
15
15
|
// src/elements/daw-annotation.ts
|
|
16
16
|
import { LitElement } from "lit";
|
|
@@ -2506,6 +2506,7 @@ import { repeat } from "lit/directives/repeat.js";
|
|
|
2506
2506
|
import {
|
|
2507
2507
|
createMixerGesture as createMixerGesture2,
|
|
2508
2508
|
clipPixelWidth,
|
|
2509
|
+
durationSamplesFromSeconds as durationSamplesFromSeconds2,
|
|
2509
2510
|
isDecidedPanLaw as isDecidedPanLaw3,
|
|
2510
2511
|
isLoadingClip as isLoadingClip5,
|
|
2511
2512
|
trackKind
|
|
@@ -5190,7 +5191,8 @@ var PointerHandler = class {
|
|
|
5190
5191
|
|
|
5191
5192
|
// src/interactions/clip-pointer-handler.ts
|
|
5192
5193
|
import { snapTickToGrid as snapTickToGrid2 } from "@waveform-playlist/core";
|
|
5193
|
-
import {
|
|
5194
|
+
import { isLoadingClip } from "@waveform-playlist/core";
|
|
5195
|
+
import { constrainClipDrag, trackClipSpans } from "@waveform-playlist/engine";
|
|
5194
5196
|
var ClipPointerHandler = class {
|
|
5195
5197
|
constructor(host) {
|
|
5196
5198
|
this._mode = null;
|
|
@@ -5207,9 +5209,13 @@ var ClipPointerHandler = class {
|
|
|
5207
5209
|
this._originalOffsetSamples = 0;
|
|
5208
5210
|
this._originalDurationSamples = 0;
|
|
5209
5211
|
this._originalStartSample = 0;
|
|
5210
|
-
// Move: the dragged clip and
|
|
5212
|
+
// Move: the dragged clip and what it collides with on its track, sorted
|
|
5211
5213
|
this._moveClip = null;
|
|
5212
5214
|
this._moveSorted = [];
|
|
5215
|
+
// The pointer's distance from the drag's start at the last move, and the
|
|
5216
|
+
// function that stops following the arrangement (set while dragging).
|
|
5217
|
+
this._lastDeltaPx = 0;
|
|
5218
|
+
this._stopFollowing = null;
|
|
5213
5219
|
this._committing = false;
|
|
5214
5220
|
this._host = host;
|
|
5215
5221
|
}
|
|
@@ -5323,13 +5329,8 @@ var ClipPointerHandler = class {
|
|
|
5323
5329
|
this._originalStartSample = bounds.startSample;
|
|
5324
5330
|
this._originalOffsetSamples = bounds.offsetSamples;
|
|
5325
5331
|
this._originalDurationSamples = bounds.durationSamples;
|
|
5326
|
-
if (this._mode === "move")
|
|
5327
|
-
|
|
5328
|
-
const clip = track?.clips.find((c) => c.id === clipId) ?? null;
|
|
5329
|
-
if (!track || !clip) return false;
|
|
5330
|
-
this._moveClip = clip;
|
|
5331
|
-
this._moveSorted = [...track.clips].sort((a, b) => a.startSample - b.startSample);
|
|
5332
|
-
}
|
|
5332
|
+
if (this._mode === "move" && !this._readMoveNeighbours()) return false;
|
|
5333
|
+
this._stopFollowing = this._host.arrangement.subscribe(() => this._onArrangementChange());
|
|
5333
5334
|
} else {
|
|
5334
5335
|
console.warn("[dawcore] drag start: engine unavailable, the drag will not be applied");
|
|
5335
5336
|
}
|
|
@@ -5347,6 +5348,23 @@ var ClipPointerHandler = class {
|
|
|
5347
5348
|
}
|
|
5348
5349
|
return true;
|
|
5349
5350
|
}
|
|
5351
|
+
/** The dragged clip and its neighbours, read from the arrangement now. False when gone. */
|
|
5352
|
+
_readMoveNeighbours() {
|
|
5353
|
+
const track = this._host.arrangement.getTracks().find((t) => t.id === this._trackId);
|
|
5354
|
+
const clip = track?.clips.find(
|
|
5355
|
+
(c) => c.id === this._clipId && !isLoadingClip(c)
|
|
5356
|
+
);
|
|
5357
|
+
if (!track || !clip) return false;
|
|
5358
|
+
this._moveClip = clip;
|
|
5359
|
+
this._moveSorted = trackClipSpans(track.clips, clip.sampleRate);
|
|
5360
|
+
return true;
|
|
5361
|
+
}
|
|
5362
|
+
/** The tracks changed under the drag: draw it again from the last pointer position. */
|
|
5363
|
+
_onArrangementChange() {
|
|
5364
|
+
if (!this._isDragging || this._committing) return;
|
|
5365
|
+
if (this._mode === "move") this._readMoveNeighbours();
|
|
5366
|
+
this._applyDrag(this._lastDeltaPx);
|
|
5367
|
+
}
|
|
5350
5368
|
/** Processes pointermove events during an active drag. */
|
|
5351
5369
|
onPointerMove(e) {
|
|
5352
5370
|
if (this._mode === null) return;
|
|
@@ -5362,6 +5380,11 @@ var ClipPointerHandler = class {
|
|
|
5362
5380
|
}
|
|
5363
5381
|
}
|
|
5364
5382
|
if (!this._isDragging) return;
|
|
5383
|
+
this._applyDrag(totalDeltaPx);
|
|
5384
|
+
}
|
|
5385
|
+
/** Draw the drag `totalDeltaPx` from its start, constrained as the release will be. */
|
|
5386
|
+
_applyDrag(totalDeltaPx) {
|
|
5387
|
+
this._lastDeltaPx = totalDeltaPx;
|
|
5365
5388
|
const engine = this._host.engine;
|
|
5366
5389
|
if (!engine) return;
|
|
5367
5390
|
if (this._mode === "move") {
|
|
@@ -5548,6 +5571,9 @@ var ClipPointerHandler = class {
|
|
|
5548
5571
|
this._originalStartSample = 0;
|
|
5549
5572
|
this._moveClip = null;
|
|
5550
5573
|
this._moveSorted = [];
|
|
5574
|
+
this._lastDeltaPx = 0;
|
|
5575
|
+
this._stopFollowing?.();
|
|
5576
|
+
this._stopFollowing = null;
|
|
5551
5577
|
}
|
|
5552
5578
|
};
|
|
5553
5579
|
|
|
@@ -6183,7 +6209,7 @@ function stringifyReason(reason) {
|
|
|
6183
6209
|
}
|
|
6184
6210
|
|
|
6185
6211
|
// src/interactions/recording-clip.ts
|
|
6186
|
-
import {
|
|
6212
|
+
import { carveTrackClipRange, createClip } from "@waveform-playlist/core";
|
|
6187
6213
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
6188
6214
|
let trimmedBuf = buf;
|
|
6189
6215
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -6218,16 +6244,41 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6218
6244
|
return;
|
|
6219
6245
|
}
|
|
6220
6246
|
host._peaksData = new Map(host._peaksData).set(clip.id, pd);
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6247
|
+
try {
|
|
6248
|
+
host._arrangement.updateTrack(trackId, (current) => ({
|
|
6249
|
+
...current,
|
|
6250
|
+
clips: [
|
|
6251
|
+
...carveTrackClipRange(
|
|
6252
|
+
current.clips,
|
|
6253
|
+
startSample,
|
|
6254
|
+
startSample + durSamples,
|
|
6255
|
+
clip.sampleRate
|
|
6256
|
+
),
|
|
6257
|
+
clip
|
|
6258
|
+
]
|
|
6259
|
+
}));
|
|
6260
|
+
} catch (refusal) {
|
|
6261
|
+
forgetClip(host, clip.id);
|
|
6262
|
+
const cause = refusal instanceof Error ? refusal : new Error(String(refusal));
|
|
6263
|
+
const error = Object.assign(
|
|
6264
|
+
new Error(
|
|
6265
|
+
'Recording completed but the take could not be saved on track "' + trackId + '": ' + cause.message
|
|
6227
6266
|
),
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6267
|
+
{ cause }
|
|
6268
|
+
);
|
|
6269
|
+
console.warn("[dawcore] " + error.message);
|
|
6270
|
+
if (host.isConnected) {
|
|
6271
|
+
host.dispatchEvent(
|
|
6272
|
+
new CustomEvent("daw-recording-error", {
|
|
6273
|
+
bubbles: true,
|
|
6274
|
+
composed: true,
|
|
6275
|
+
detail: { trackId, error }
|
|
6276
|
+
})
|
|
6277
|
+
);
|
|
6278
|
+
}
|
|
6279
|
+
return;
|
|
6280
|
+
}
|
|
6281
|
+
host._raiseZoomFloor(host._peakPipeline.getCachedScale(trimmedBuf));
|
|
6231
6282
|
if (host.isConnected) {
|
|
6232
6283
|
host.dispatchEvent(
|
|
6233
6284
|
new CustomEvent("daw-recording-clip-add", {
|
|
@@ -6239,10 +6290,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6239
6290
|
}
|
|
6240
6291
|
}).catch((err) => {
|
|
6241
6292
|
console.warn("[dawcore] Failed to generate peaks for recorded clip: " + String(err));
|
|
6242
|
-
|
|
6243
|
-
next.delete(clip.id);
|
|
6244
|
-
host._clipBuffers = next;
|
|
6245
|
-
host._clipOffsets.delete(clip.id);
|
|
6293
|
+
forgetClip(host, clip.id);
|
|
6246
6294
|
if (host.isConnected) {
|
|
6247
6295
|
host.dispatchEvent(
|
|
6248
6296
|
new CustomEvent("daw-error", {
|
|
@@ -6254,6 +6302,17 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
6254
6302
|
}
|
|
6255
6303
|
});
|
|
6256
6304
|
}
|
|
6305
|
+
function forgetClip(host, clipId) {
|
|
6306
|
+
const next = new Map(host._clipBuffers);
|
|
6307
|
+
next.delete(clipId);
|
|
6308
|
+
host._clipBuffers = next;
|
|
6309
|
+
host._clipOffsets.delete(clipId);
|
|
6310
|
+
if (host._peaksData.has(clipId)) {
|
|
6311
|
+
const peaks = new Map(host._peaksData);
|
|
6312
|
+
peaks.delete(clipId);
|
|
6313
|
+
host._peaksData = peaks;
|
|
6314
|
+
}
|
|
6315
|
+
}
|
|
6257
6316
|
|
|
6258
6317
|
// src/interactions/split-handler.ts
|
|
6259
6318
|
function splitAtPlayhead(host) {
|
|
@@ -6421,7 +6480,13 @@ function findAudioBufferForClip(host, clip, track) {
|
|
|
6421
6480
|
}
|
|
6422
6481
|
|
|
6423
6482
|
// src/interactions/track-entry.ts
|
|
6424
|
-
import {
|
|
6483
|
+
import {
|
|
6484
|
+
createClip as createClip2,
|
|
6485
|
+
createTrack,
|
|
6486
|
+
durationSamplesFromSeconds,
|
|
6487
|
+
isDecidedPanLaw as isDecidedPanLaw2
|
|
6488
|
+
} from "@waveform-playlist/core";
|
|
6489
|
+
import { findClipOverlap } from "@waveform-playlist/engine";
|
|
6425
6490
|
function validMidiNotes(notes) {
|
|
6426
6491
|
return notes.filter((n) => {
|
|
6427
6492
|
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;
|
|
@@ -6457,7 +6522,7 @@ function buildMidiClip(clipDesc, sampleRate) {
|
|
|
6457
6522
|
const sourceDurationSamples = Math.ceil(
|
|
6458
6523
|
Math.max(noteSpanSeconds, clipDesc.duration, 1) * sampleRate
|
|
6459
6524
|
);
|
|
6460
|
-
const requestedDurationSamples = clipDesc.duration > 0 ?
|
|
6525
|
+
const requestedDurationSamples = clipDesc.duration > 0 ? durationSamplesFromSeconds(clipDesc.start, clipDesc.duration, sampleRate) : sourceDurationSamples;
|
|
6461
6526
|
const clip = createClip2({
|
|
6462
6527
|
startSample: Math.round(clipDesc.start * sampleRate),
|
|
6463
6528
|
durationSamples: requestedDurationSamples,
|
|
@@ -6488,8 +6553,20 @@ function withClipId(clipDesc) {
|
|
|
6488
6553
|
if (clipDesc.clipId) return clipDesc;
|
|
6489
6554
|
return { ...clipDesc, clipId: crypto.randomUUID() };
|
|
6490
6555
|
}
|
|
6491
|
-
function
|
|
6556
|
+
function clipOverlapError(trackName, clips, clip, clipLabel) {
|
|
6557
|
+
const overlap = findClipOverlap([...clips, clip]);
|
|
6558
|
+
if (!overlap) return null;
|
|
6559
|
+
const other = overlap.first === clip.id ? overlap.second : overlap.first;
|
|
6560
|
+
return new Error(
|
|
6561
|
+
'clip "' + clipLabel + '" overlaps clip "' + other + '" on track "' + trackName + '". Clips on a track cannot overlap: give it a start after the other ends.'
|
|
6562
|
+
);
|
|
6563
|
+
}
|
|
6564
|
+
function isMidiClip(clip) {
|
|
6565
|
+
return "midiNotes" in clip && clip.midiNotes != null;
|
|
6566
|
+
}
|
|
6567
|
+
function buildArrangementTrack(trackId, descriptor, mix, sampleRate, heldOf = () => void 0) {
|
|
6492
6568
|
const clips = [];
|
|
6569
|
+
const placed = [];
|
|
6493
6570
|
const refused = [];
|
|
6494
6571
|
let changed = false;
|
|
6495
6572
|
const descClips = descriptor.clips.map((clipDesc) => {
|
|
@@ -6500,8 +6577,24 @@ function buildArrangementTrack(trackId, descriptor, mix, sampleRate) {
|
|
|
6500
6577
|
const sourceName = typeof source === "string" ? source : source instanceof File ? source.name : "";
|
|
6501
6578
|
const label = identified.name || sourceName || identified.clipId;
|
|
6502
6579
|
const kindError = clipKindError(descriptor.name, descriptor.kind, isMidi, label);
|
|
6503
|
-
if (kindError)
|
|
6504
|
-
|
|
6580
|
+
if (kindError) {
|
|
6581
|
+
refused.push({ clipId: identified.clipId, error: kindError });
|
|
6582
|
+
return identified;
|
|
6583
|
+
}
|
|
6584
|
+
const clip = isMidi ? buildMidiClip(identified, sampleRate) : buildLoadingClip(identified);
|
|
6585
|
+
const held = heldOf(identified.clipId);
|
|
6586
|
+
if (held && isMidiClip(held) !== (descriptor.kind === "midi")) {
|
|
6587
|
+
clips.push(clip);
|
|
6588
|
+
return identified;
|
|
6589
|
+
}
|
|
6590
|
+
const where = held ?? clip;
|
|
6591
|
+
const overlapError = clipOverlapError(descriptor.name, placed, where, label);
|
|
6592
|
+
if (overlapError) {
|
|
6593
|
+
refused.push({ clipId: identified.clipId, error: overlapError });
|
|
6594
|
+
} else {
|
|
6595
|
+
clips.push(clip);
|
|
6596
|
+
placed.push(where);
|
|
6597
|
+
}
|
|
6505
6598
|
return identified;
|
|
6506
6599
|
});
|
|
6507
6600
|
const { panLaw, ...fields } = mix;
|
|
@@ -8823,7 +8916,8 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8823
8916
|
this.requestUpdate();
|
|
8824
8917
|
});
|
|
8825
8918
|
let tracksVersion = arrangement.tracksVersion;
|
|
8826
|
-
const stopTracks = arrangement.subscribe(() => {
|
|
8919
|
+
const stopTracks = arrangement.subscribe((info) => {
|
|
8920
|
+
if (info.removedClips) this._reportRemovedOnArrival(info.removedClips);
|
|
8827
8921
|
this._watchDrags();
|
|
8828
8922
|
if (arrangement.tracksVersion === tracksVersion) return;
|
|
8829
8923
|
tracksVersion = arrangement.tracksVersion;
|
|
@@ -8834,6 +8928,23 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
8834
8928
|
stopTracks();
|
|
8835
8929
|
};
|
|
8836
8930
|
}
|
|
8931
|
+
/**
|
|
8932
|
+
* The clips the arrangement took out by itself because nothing of their
|
|
8933
|
+
* audio was left after their offset (#859, maintainer's choice "remove"),
|
|
8934
|
+
* as its change says (`removedClips`), reported with `daw-clip-error`
|
|
8935
|
+
* (maintainer, "a"). Their `<daw-clip>` stays on the page.
|
|
8936
|
+
*/
|
|
8937
|
+
_reportRemovedOnArrival(removed) {
|
|
8938
|
+
for (const { trackId, clipId } of removed) {
|
|
8939
|
+
this.dispatchEvent(
|
|
8940
|
+
new CustomEvent("daw-clip-error", {
|
|
8941
|
+
bubbles: true,
|
|
8942
|
+
composed: true,
|
|
8943
|
+
detail: { trackId, clipId, error: removedOnArrival(clipId) }
|
|
8944
|
+
})
|
|
8945
|
+
);
|
|
8946
|
+
}
|
|
8947
|
+
}
|
|
8837
8948
|
/**
|
|
8838
8949
|
* A change to the arrangement while a drag is in progress came from
|
|
8839
8950
|
* elsewhere (a drag writes nothing until its release): cancel the drag
|
|
@@ -9360,11 +9471,21 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9360
9471
|
const src = clip && typeof clip.src === "string" ? clip.src : "";
|
|
9361
9472
|
this._applyClipUpdate(holderId, clipId, { ...current, ...partial, src });
|
|
9362
9473
|
}
|
|
9474
|
+
/** The clip of that id another track of the arrangement holds (a `<daw-clip>` the page moved here), if any. */
|
|
9475
|
+
_heldElsewhere(trackId, clipId) {
|
|
9476
|
+
for (const t of this._arrangement.getTracks()) {
|
|
9477
|
+
if (t.id === trackId) continue;
|
|
9478
|
+
const held = t.clips.find((c) => c.id === clipId);
|
|
9479
|
+
if (held) return held;
|
|
9480
|
+
}
|
|
9481
|
+
return void 0;
|
|
9482
|
+
}
|
|
9363
9483
|
/**
|
|
9364
9484
|
* The clips of an entering track that another track of the arrangement
|
|
9365
9485
|
* holds (the page moved their `<daw-clip>` here while the track waited):
|
|
9366
9486
|
* the track takes the held clip as it is, and `from` names what leaves
|
|
9367
|
-
* where. A held clip of the other kind
|
|
9487
|
+
* where. A held clip of the other kind, or one that would overlap a clip of
|
|
9488
|
+
* the entering track (#859), is refused and stays.
|
|
9368
9489
|
*/
|
|
9369
9490
|
_takeOverMovedClips(trackId, track) {
|
|
9370
9491
|
const from = /* @__PURE__ */ new Map();
|
|
@@ -9373,7 +9494,13 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9373
9494
|
const others = this._arrangement.getTracks().filter((t) => t.id !== trackId);
|
|
9374
9495
|
const kind = trackKind(track);
|
|
9375
9496
|
const clips = [];
|
|
9376
|
-
|
|
9497
|
+
const isMidiOf = (c) => "midiNotes" in c && c.midiNotes != null;
|
|
9498
|
+
const finalOf = (c) => {
|
|
9499
|
+
const held = this._heldElsewhere(trackId, c.id);
|
|
9500
|
+
if (!held) return [c];
|
|
9501
|
+
return isMidiOf(held) === (kind === "midi") ? [held] : [];
|
|
9502
|
+
};
|
|
9503
|
+
for (const [i, clip] of track.clips.entries()) {
|
|
9377
9504
|
const holder = others.find((t) => t.clips.some((c) => c.id === clip.id));
|
|
9378
9505
|
const held = holder?.clips.find((c) => c.id === clip.id);
|
|
9379
9506
|
if (!holder || !held) {
|
|
@@ -9381,7 +9508,8 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9381
9508
|
continue;
|
|
9382
9509
|
}
|
|
9383
9510
|
const isMidi = "midiNotes" in held && held.midiNotes != null;
|
|
9384
|
-
const
|
|
9511
|
+
const neighbours = [...clips, ...track.clips.slice(i + 1).flatMap(finalOf)];
|
|
9512
|
+
const error = clipKindError(track.name ?? "", kind, isMidi, held.name || held.id) ?? clipOverlapError(track.name ?? "", neighbours, held, held.name || held.id);
|
|
9385
9513
|
if (error) {
|
|
9386
9514
|
refused.push({ clipId: clip.id, error });
|
|
9387
9515
|
continue;
|
|
@@ -9962,11 +10090,33 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
9962
10090
|
* function form, so the track's loading clips stay as they are (#848).
|
|
9963
10091
|
*/
|
|
9964
10092
|
_replaceClip(trackId, clipId, clip) {
|
|
10093
|
+
if (this._refusedForOverlap(trackId, clip)) return;
|
|
9965
10094
|
this._arrangement.updateTrack(trackId, (current) => ({
|
|
9966
10095
|
...current,
|
|
9967
10096
|
clips: current.clips.map((c) => c.id === clipId ? clip : c)
|
|
9968
10097
|
}));
|
|
9969
10098
|
}
|
|
10099
|
+
/**
|
|
10100
|
+
* A clip change that would make `clip` overlap another clip of its track
|
|
10101
|
+
* (#859) changes nothing and is reported with `daw-clip-error`, as a change
|
|
10102
|
+
* that would give it the other kind is. True when refused.
|
|
10103
|
+
*/
|
|
10104
|
+
_refusedForOverlap(trackId, clip) {
|
|
10105
|
+
const track = this._arrangement.getTracks().find((t) => t.id === trackId);
|
|
10106
|
+
if (!track) return false;
|
|
10107
|
+
const others = track.clips.filter((c) => c.id !== clip.id);
|
|
10108
|
+
const error = clipOverlapError(track.name ?? "", others, clip, clip.name || clip.id);
|
|
10109
|
+
if (!error) return false;
|
|
10110
|
+
console.warn("[dawcore] " + error.message);
|
|
10111
|
+
this.dispatchEvent(
|
|
10112
|
+
new CustomEvent("daw-clip-error", {
|
|
10113
|
+
bubbles: true,
|
|
10114
|
+
composed: true,
|
|
10115
|
+
detail: { trackId, clipId: clip.id, error }
|
|
10116
|
+
})
|
|
10117
|
+
);
|
|
10118
|
+
return true;
|
|
10119
|
+
}
|
|
9970
10120
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
9971
10121
|
const t = this._arrangement.getTracks().find((track) => track.id === trackId);
|
|
9972
10122
|
if (!t) {
|
|
@@ -10002,13 +10152,13 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10002
10152
|
return;
|
|
10003
10153
|
}
|
|
10004
10154
|
if (isMidiNow || wasMidi) {
|
|
10005
|
-
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 ||
|
|
10155
|
+
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 || durationSamplesFromSeconds2(clipEl.start, clipEl.duration, sr) === oldClip.durationSamples) && clipEl.gain === (oldClip.gain ?? 1) && (clipEl.name || oldClip.name) === oldClip.name) {
|
|
10006
10156
|
return;
|
|
10007
10157
|
}
|
|
10008
10158
|
const notes = validMidiNotes(clipEl.midiNotes ?? []);
|
|
10009
10159
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
10010
10160
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipEl.duration, 1) * sr);
|
|
10011
|
-
const requestedDurationSamples = clipEl.duration > 0 ?
|
|
10161
|
+
const requestedDurationSamples = clipEl.duration > 0 ? durationSamplesFromSeconds2(clipEl.start, clipEl.duration, sr) : sourceDurationSamples;
|
|
10012
10162
|
const updatedClip2 = {
|
|
10013
10163
|
...oldClip,
|
|
10014
10164
|
audioBuffer: void 0,
|
|
@@ -10027,7 +10177,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10027
10177
|
return;
|
|
10028
10178
|
}
|
|
10029
10179
|
const newStartSample = Math.round(clipEl.start * sr);
|
|
10030
|
-
const newDurationSamples = clipEl.duration > 0 ?
|
|
10180
|
+
const newDurationSamples = clipEl.duration > 0 ? durationSamplesFromSeconds2(clipEl.start, clipEl.duration, sr) : oldClip.durationSamples;
|
|
10031
10181
|
const newOffsetSamples = Math.round(clipEl.offset * sr);
|
|
10032
10182
|
const updatedClip = {
|
|
10033
10183
|
...oldClip,
|
|
@@ -10069,6 +10219,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10069
10219
|
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) {
|
|
10070
10220
|
return;
|
|
10071
10221
|
}
|
|
10222
|
+
if (this._refusedForOverlap(trackId, next)) return;
|
|
10072
10223
|
this._arrangement.updateTrack(trackId, (current) => ({
|
|
10073
10224
|
...current,
|
|
10074
10225
|
clips: current.clips.map((c) => c.id === clip.id ? next : c)
|
|
@@ -10260,7 +10411,8 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10260
10411
|
trackId,
|
|
10261
10412
|
descriptor,
|
|
10262
10413
|
this._mixOf(trackId),
|
|
10263
|
-
this.effectiveSampleRate
|
|
10414
|
+
this.effectiveSampleRate,
|
|
10415
|
+
(clipId) => this._heldElsewhere(trackId, clipId)
|
|
10264
10416
|
);
|
|
10265
10417
|
const nextPending = new Map(this._pending);
|
|
10266
10418
|
nextPending.delete(trackId);
|
|
@@ -10297,9 +10449,10 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10297
10449
|
for (const clip of entering.clips) {
|
|
10298
10450
|
if (isLoadingClip5(clip)) this._announcer.expectClip(clip.id);
|
|
10299
10451
|
}
|
|
10452
|
+
const addEntering = () => this._arrangement.addTrack(entering, index === void 0 ? void 0 : { index });
|
|
10300
10453
|
try {
|
|
10301
10454
|
if (moved.from.size === 0) {
|
|
10302
|
-
|
|
10455
|
+
addEntering();
|
|
10303
10456
|
} else {
|
|
10304
10457
|
this._inOneStep([this._arrangement], () => {
|
|
10305
10458
|
for (const [fromId, clipIds] of moved.from) {
|
|
@@ -10309,7 +10462,7 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
10309
10462
|
}));
|
|
10310
10463
|
for (const clipId of clipIds) this._forgetClip(fromId, clipId);
|
|
10311
10464
|
}
|
|
10312
|
-
|
|
10465
|
+
addEntering();
|
|
10313
10466
|
});
|
|
10314
10467
|
}
|
|
10315
10468
|
} catch (err) {
|
|
@@ -11028,13 +11181,25 @@ var DawEditorElement = class extends LitElement14 {
|
|
|
11028
11181
|
{ signal: call.signal }
|
|
11029
11182
|
);
|
|
11030
11183
|
const watched = pending && "element" in pending && !this._isEntered(trackId) ? this._ownArrangement : this._arrangement;
|
|
11031
|
-
|
|
11184
|
+
let settled = false;
|
|
11185
|
+
const stopWatching = watched.subscribe((info) => {
|
|
11186
|
+
if (settled) return;
|
|
11187
|
+
if (info.removedClips?.some((c) => c.trackId === trackId && c.clipId === clipId)) {
|
|
11188
|
+
settled = true;
|
|
11189
|
+
cleanup();
|
|
11190
|
+
reject(removedOnArrival(clipId));
|
|
11191
|
+
return;
|
|
11192
|
+
}
|
|
11032
11193
|
const present = watched.getTracks().some((t) => t.clips.some((c) => c.id === clipId));
|
|
11033
11194
|
if (present) {
|
|
11034
11195
|
seen = true;
|
|
11035
11196
|
} else if (seen) {
|
|
11036
|
-
|
|
11037
|
-
|
|
11197
|
+
queueMicrotask(() => {
|
|
11198
|
+
if (settled) return;
|
|
11199
|
+
settled = true;
|
|
11200
|
+
cleanup();
|
|
11201
|
+
reject(new Error('clip "' + clipId + '" was removed before its audio loaded'));
|
|
11202
|
+
});
|
|
11038
11203
|
}
|
|
11039
11204
|
});
|
|
11040
11205
|
call.signal.addEventListener("abort", stopWatching);
|
|
@@ -12149,6 +12314,11 @@ __decorateClass([
|
|
|
12149
12314
|
DawEditorElement = __decorateClass([
|
|
12150
12315
|
customElement16("daw-editor")
|
|
12151
12316
|
], DawEditorElement);
|
|
12317
|
+
function removedOnArrival(clipId) {
|
|
12318
|
+
return new Error(
|
|
12319
|
+
'clip "' + clipId + '": its offset is at or past the end of its audio; the clip is removed'
|
|
12320
|
+
);
|
|
12321
|
+
}
|
|
12152
12322
|
|
|
12153
12323
|
// src/elements/daw-selection.ts
|
|
12154
12324
|
import { LitElement as LitElement15, html as html13, css as css12 } from "lit";
|