@dawcore/components 0.0.34 → 0.0.36
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 +286 -5
- package/dist/index.d.ts +286 -5
- package/dist/index.js +2071 -450
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2062 -436
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -38,8 +38,12 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
38
38
|
// src/index.ts
|
|
39
39
|
var index_exports = {};
|
|
40
40
|
__export(index_exports, {
|
|
41
|
+
ANNOTATION_LANE_HEIGHT: () => ANNOTATION_LANE_HEIGHT,
|
|
41
42
|
AudioResumeController: () => AudioResumeController,
|
|
42
43
|
ClipPointerHandler: () => ClipPointerHandler,
|
|
44
|
+
DawAnnotationElement: () => DawAnnotationElement,
|
|
45
|
+
DawAnnotationListElement: () => DawAnnotationListElement,
|
|
46
|
+
DawAnnotationTrackElement: () => DawAnnotationTrackElement,
|
|
43
47
|
DawClipElement: () => DawClipElement,
|
|
44
48
|
DawEditorElement: () => DawEditorElement,
|
|
45
49
|
DawGridElement: () => DawGridElement,
|
|
@@ -80,10 +84,817 @@ __export(index_exports, {
|
|
|
80
84
|
});
|
|
81
85
|
module.exports = __toCommonJS(index_exports);
|
|
82
86
|
|
|
83
|
-
// src/elements/daw-
|
|
87
|
+
// src/elements/daw-annotation.ts
|
|
84
88
|
var import_lit = require("lit");
|
|
85
89
|
var import_decorators = require("lit/decorators.js");
|
|
86
|
-
|
|
90
|
+
function isValidTick(value) {
|
|
91
|
+
return Number.isFinite(value) && Number.isInteger(value) && value >= 0;
|
|
92
|
+
}
|
|
93
|
+
var DawAnnotationElement = class extends import_lit.LitElement {
|
|
94
|
+
constructor() {
|
|
95
|
+
super(...arguments);
|
|
96
|
+
this._start = 0;
|
|
97
|
+
this._end = 0;
|
|
98
|
+
this._startTick = null;
|
|
99
|
+
this._endTick = null;
|
|
100
|
+
this._warnedHalfTick = false;
|
|
101
|
+
this._generatedId = "annotation-" + crypto.randomUUID();
|
|
102
|
+
this._hasRendered = false;
|
|
103
|
+
}
|
|
104
|
+
get start() {
|
|
105
|
+
return this._start;
|
|
106
|
+
}
|
|
107
|
+
set start(value) {
|
|
108
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
109
|
+
console.warn("[dawcore] daw-annotation start " + String(value) + " is invalid \u2014 ignored");
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const old = this._start;
|
|
113
|
+
this._start = value;
|
|
114
|
+
this.requestUpdate("start", old);
|
|
115
|
+
}
|
|
116
|
+
get end() {
|
|
117
|
+
return this._end;
|
|
118
|
+
}
|
|
119
|
+
set end(value) {
|
|
120
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
121
|
+
console.warn("[dawcore] daw-annotation end " + String(value) + " is invalid \u2014 ignored");
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const old = this._end;
|
|
125
|
+
this._end = value;
|
|
126
|
+
this.requestUpdate("end", old);
|
|
127
|
+
}
|
|
128
|
+
get startTick() {
|
|
129
|
+
return this._startTick;
|
|
130
|
+
}
|
|
131
|
+
set startTick(value) {
|
|
132
|
+
const old = this._startTick;
|
|
133
|
+
if (value === null) {
|
|
134
|
+
this._startTick = null;
|
|
135
|
+
this.requestUpdate("startTick", old);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (!isValidTick(value)) {
|
|
139
|
+
console.warn(
|
|
140
|
+
"[dawcore] daw-annotation start-tick " + String(value) + " is invalid \u2014 ignored"
|
|
141
|
+
);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this._startTick = value;
|
|
145
|
+
this.requestUpdate("startTick", old);
|
|
146
|
+
}
|
|
147
|
+
get endTick() {
|
|
148
|
+
return this._endTick;
|
|
149
|
+
}
|
|
150
|
+
set endTick(value) {
|
|
151
|
+
const old = this._endTick;
|
|
152
|
+
if (value === null) {
|
|
153
|
+
this._endTick = null;
|
|
154
|
+
this.requestUpdate("endTick", old);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (!isValidTick(value)) {
|
|
158
|
+
console.warn("[dawcore] daw-annotation end-tick " + String(value) + " is invalid \u2014 ignored");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
this._endTick = value;
|
|
162
|
+
this.requestUpdate("endTick", old);
|
|
163
|
+
}
|
|
164
|
+
/** Tick-based iff BOTH tick attributes are set (authority rule). */
|
|
165
|
+
get isTickBased() {
|
|
166
|
+
return this._startTick !== null && this._endTick !== null;
|
|
167
|
+
}
|
|
168
|
+
/** Stable identity: the id attribute when present, else a generated UUID. */
|
|
169
|
+
get annotationId() {
|
|
170
|
+
return this.id || this._generatedId;
|
|
171
|
+
}
|
|
172
|
+
toAnnotationData() {
|
|
173
|
+
const text = this.textContent?.trim() ?? "";
|
|
174
|
+
const data = {
|
|
175
|
+
id: this.annotationId,
|
|
176
|
+
start: this.start,
|
|
177
|
+
end: this.end,
|
|
178
|
+
lines: text.length > 0 ? text.split("\n") : [""]
|
|
179
|
+
};
|
|
180
|
+
if (this.isTickBased) {
|
|
181
|
+
data.startTick = this._startTick;
|
|
182
|
+
data.endTick = this._endTick;
|
|
183
|
+
}
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
// Light DOM — data container only.
|
|
187
|
+
createRenderRoot() {
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
connectedCallback() {
|
|
191
|
+
super.connectedCallback();
|
|
192
|
+
this.style.display = "none";
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
this.dispatchEvent(
|
|
195
|
+
new CustomEvent("daw-annotation-connected", {
|
|
196
|
+
bubbles: true,
|
|
197
|
+
composed: true,
|
|
198
|
+
detail: { annotationId: this.annotationId, element: this }
|
|
199
|
+
})
|
|
200
|
+
);
|
|
201
|
+
}, 0);
|
|
202
|
+
}
|
|
203
|
+
updated(changed) {
|
|
204
|
+
const halfTick = this._startTick !== null !== (this._endTick !== null);
|
|
205
|
+
if (halfTick && !this._warnedHalfTick) {
|
|
206
|
+
this._warnedHalfTick = true;
|
|
207
|
+
console.warn(
|
|
208
|
+
'[dawcore] daw-annotation "' + this.annotationId + '": only one of start-tick/end-tick is set \u2014 treated as seconds-based until both are present'
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (!this._hasRendered) {
|
|
212
|
+
this._hasRendered = true;
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (changed.has("start") || changed.has("end") || changed.has("startTick") || changed.has("endTick")) {
|
|
216
|
+
this.dispatchEvent(
|
|
217
|
+
new CustomEvent("daw-annotation-update", {
|
|
218
|
+
bubbles: true,
|
|
219
|
+
composed: true,
|
|
220
|
+
detail: { annotationId: this.annotationId }
|
|
221
|
+
})
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
__decorateClass([
|
|
227
|
+
(0, import_decorators.property)({ type: Number, noAccessor: true, reflect: true })
|
|
228
|
+
], DawAnnotationElement.prototype, "start", 1);
|
|
229
|
+
__decorateClass([
|
|
230
|
+
(0, import_decorators.property)({ type: Number, noAccessor: true, reflect: true })
|
|
231
|
+
], DawAnnotationElement.prototype, "end", 1);
|
|
232
|
+
__decorateClass([
|
|
233
|
+
(0, import_decorators.property)({ type: Number, noAccessor: true, reflect: true, attribute: "start-tick" })
|
|
234
|
+
], DawAnnotationElement.prototype, "startTick", 1);
|
|
235
|
+
__decorateClass([
|
|
236
|
+
(0, import_decorators.property)({ type: Number, noAccessor: true, reflect: true, attribute: "end-tick" })
|
|
237
|
+
], DawAnnotationElement.prototype, "endTick", 1);
|
|
238
|
+
DawAnnotationElement = __decorateClass([
|
|
239
|
+
(0, import_decorators.customElement)("daw-annotation")
|
|
240
|
+
], DawAnnotationElement);
|
|
241
|
+
|
|
242
|
+
// src/elements/daw-annotation-track.ts
|
|
243
|
+
var import_lit2 = require("lit");
|
|
244
|
+
var import_decorators2 = require("lit/decorators.js");
|
|
245
|
+
var import_core = require("@waveform-playlist/core");
|
|
246
|
+
function applyBoundaryResults(elements, after) {
|
|
247
|
+
const byId = new Map(elements.map((el) => [el.annotationId, el]));
|
|
248
|
+
for (const next of after) {
|
|
249
|
+
const el = byId.get(next.id);
|
|
250
|
+
if (!el) continue;
|
|
251
|
+
if (el.start !== next.start) el.start = next.start;
|
|
252
|
+
if (el.end !== next.end) el.end = next.end;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function applyTickBoundaryResults(elements, after, ticksToSeconds) {
|
|
256
|
+
const byId = new Map(elements.map((el) => [el.annotationId, el]));
|
|
257
|
+
for (const next of after) {
|
|
258
|
+
const el = byId.get(next.id);
|
|
259
|
+
if (!el) continue;
|
|
260
|
+
if (el.isTickBased) {
|
|
261
|
+
const startTick = Math.round(next.start);
|
|
262
|
+
const endTick = Math.round(next.end);
|
|
263
|
+
if (el.startTick !== startTick) {
|
|
264
|
+
el.startTick = startTick;
|
|
265
|
+
el.start = ticksToSeconds(startTick);
|
|
266
|
+
}
|
|
267
|
+
if (el.endTick !== endTick) {
|
|
268
|
+
el.endTick = endTick;
|
|
269
|
+
el.end = ticksToSeconds(endTick);
|
|
270
|
+
}
|
|
271
|
+
} else {
|
|
272
|
+
const start = ticksToSeconds(next.start);
|
|
273
|
+
const end = ticksToSeconds(next.end);
|
|
274
|
+
if (el.start !== start) el.start = start;
|
|
275
|
+
if (el.end !== end) el.end = end;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function tickSpaceData(el, editor) {
|
|
280
|
+
const base = el.toAnnotationData();
|
|
281
|
+
if (el.isTickBased) {
|
|
282
|
+
return { ...base, start: base.startTick, end: base.endTick };
|
|
283
|
+
}
|
|
284
|
+
return {
|
|
285
|
+
...base,
|
|
286
|
+
start: editor._secondsToTicks(base.start),
|
|
287
|
+
end: editor._secondsToTicks(base.end)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
var DawAnnotationTrackElement = class extends import_lit2.LitElement {
|
|
291
|
+
constructor() {
|
|
292
|
+
super(...arguments);
|
|
293
|
+
this.editable = false;
|
|
294
|
+
this.linkEndpoints = false;
|
|
295
|
+
this.continuousPlay = false;
|
|
296
|
+
this.keyboardControls = false;
|
|
297
|
+
this.boxLabel = "text";
|
|
298
|
+
this.name = "";
|
|
299
|
+
// --- Selection (ephemeral UI state — deliberately NOT DOM data) ---
|
|
300
|
+
this._activeAnnotationId = null;
|
|
301
|
+
// --- Keyboard remapping (accessor pair: cache invalidation on set) ---
|
|
302
|
+
this._annotationShortcuts = null;
|
|
303
|
+
this._resolvedShortcuts = null;
|
|
304
|
+
// Capture phase: runs before <daw-keyboard-shortcuts>' bubble-phase listener,
|
|
305
|
+
// giving annotation shortcuts deterministic priority (spec rule).
|
|
306
|
+
this._onKeyDownCapture = (e) => {
|
|
307
|
+
if (!this.keyboardControls) return;
|
|
308
|
+
if (e.repeat) return;
|
|
309
|
+
const target = e.target;
|
|
310
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const match = this._shortcutEntries().find((entry) => (0, import_core.matchesKeyBinding)(e, entry.binding));
|
|
314
|
+
if (!match) return;
|
|
315
|
+
const hasSelection = this._activeAnnotationId !== null;
|
|
316
|
+
if (match.action === "clearSelection" && !hasSelection) return;
|
|
317
|
+
if (DawAnnotationTrackElement._boundaryActions.has(match.action)) {
|
|
318
|
+
if (!this.editable || !hasSelection) return;
|
|
319
|
+
}
|
|
320
|
+
if (match.action === "playActive" && !hasSelection) return;
|
|
321
|
+
e.preventDefault();
|
|
322
|
+
e.stopImmediatePropagation();
|
|
323
|
+
try {
|
|
324
|
+
this._runShortcutAction(match.action);
|
|
325
|
+
} catch (err) {
|
|
326
|
+
console.warn("[dawcore] Annotation shortcut failed (key=" + e.key + "): " + String(err));
|
|
327
|
+
this.dispatchEvent(
|
|
328
|
+
new CustomEvent("daw-error", {
|
|
329
|
+
bubbles: true,
|
|
330
|
+
composed: true,
|
|
331
|
+
detail: { operation: "annotation-shortcut", key: e.key, error: err }
|
|
332
|
+
})
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
// --- Lifecycle ---
|
|
337
|
+
this._childObserver = null;
|
|
338
|
+
}
|
|
339
|
+
get activeAnnotationId() {
|
|
340
|
+
return this._activeAnnotationId;
|
|
341
|
+
}
|
|
342
|
+
set activeAnnotationId(value) {
|
|
343
|
+
if (value !== null && !this.annotationElements.some((el) => el.annotationId === value)) {
|
|
344
|
+
console.warn(
|
|
345
|
+
'[dawcore] daw-annotation-track: unknown annotation id "' + value + '" \u2014 selection ignored'
|
|
346
|
+
);
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (value === this._activeAnnotationId) return;
|
|
350
|
+
this._activeAnnotationId = value;
|
|
351
|
+
const active = this._activeElement();
|
|
352
|
+
this.dispatchEvent(
|
|
353
|
+
new CustomEvent("daw-annotation-select", {
|
|
354
|
+
bubbles: true,
|
|
355
|
+
composed: true,
|
|
356
|
+
detail: { annotation: active ? active.toAnnotationData() : null }
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
// --- Child access ---
|
|
361
|
+
/** Child annotation elements, sorted by start time. */
|
|
362
|
+
get annotationElements() {
|
|
363
|
+
return Array.from(this.querySelectorAll(":scope > daw-annotation")).sort(
|
|
364
|
+
(a, b) => a.start - b.start
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
get annotations() {
|
|
368
|
+
return this.annotationElements.map((el) => el.toAnnotationData());
|
|
369
|
+
}
|
|
370
|
+
// --- Navigation methods (spec API) ---
|
|
371
|
+
selectNext() {
|
|
372
|
+
this._selectByOffset(1, 0);
|
|
373
|
+
}
|
|
374
|
+
selectPrevious() {
|
|
375
|
+
this._selectByOffset(-1, -1);
|
|
376
|
+
}
|
|
377
|
+
selectFirst() {
|
|
378
|
+
const list = this.annotationElements;
|
|
379
|
+
if (list.length > 0) this.activeAnnotationId = list[0].annotationId;
|
|
380
|
+
}
|
|
381
|
+
selectLast() {
|
|
382
|
+
const list = this.annotationElements;
|
|
383
|
+
if (list.length > 0) this.activeAnnotationId = list[list.length - 1].annotationId;
|
|
384
|
+
}
|
|
385
|
+
clearSelection() {
|
|
386
|
+
this.activeAnnotationId = null;
|
|
387
|
+
}
|
|
388
|
+
/** offset: +1 next / -1 previous; noSelectionIndex: 0 → first, -1 → last. */
|
|
389
|
+
_selectByOffset(offset, noSelectionIndex) {
|
|
390
|
+
const list = this.annotationElements;
|
|
391
|
+
if (list.length === 0) return;
|
|
392
|
+
const currentIndex = list.findIndex((el) => el.annotationId === this._activeAnnotationId);
|
|
393
|
+
const nextIndex = currentIndex === -1 ? (noSelectionIndex + list.length) % list.length : (currentIndex + offset + list.length) % list.length;
|
|
394
|
+
this.activeAnnotationId = list[nextIndex].annotationId;
|
|
395
|
+
}
|
|
396
|
+
// --- Playback (spec API) ---
|
|
397
|
+
playActive() {
|
|
398
|
+
const active = this._activeElement();
|
|
399
|
+
if (!active) return;
|
|
400
|
+
const editor = this._hostEditor();
|
|
401
|
+
if (!editor) {
|
|
402
|
+
console.warn(
|
|
403
|
+
"[dawcore] <daw-annotation-track> playActive: no parent <daw-editor> \u2014 call ignored"
|
|
404
|
+
);
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
const data = active.toAnnotationData();
|
|
408
|
+
void editor.play(data.start, this.continuousPlay ? void 0 : data.end);
|
|
409
|
+
}
|
|
410
|
+
// --- Boundary editing (spec API) ---
|
|
411
|
+
moveStartBoundary(deltaMs) {
|
|
412
|
+
this._moveBoundary(deltaMs, true);
|
|
413
|
+
}
|
|
414
|
+
moveEndBoundary(deltaMs) {
|
|
415
|
+
this._moveBoundary(deltaMs, false);
|
|
416
|
+
}
|
|
417
|
+
_moveBoundary(deltaMs, isStart) {
|
|
418
|
+
if (!this.editable) {
|
|
419
|
+
console.warn(
|
|
420
|
+
"[dawcore] daw-annotation-track: boundary editing requires the editable attribute"
|
|
421
|
+
);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const elements = this.annotationElements;
|
|
425
|
+
const index = elements.findIndex((el) => el.annotationId === this._activeAnnotationId);
|
|
426
|
+
if (index === -1) return;
|
|
427
|
+
const active = elements[index];
|
|
428
|
+
if (active.isTickBased) {
|
|
429
|
+
const editor = this._hostEditor();
|
|
430
|
+
if (!editor) {
|
|
431
|
+
console.warn(
|
|
432
|
+
"[dawcore] daw-annotation-track: tick-based boundary edits need a parent <daw-editor> for tempo conversion \u2014 call ignored"
|
|
433
|
+
);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
const tickData = elements.map((el) => tickSpaceData(el, editor));
|
|
437
|
+
const edgeTick = isStart ? tickData[index].start : tickData[index].end;
|
|
438
|
+
const edgeSeconds = editor._ticksToSeconds(edgeTick);
|
|
439
|
+
const deltaTicks = editor._secondsToTicks(edgeSeconds + deltaMs / 1e3) - editor._secondsToTicks(edgeSeconds);
|
|
440
|
+
const clamp = this._timelineDuration();
|
|
441
|
+
const updated2 = (0, import_core.updateAnnotationBoundaries)(
|
|
442
|
+
{
|
|
443
|
+
annotationIndex: index,
|
|
444
|
+
newTime: edgeTick + deltaTicks,
|
|
445
|
+
isDraggingStart: isStart,
|
|
446
|
+
annotations: tickData,
|
|
447
|
+
duration: clamp === Infinity ? Infinity : editor._secondsToTicks(clamp),
|
|
448
|
+
linkEndpoints: this.linkEndpoints
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
linkThreshold: import_core.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
452
|
+
minDuration: (0, import_core.annotationMinDurationTicks)(editor.ppqn)
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
applyTickBoundaryResults(elements, updated2, (t) => editor._ticksToSeconds(t));
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
const data = elements.map((el) => el.toAnnotationData());
|
|
459
|
+
const edge = isStart ? data[index].start : data[index].end;
|
|
460
|
+
const updated = (0, import_core.updateAnnotationBoundaries)({
|
|
461
|
+
annotationIndex: index,
|
|
462
|
+
newTime: edge + deltaMs / 1e3,
|
|
463
|
+
isDraggingStart: isStart,
|
|
464
|
+
annotations: data,
|
|
465
|
+
duration: this._timelineDuration(),
|
|
466
|
+
linkEndpoints: this.linkEndpoints
|
|
467
|
+
});
|
|
468
|
+
applyBoundaryResults(elements, updated);
|
|
469
|
+
}
|
|
470
|
+
_timelineDuration() {
|
|
471
|
+
return this._hostEditor()?._annotationClampDuration ?? Infinity;
|
|
472
|
+
}
|
|
473
|
+
_activeElement() {
|
|
474
|
+
if (this._activeAnnotationId === null) return null;
|
|
475
|
+
return this.annotationElements.find((el) => el.annotationId === this._activeAnnotationId) ?? null;
|
|
476
|
+
}
|
|
477
|
+
_hostEditor() {
|
|
478
|
+
return this.closest("daw-editor");
|
|
479
|
+
}
|
|
480
|
+
get annotationShortcuts() {
|
|
481
|
+
return this._annotationShortcuts;
|
|
482
|
+
}
|
|
483
|
+
set annotationShortcuts(value) {
|
|
484
|
+
this._annotationShortcuts = value;
|
|
485
|
+
this._resolvedShortcuts = null;
|
|
486
|
+
}
|
|
487
|
+
_shortcutEntries() {
|
|
488
|
+
if (!this._resolvedShortcuts) {
|
|
489
|
+
this._resolvedShortcuts = (0, import_core.resolveAnnotationShortcuts)(this._annotationShortcuts);
|
|
490
|
+
}
|
|
491
|
+
return this._resolvedShortcuts;
|
|
492
|
+
}
|
|
493
|
+
_runShortcutAction(action) {
|
|
494
|
+
switch (action) {
|
|
495
|
+
case "selectPrevious":
|
|
496
|
+
this.selectPrevious();
|
|
497
|
+
break;
|
|
498
|
+
case "selectNext":
|
|
499
|
+
this.selectNext();
|
|
500
|
+
break;
|
|
501
|
+
case "selectFirst":
|
|
502
|
+
this.selectFirst();
|
|
503
|
+
break;
|
|
504
|
+
case "selectLast":
|
|
505
|
+
this.selectLast();
|
|
506
|
+
break;
|
|
507
|
+
case "clearSelection":
|
|
508
|
+
this.clearSelection();
|
|
509
|
+
break;
|
|
510
|
+
case "moveStartEarlier":
|
|
511
|
+
this.moveStartBoundary(-10);
|
|
512
|
+
break;
|
|
513
|
+
case "moveStartLater":
|
|
514
|
+
this.moveStartBoundary(10);
|
|
515
|
+
break;
|
|
516
|
+
case "moveEndEarlier":
|
|
517
|
+
this.moveEndBoundary(-10);
|
|
518
|
+
break;
|
|
519
|
+
case "moveEndLater":
|
|
520
|
+
this.moveEndBoundary(10);
|
|
521
|
+
break;
|
|
522
|
+
case "playActive":
|
|
523
|
+
this.playActive();
|
|
524
|
+
break;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
createRenderRoot() {
|
|
528
|
+
return this;
|
|
529
|
+
}
|
|
530
|
+
connectedCallback() {
|
|
531
|
+
super.connectedCallback();
|
|
532
|
+
this.style.display = "none";
|
|
533
|
+
if (Object.prototype.hasOwnProperty.call(this, "annotationShortcuts")) {
|
|
534
|
+
const value = this["annotationShortcuts"];
|
|
535
|
+
delete this["annotationShortcuts"];
|
|
536
|
+
this.annotationShortcuts = value;
|
|
537
|
+
}
|
|
538
|
+
document.addEventListener("keydown", this._onKeyDownCapture, true);
|
|
539
|
+
setTimeout(() => {
|
|
540
|
+
this.dispatchEvent(
|
|
541
|
+
new CustomEvent("daw-annotation-track-connected", {
|
|
542
|
+
bubbles: true,
|
|
543
|
+
composed: true,
|
|
544
|
+
detail: { element: this }
|
|
545
|
+
})
|
|
546
|
+
);
|
|
547
|
+
}, 0);
|
|
548
|
+
this._childObserver = new MutationObserver(() => {
|
|
549
|
+
if (this._activeAnnotationId !== null && !this.annotationElements.some((el) => el.annotationId === this._activeAnnotationId)) {
|
|
550
|
+
this.activeAnnotationId = null;
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
this._childObserver.observe(this, { childList: true });
|
|
554
|
+
}
|
|
555
|
+
disconnectedCallback() {
|
|
556
|
+
super.disconnectedCallback();
|
|
557
|
+
document.removeEventListener("keydown", this._onKeyDownCapture, true);
|
|
558
|
+
this._childObserver?.disconnect();
|
|
559
|
+
this._childObserver = null;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
DawAnnotationTrackElement._boundaryActions = /* @__PURE__ */ new Set([
|
|
563
|
+
"moveStartEarlier",
|
|
564
|
+
"moveStartLater",
|
|
565
|
+
"moveEndEarlier",
|
|
566
|
+
"moveEndLater"
|
|
567
|
+
]);
|
|
568
|
+
__decorateClass([
|
|
569
|
+
(0, import_decorators2.property)({ type: Boolean, reflect: true })
|
|
570
|
+
], DawAnnotationTrackElement.prototype, "editable", 2);
|
|
571
|
+
__decorateClass([
|
|
572
|
+
(0, import_decorators2.property)({ type: Boolean, reflect: true, attribute: "link-endpoints" })
|
|
573
|
+
], DawAnnotationTrackElement.prototype, "linkEndpoints", 2);
|
|
574
|
+
__decorateClass([
|
|
575
|
+
(0, import_decorators2.property)({ type: Boolean, reflect: true, attribute: "continuous-play" })
|
|
576
|
+
], DawAnnotationTrackElement.prototype, "continuousPlay", 2);
|
|
577
|
+
__decorateClass([
|
|
578
|
+
(0, import_decorators2.property)({ type: Boolean, reflect: true, attribute: "keyboard-controls" })
|
|
579
|
+
], DawAnnotationTrackElement.prototype, "keyboardControls", 2);
|
|
580
|
+
__decorateClass([
|
|
581
|
+
(0, import_decorators2.property)({ reflect: true, attribute: "box-label" })
|
|
582
|
+
], DawAnnotationTrackElement.prototype, "boxLabel", 2);
|
|
583
|
+
__decorateClass([
|
|
584
|
+
(0, import_decorators2.property)({ reflect: true })
|
|
585
|
+
], DawAnnotationTrackElement.prototype, "name", 2);
|
|
586
|
+
DawAnnotationTrackElement = __decorateClass([
|
|
587
|
+
(0, import_decorators2.customElement)("daw-annotation-track")
|
|
588
|
+
], DawAnnotationTrackElement);
|
|
589
|
+
|
|
590
|
+
// src/elements/daw-annotation-list.ts
|
|
591
|
+
var import_lit3 = require("lit");
|
|
592
|
+
var import_decorators3 = require("lit/decorators.js");
|
|
593
|
+
var import_core2 = require("@waveform-playlist/core");
|
|
594
|
+
|
|
595
|
+
// src/utils/annotation-playing.ts
|
|
596
|
+
function computePlayingAnnotationId(annotations, time) {
|
|
597
|
+
const match = annotations.find((a) => a.start <= time && time < a.end);
|
|
598
|
+
return match?.id ?? null;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
// src/elements/daw-annotation-list.ts
|
|
602
|
+
function formatAnnotationTime(seconds) {
|
|
603
|
+
const whole = Math.floor(seconds);
|
|
604
|
+
const ms = Math.round((seconds - whole) * 1e3);
|
|
605
|
+
const s = whole % 60;
|
|
606
|
+
const m = (whole - s) / 60;
|
|
607
|
+
return m + ":" + String(s).padStart(2, "0") + "." + String(ms).padStart(3, "0");
|
|
608
|
+
}
|
|
609
|
+
var DawAnnotationListElement = class extends import_lit3.LitElement {
|
|
610
|
+
constructor() {
|
|
611
|
+
super(...arguments);
|
|
612
|
+
this.for = "";
|
|
613
|
+
this.timeDisplay = "time";
|
|
614
|
+
this._editingId = null;
|
|
615
|
+
this._activeId = null;
|
|
616
|
+
/** Playback-following highlight, separate from `_activeId` (selection) so
|
|
617
|
+
* playback never disturbs selection/keyboard editing. Driven by
|
|
618
|
+
* daw-timeupdate, cleared on daw-stop, retained on pause. */
|
|
619
|
+
this._playingId = null;
|
|
620
|
+
this._observer = null;
|
|
621
|
+
this._observedTrack = null;
|
|
622
|
+
this._warnedMissing = false;
|
|
623
|
+
/** Warn once per resolved `for` target when bars mode can't find a host
|
|
624
|
+
* editor — reset alongside `_warnedMissing` on `for` change so a
|
|
625
|
+
* retargeted list can warn again for its new target. */
|
|
626
|
+
this._warnedNoEditorForBars = false;
|
|
627
|
+
/** Set around `_cancelEdit`'s `span.blur()` so the resulting synchronous
|
|
628
|
+
* blur event doesn't re-enter `_commitEdit` (cancel already restores the
|
|
629
|
+
* text and clears `_editingId` itself). */
|
|
630
|
+
this._cancelling = false;
|
|
631
|
+
this._onSelect = (e) => {
|
|
632
|
+
if (e.target !== this.track) return;
|
|
633
|
+
this._activeId = e.detail.annotation?.id ?? null;
|
|
634
|
+
this.requestUpdate();
|
|
635
|
+
void this.updateComplete.then(() => {
|
|
636
|
+
const row = this.shadowRoot?.querySelector(".annotation-row.active");
|
|
637
|
+
row?.scrollIntoView?.({ block: "center" });
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
/**
|
|
641
|
+
* Update only on annotation-boundary crossings, not per animation frame.
|
|
642
|
+
* `shouldUpdate()` suppresses the resulting render while a row is being
|
|
643
|
+
* edited (`_editingId`) — intentional, not bypassed here. A boundary
|
|
644
|
+
* crossed mid-edit is caught up on the NEXT crossing after the edit ends;
|
|
645
|
+
* the highlight is briefly stale in that window, which is acceptable
|
|
646
|
+
* (edits are rare and short-lived relative to playback).
|
|
647
|
+
*/
|
|
648
|
+
this._onTimeUpdate = (e) => {
|
|
649
|
+
if (e.target !== this.track?.closest("daw-editor")) return;
|
|
650
|
+
const playingId = computePlayingAnnotationId(this.track?.annotations ?? [], e.detail.time);
|
|
651
|
+
if (playingId === this._playingId) return;
|
|
652
|
+
this._playingId = playingId;
|
|
653
|
+
this.requestUpdate();
|
|
654
|
+
void this.updateComplete.then(() => {
|
|
655
|
+
const row = this.shadowRoot?.querySelector(".annotation-row.playing");
|
|
656
|
+
row?.scrollIntoView?.({ block: "center" });
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
this._onStop = (e) => {
|
|
660
|
+
if (e.target !== this.track?.closest("daw-editor")) return;
|
|
661
|
+
if (this._playingId === null) return;
|
|
662
|
+
this._playingId = null;
|
|
663
|
+
this.requestUpdate();
|
|
664
|
+
};
|
|
665
|
+
}
|
|
666
|
+
get track() {
|
|
667
|
+
if (!this.for) return null;
|
|
668
|
+
const el = document.getElementById(this.for);
|
|
669
|
+
if (!el || el.tagName !== "DAW-ANNOTATION-TRACK") {
|
|
670
|
+
if (!this._warnedMissing) {
|
|
671
|
+
console.warn(
|
|
672
|
+
el ? '[dawcore] <daw-annotation-list for="' + this.for + '"> target is not a <daw-annotation-track>' : '[dawcore] <daw-annotation-list for="' + this.for + '"> target not found'
|
|
673
|
+
);
|
|
674
|
+
this._warnedMissing = true;
|
|
675
|
+
}
|
|
676
|
+
return null;
|
|
677
|
+
}
|
|
678
|
+
return el;
|
|
679
|
+
}
|
|
680
|
+
willUpdate(changed) {
|
|
681
|
+
if (changed.has("for")) {
|
|
682
|
+
this._warnedMissing = false;
|
|
683
|
+
this._warnedNoEditorForBars = false;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
connectedCallback() {
|
|
687
|
+
super.connectedCallback();
|
|
688
|
+
document.addEventListener("daw-annotation-select", this._onSelect);
|
|
689
|
+
document.addEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
690
|
+
document.addEventListener("daw-stop", this._onStop);
|
|
691
|
+
}
|
|
692
|
+
disconnectedCallback() {
|
|
693
|
+
super.disconnectedCallback();
|
|
694
|
+
document.removeEventListener("daw-annotation-select", this._onSelect);
|
|
695
|
+
document.removeEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
696
|
+
document.removeEventListener("daw-stop", this._onStop);
|
|
697
|
+
this._observer?.disconnect();
|
|
698
|
+
this._observer = null;
|
|
699
|
+
this._observedTrack = null;
|
|
700
|
+
}
|
|
701
|
+
shouldUpdate() {
|
|
702
|
+
return this._editingId === null;
|
|
703
|
+
}
|
|
704
|
+
updated() {
|
|
705
|
+
this._ensureObserver();
|
|
706
|
+
this._syncRowText();
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Text content is set imperatively, NOT bound as a Lit expression.
|
|
710
|
+
* contenteditable mutates the span's DOM directly as the user types —
|
|
711
|
+
* that ejects lit-html's ChildPart marker comments for any binding at
|
|
712
|
+
* that position, so a later Lit-driven re-render of the same row throws
|
|
713
|
+
* "ChildPart has no parentNode". Keeping the span's children entirely
|
|
714
|
+
* outside Lit's diffing sidesteps the crash; the (soon-to-commit) edited
|
|
715
|
+
* row is skipped via the _editingId check.
|
|
716
|
+
*/
|
|
717
|
+
_syncRowText() {
|
|
718
|
+
const annotations = this.track?.annotations ?? [];
|
|
719
|
+
const spans = this.shadowRoot?.querySelectorAll(".annotation-row-text") ?? [];
|
|
720
|
+
spans.forEach((span) => {
|
|
721
|
+
const id = span.dataset.id;
|
|
722
|
+
if (id === void 0 || id === this._editingId) return;
|
|
723
|
+
const a = annotations.find((x) => x.id === id);
|
|
724
|
+
if (!a) return;
|
|
725
|
+
const text = a.lines.join(" ");
|
|
726
|
+
if (span.textContent !== text) span.textContent = text;
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
/** (Re)attach the MutationObserver when the resolved track changes. */
|
|
730
|
+
_ensureObserver() {
|
|
731
|
+
const track = this.track;
|
|
732
|
+
if (track === this._observedTrack) return;
|
|
733
|
+
this._observer?.disconnect();
|
|
734
|
+
this._observedTrack = track;
|
|
735
|
+
if (!track) return;
|
|
736
|
+
this._observer = new MutationObserver(() => this.requestUpdate());
|
|
737
|
+
this._observer.observe(track, {
|
|
738
|
+
childList: true,
|
|
739
|
+
subtree: true,
|
|
740
|
+
characterData: true,
|
|
741
|
+
attributes: true,
|
|
742
|
+
attributeFilter: ["start", "end", "id", "editable"]
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
_onRowClick(a) {
|
|
746
|
+
const track = this.track;
|
|
747
|
+
if (!track) return;
|
|
748
|
+
track.activeAnnotationId = a.id;
|
|
749
|
+
const editor = track.closest("daw-editor");
|
|
750
|
+
editor?.seekTo?.(a.start);
|
|
751
|
+
}
|
|
752
|
+
/** Formats a row's times span per `timeDisplay`. `'bars'` resolves the
|
|
753
|
+
* host editor once (shared across all rows in a render) and falls back
|
|
754
|
+
* to time display, warning once, when no editor is found. */
|
|
755
|
+
_formatTimes(a, editor) {
|
|
756
|
+
if (this.timeDisplay === "bars") {
|
|
757
|
+
if (editor) {
|
|
758
|
+
const isTickBased = a.startTick !== void 0 && a.endTick !== void 0;
|
|
759
|
+
const startTick = isTickBased ? a.startTick : editor._secondsToTicks(a.start);
|
|
760
|
+
const endTick = isTickBased ? a.endTick : editor._secondsToTicks(a.end);
|
|
761
|
+
const start = (0, import_core2.ticksToBarBeat)(startTick, editor._meterEntries, editor.ppqn);
|
|
762
|
+
const end = (0, import_core2.ticksToBarBeat)(endTick, editor._meterEntries, editor.ppqn);
|
|
763
|
+
return start.bar + "." + start.beat + " \u2013 " + end.bar + "." + end.beat;
|
|
764
|
+
}
|
|
765
|
+
if (!this._warnedNoEditorForBars) {
|
|
766
|
+
console.warn(
|
|
767
|
+
'[dawcore] <daw-annotation-list for="' + this.for + '" time-display="bars"> found no parent <daw-editor> \u2014 falling back to time display'
|
|
768
|
+
);
|
|
769
|
+
this._warnedNoEditorForBars = true;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return formatAnnotationTime(a.start) + " \u2013 " + formatAnnotationTime(a.end);
|
|
773
|
+
}
|
|
774
|
+
_annotationElement(id) {
|
|
775
|
+
return this.track?.annotationElements.find((el) => el.annotationId === id) ?? null;
|
|
776
|
+
}
|
|
777
|
+
_commitEdit(a, span) {
|
|
778
|
+
if (this._cancelling) return;
|
|
779
|
+
this._editingId = null;
|
|
780
|
+
const el = this._annotationElement(a.id);
|
|
781
|
+
if (el) el.textContent = span.textContent?.trim() ?? "";
|
|
782
|
+
this.requestUpdate();
|
|
783
|
+
}
|
|
784
|
+
_cancelEdit(a, span) {
|
|
785
|
+
this._editingId = null;
|
|
786
|
+
span.textContent = a.lines.join("\n");
|
|
787
|
+
this._cancelling = true;
|
|
788
|
+
try {
|
|
789
|
+
span.blur();
|
|
790
|
+
} finally {
|
|
791
|
+
this._cancelling = false;
|
|
792
|
+
}
|
|
793
|
+
this.requestUpdate();
|
|
794
|
+
}
|
|
795
|
+
render() {
|
|
796
|
+
const track = this.track;
|
|
797
|
+
const annotations = track?.annotations ?? [];
|
|
798
|
+
const editable = track?.editable ?? false;
|
|
799
|
+
const editor = this.timeDisplay === "bars" ? track?.closest("daw-editor") ?? null : null;
|
|
800
|
+
return import_lit3.html`
|
|
801
|
+
${annotations.map(
|
|
802
|
+
(a) => import_lit3.html`
|
|
803
|
+
<div
|
|
804
|
+
class="annotation-row ${a.id === this._activeId ? "active" : ""} ${a.id === this._playingId ? "playing" : ""}"
|
|
805
|
+
@click=${(e) => {
|
|
806
|
+
if (this._editingId === a.id && this._activeId === a.id) return;
|
|
807
|
+
e.stopPropagation();
|
|
808
|
+
this._onRowClick(a);
|
|
809
|
+
}}
|
|
810
|
+
>
|
|
811
|
+
<span class="annotation-row-times"> ${this._formatTimes(a, editor)} </span>
|
|
812
|
+
<span
|
|
813
|
+
class="annotation-row-text"
|
|
814
|
+
data-id=${a.id}
|
|
815
|
+
contenteditable=${editable ? "true" : import_lit3.nothing}
|
|
816
|
+
@focus=${() => {
|
|
817
|
+
if (editable) this._editingId = a.id;
|
|
818
|
+
}}
|
|
819
|
+
@blur=${(e) => this._commitEdit(a, e.target)}
|
|
820
|
+
@keydown=${(e) => {
|
|
821
|
+
if (!editable) return;
|
|
822
|
+
e.stopPropagation();
|
|
823
|
+
if (e.key === "Enter") {
|
|
824
|
+
e.preventDefault();
|
|
825
|
+
e.target.blur();
|
|
826
|
+
} else if (e.key === "Escape") {
|
|
827
|
+
this._cancelEdit(a, e.target);
|
|
828
|
+
}
|
|
829
|
+
}}
|
|
830
|
+
></span>
|
|
831
|
+
</div>
|
|
832
|
+
`
|
|
833
|
+
)}
|
|
834
|
+
`;
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
DawAnnotationListElement.styles = import_lit3.css`
|
|
838
|
+
:host {
|
|
839
|
+
display: block;
|
|
840
|
+
max-height: var(--daw-annotation-list-max-height, 240px);
|
|
841
|
+
overflow-y: auto;
|
|
842
|
+
background: var(--daw-annotation-list-background, #16213e);
|
|
843
|
+
color: var(--daw-annotation-text-color, #e0d4c8);
|
|
844
|
+
font-family: system-ui, sans-serif;
|
|
845
|
+
font-size: 13px;
|
|
846
|
+
}
|
|
847
|
+
.annotation-row {
|
|
848
|
+
display: flex;
|
|
849
|
+
gap: 10px;
|
|
850
|
+
align-items: baseline;
|
|
851
|
+
padding: 6px 10px;
|
|
852
|
+
border-bottom: 1px solid rgba(255, 255, 255, 0.06);
|
|
853
|
+
cursor: pointer;
|
|
854
|
+
}
|
|
855
|
+
.annotation-row.playing {
|
|
856
|
+
background: var(--daw-annotation-playing-background, rgba(196, 154, 108, 0.12));
|
|
857
|
+
box-shadow: inset 2px 0 0 var(--daw-annotation-box-border, #c49a6c);
|
|
858
|
+
}
|
|
859
|
+
.annotation-row.active {
|
|
860
|
+
background: var(--daw-annotation-active-background, rgba(196, 154, 108, 0.25));
|
|
861
|
+
}
|
|
862
|
+
.annotation-row-times {
|
|
863
|
+
font-variant-numeric: tabular-nums;
|
|
864
|
+
font-size: 11px;
|
|
865
|
+
opacity: 0.7;
|
|
866
|
+
white-space: nowrap;
|
|
867
|
+
}
|
|
868
|
+
.annotation-row-text {
|
|
869
|
+
flex: 1;
|
|
870
|
+
min-width: 0;
|
|
871
|
+
}
|
|
872
|
+
.annotation-row-text[contenteditable='true'] {
|
|
873
|
+
cursor: text;
|
|
874
|
+
outline-offset: 2px;
|
|
875
|
+
}
|
|
876
|
+
.annotation-row-text:empty::before {
|
|
877
|
+
content: '—';
|
|
878
|
+
opacity: 0.4;
|
|
879
|
+
}
|
|
880
|
+
`;
|
|
881
|
+
__decorateClass([
|
|
882
|
+
(0, import_decorators3.property)()
|
|
883
|
+
], DawAnnotationListElement.prototype, "for", 2);
|
|
884
|
+
__decorateClass([
|
|
885
|
+
(0, import_decorators3.property)({ type: String, attribute: "time-display", reflect: true })
|
|
886
|
+
], DawAnnotationListElement.prototype, "timeDisplay", 2);
|
|
887
|
+
__decorateClass([
|
|
888
|
+
(0, import_decorators3.state)()
|
|
889
|
+
], DawAnnotationListElement.prototype, "_editingId", 2);
|
|
890
|
+
DawAnnotationListElement = __decorateClass([
|
|
891
|
+
(0, import_decorators3.customElement)("daw-annotation-list")
|
|
892
|
+
], DawAnnotationListElement);
|
|
893
|
+
|
|
894
|
+
// src/elements/daw-clip.ts
|
|
895
|
+
var import_lit4 = require("lit");
|
|
896
|
+
var import_decorators4 = require("lit/decorators.js");
|
|
897
|
+
var DawClipElement = class extends import_lit4.LitElement {
|
|
87
898
|
constructor() {
|
|
88
899
|
super(...arguments);
|
|
89
900
|
this.src = "";
|
|
@@ -188,55 +999,55 @@ var DawClipElement = class extends import_lit.LitElement {
|
|
|
188
999
|
}
|
|
189
1000
|
};
|
|
190
1001
|
__decorateClass([
|
|
191
|
-
(0,
|
|
1002
|
+
(0, import_decorators4.property)()
|
|
192
1003
|
], DawClipElement.prototype, "src", 2);
|
|
193
1004
|
__decorateClass([
|
|
194
|
-
(0,
|
|
1005
|
+
(0, import_decorators4.property)({ attribute: "peaks-src" })
|
|
195
1006
|
], DawClipElement.prototype, "peaksSrc", 2);
|
|
196
1007
|
__decorateClass([
|
|
197
|
-
(0,
|
|
1008
|
+
(0, import_decorators4.property)({ type: Number })
|
|
198
1009
|
], DawClipElement.prototype, "start", 2);
|
|
199
1010
|
__decorateClass([
|
|
200
|
-
(0,
|
|
1011
|
+
(0, import_decorators4.property)({ type: Number })
|
|
201
1012
|
], DawClipElement.prototype, "duration", 2);
|
|
202
1013
|
__decorateClass([
|
|
203
|
-
(0,
|
|
1014
|
+
(0, import_decorators4.property)({ type: Number })
|
|
204
1015
|
], DawClipElement.prototype, "offset", 2);
|
|
205
1016
|
__decorateClass([
|
|
206
|
-
(0,
|
|
1017
|
+
(0, import_decorators4.property)({ type: Number })
|
|
207
1018
|
], DawClipElement.prototype, "gain", 2);
|
|
208
1019
|
__decorateClass([
|
|
209
|
-
(0,
|
|
1020
|
+
(0, import_decorators4.property)()
|
|
210
1021
|
], DawClipElement.prototype, "name", 2);
|
|
211
1022
|
__decorateClass([
|
|
212
|
-
(0,
|
|
1023
|
+
(0, import_decorators4.property)()
|
|
213
1024
|
], DawClipElement.prototype, "color", 2);
|
|
214
1025
|
__decorateClass([
|
|
215
|
-
(0,
|
|
1026
|
+
(0, import_decorators4.property)({ type: Number, attribute: "fade-in" })
|
|
216
1027
|
], DawClipElement.prototype, "fadeIn", 2);
|
|
217
1028
|
__decorateClass([
|
|
218
|
-
(0,
|
|
1029
|
+
(0, import_decorators4.property)({ type: Number, attribute: "fade-out" })
|
|
219
1030
|
], DawClipElement.prototype, "fadeOut", 2);
|
|
220
1031
|
__decorateClass([
|
|
221
|
-
(0,
|
|
1032
|
+
(0, import_decorators4.property)({ attribute: "fade-type" })
|
|
222
1033
|
], DawClipElement.prototype, "fadeType", 2);
|
|
223
1034
|
__decorateClass([
|
|
224
|
-
(0,
|
|
1035
|
+
(0, import_decorators4.property)({ attribute: false })
|
|
225
1036
|
], DawClipElement.prototype, "midiNotes", 2);
|
|
226
1037
|
__decorateClass([
|
|
227
|
-
(0,
|
|
1038
|
+
(0, import_decorators4.property)({ type: Number, attribute: "midi-channel", noAccessor: true })
|
|
228
1039
|
], DawClipElement.prototype, "midiChannel", 1);
|
|
229
1040
|
__decorateClass([
|
|
230
|
-
(0,
|
|
1041
|
+
(0, import_decorators4.property)({ type: Number, attribute: "midi-program", noAccessor: true })
|
|
231
1042
|
], DawClipElement.prototype, "midiProgram", 1);
|
|
232
1043
|
DawClipElement = __decorateClass([
|
|
233
|
-
(0,
|
|
1044
|
+
(0, import_decorators4.customElement)("daw-clip")
|
|
234
1045
|
], DawClipElement);
|
|
235
1046
|
|
|
236
1047
|
// src/elements/daw-track.ts
|
|
237
|
-
var
|
|
238
|
-
var
|
|
239
|
-
var DawTrackElement = class extends
|
|
1048
|
+
var import_lit5 = require("lit");
|
|
1049
|
+
var import_decorators5 = require("lit/decorators.js");
|
|
1050
|
+
var DawTrackElement = class extends import_lit5.LitElement {
|
|
240
1051
|
constructor() {
|
|
241
1052
|
super(...arguments);
|
|
242
1053
|
this.src = "";
|
|
@@ -374,36 +1185,36 @@ var DawTrackElement = class extends import_lit2.LitElement {
|
|
|
374
1185
|
}
|
|
375
1186
|
};
|
|
376
1187
|
__decorateClass([
|
|
377
|
-
(0,
|
|
1188
|
+
(0, import_decorators5.property)()
|
|
378
1189
|
], DawTrackElement.prototype, "src", 2);
|
|
379
1190
|
__decorateClass([
|
|
380
|
-
(0,
|
|
1191
|
+
(0, import_decorators5.property)()
|
|
381
1192
|
], DawTrackElement.prototype, "name", 2);
|
|
382
1193
|
__decorateClass([
|
|
383
|
-
(0,
|
|
1194
|
+
(0, import_decorators5.property)({ type: Number })
|
|
384
1195
|
], DawTrackElement.prototype, "volume", 2);
|
|
385
1196
|
__decorateClass([
|
|
386
|
-
(0,
|
|
1197
|
+
(0, import_decorators5.property)({ type: Number })
|
|
387
1198
|
], DawTrackElement.prototype, "pan", 2);
|
|
388
1199
|
__decorateClass([
|
|
389
|
-
(0,
|
|
1200
|
+
(0, import_decorators5.property)({ type: Boolean })
|
|
390
1201
|
], DawTrackElement.prototype, "muted", 2);
|
|
391
1202
|
__decorateClass([
|
|
392
|
-
(0,
|
|
1203
|
+
(0, import_decorators5.property)({ type: Boolean })
|
|
393
1204
|
], DawTrackElement.prototype, "soloed", 2);
|
|
394
1205
|
__decorateClass([
|
|
395
|
-
(0,
|
|
1206
|
+
(0, import_decorators5.property)({ attribute: "render-mode", noAccessor: true })
|
|
396
1207
|
], DawTrackElement.prototype, "renderMode", 1);
|
|
397
1208
|
__decorateClass([
|
|
398
|
-
(0,
|
|
1209
|
+
(0, import_decorators5.property)({ attribute: false })
|
|
399
1210
|
], DawTrackElement.prototype, "spectrogramConfig", 2);
|
|
400
1211
|
DawTrackElement = __decorateClass([
|
|
401
|
-
(0,
|
|
1212
|
+
(0, import_decorators5.customElement)("daw-track")
|
|
402
1213
|
], DawTrackElement);
|
|
403
1214
|
|
|
404
1215
|
// src/elements/daw-waveform.ts
|
|
405
|
-
var
|
|
406
|
-
var
|
|
1216
|
+
var import_lit6 = require("lit");
|
|
1217
|
+
var import_decorators6 = require("lit/decorators.js");
|
|
407
1218
|
|
|
408
1219
|
// src/utils/peak-rendering.ts
|
|
409
1220
|
function aggregatePeaks(data, bits, startIndex, endIndex) {
|
|
@@ -489,7 +1300,7 @@ function groupDirtyByChunk(dirtyPixels, step, barWidth) {
|
|
|
489
1300
|
}
|
|
490
1301
|
return dirtyByChunk;
|
|
491
1302
|
}
|
|
492
|
-
var DawWaveformElement = class extends
|
|
1303
|
+
var DawWaveformElement = class extends import_lit6.LitElement {
|
|
493
1304
|
constructor() {
|
|
494
1305
|
super(...arguments);
|
|
495
1306
|
this._peaks = new Int16Array(0);
|
|
@@ -695,11 +1506,11 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
695
1506
|
render() {
|
|
696
1507
|
const indices = this._getVisibleChunkIndices();
|
|
697
1508
|
const dpr = typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
|
|
698
|
-
return
|
|
1509
|
+
return import_lit6.html`
|
|
699
1510
|
<div class="container" style="width: ${this.length}px; height: ${this.waveHeight}px;">
|
|
700
1511
|
${indices.map((i) => {
|
|
701
1512
|
const width = Math.min(MAX_CANVAS_WIDTH, this.length - i * MAX_CANVAS_WIDTH);
|
|
702
|
-
return
|
|
1513
|
+
return import_lit6.html`
|
|
703
1514
|
<canvas
|
|
704
1515
|
data-index=${i}
|
|
705
1516
|
width=${width * dpr}
|
|
@@ -739,7 +1550,7 @@ var DawWaveformElement = class extends import_lit3.LitElement {
|
|
|
739
1550
|
}
|
|
740
1551
|
}
|
|
741
1552
|
};
|
|
742
|
-
DawWaveformElement.styles =
|
|
1553
|
+
DawWaveformElement.styles = import_lit6.css`
|
|
743
1554
|
:host {
|
|
744
1555
|
display: block;
|
|
745
1556
|
position: relative;
|
|
@@ -753,39 +1564,39 @@ DawWaveformElement.styles = import_lit3.css`
|
|
|
753
1564
|
}
|
|
754
1565
|
`;
|
|
755
1566
|
__decorateClass([
|
|
756
|
-
(0,
|
|
1567
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
757
1568
|
], DawWaveformElement.prototype, "length", 2);
|
|
758
1569
|
__decorateClass([
|
|
759
|
-
(0,
|
|
1570
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
760
1571
|
], DawWaveformElement.prototype, "waveHeight", 2);
|
|
761
1572
|
__decorateClass([
|
|
762
|
-
(0,
|
|
1573
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
763
1574
|
], DawWaveformElement.prototype, "barWidth", 2);
|
|
764
1575
|
__decorateClass([
|
|
765
|
-
(0,
|
|
1576
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
766
1577
|
], DawWaveformElement.prototype, "barGap", 2);
|
|
767
1578
|
__decorateClass([
|
|
768
|
-
(0,
|
|
1579
|
+
(0, import_decorators6.property)({ type: Boolean, attribute: false })
|
|
769
1580
|
], DawWaveformElement.prototype, "roundedBars", 2);
|
|
770
1581
|
__decorateClass([
|
|
771
|
-
(0,
|
|
1582
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
772
1583
|
], DawWaveformElement.prototype, "visibleStart", 2);
|
|
773
1584
|
__decorateClass([
|
|
774
|
-
(0,
|
|
1585
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
775
1586
|
], DawWaveformElement.prototype, "visibleEnd", 2);
|
|
776
1587
|
__decorateClass([
|
|
777
|
-
(0,
|
|
1588
|
+
(0, import_decorators6.property)({ type: Number, attribute: false })
|
|
778
1589
|
], DawWaveformElement.prototype, "originX", 2);
|
|
779
1590
|
__decorateClass([
|
|
780
|
-
(0,
|
|
1591
|
+
(0, import_decorators6.property)({ attribute: false })
|
|
781
1592
|
], DawWaveformElement.prototype, "segments", 2);
|
|
782
1593
|
DawWaveformElement = __decorateClass([
|
|
783
|
-
(0,
|
|
1594
|
+
(0, import_decorators6.customElement)("daw-waveform")
|
|
784
1595
|
], DawWaveformElement);
|
|
785
1596
|
|
|
786
1597
|
// src/elements/daw-piano-roll.ts
|
|
787
|
-
var
|
|
788
|
-
var
|
|
1598
|
+
var import_lit7 = require("lit");
|
|
1599
|
+
var import_decorators7 = require("lit/decorators.js");
|
|
789
1600
|
var MAX_CANVAS_WIDTH2 = 1e3;
|
|
790
1601
|
var LAYOUT_PROPS2 = /* @__PURE__ */ new Set([
|
|
791
1602
|
"length",
|
|
@@ -796,7 +1607,7 @@ var LAYOUT_PROPS2 = /* @__PURE__ */ new Set([
|
|
|
796
1607
|
"midiNotes",
|
|
797
1608
|
"selected"
|
|
798
1609
|
]);
|
|
799
|
-
var DawPianoRollElement = class extends
|
|
1610
|
+
var DawPianoRollElement = class extends import_lit7.LitElement {
|
|
800
1611
|
constructor() {
|
|
801
1612
|
super(...arguments);
|
|
802
1613
|
this.midiNotes = [];
|
|
@@ -928,7 +1739,7 @@ var DawPianoRollElement = class extends import_lit4.LitElement {
|
|
|
928
1739
|
}
|
|
929
1740
|
render() {
|
|
930
1741
|
if (this.length <= 0)
|
|
931
|
-
return
|
|
1742
|
+
return import_lit7.html`<div class="container" style="width: 0; height: ${this.waveHeight}px;"></div>`;
|
|
932
1743
|
const dpr = typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
|
|
933
1744
|
const visibleIndices = getVisibleChunkIndices(
|
|
934
1745
|
this.length,
|
|
@@ -937,12 +1748,12 @@ var DawPianoRollElement = class extends import_lit4.LitElement {
|
|
|
937
1748
|
this.visibleEnd,
|
|
938
1749
|
this.originX
|
|
939
1750
|
);
|
|
940
|
-
return
|
|
1751
|
+
return import_lit7.html`
|
|
941
1752
|
<div class="container" style="width: ${this.length}px; height: ${this.waveHeight}px;">
|
|
942
1753
|
${visibleIndices.map((i) => {
|
|
943
1754
|
const chunkLeft = i * MAX_CANVAS_WIDTH2;
|
|
944
1755
|
const chunkWidth = Math.min(this.length - chunkLeft, MAX_CANVAS_WIDTH2);
|
|
945
|
-
return
|
|
1756
|
+
return import_lit7.html`<canvas
|
|
946
1757
|
data-index=${i}
|
|
947
1758
|
width=${chunkWidth * dpr}
|
|
948
1759
|
height=${this.waveHeight * dpr}
|
|
@@ -953,7 +1764,7 @@ var DawPianoRollElement = class extends import_lit4.LitElement {
|
|
|
953
1764
|
`;
|
|
954
1765
|
}
|
|
955
1766
|
};
|
|
956
|
-
DawPianoRollElement.styles =
|
|
1767
|
+
DawPianoRollElement.styles = import_lit7.css`
|
|
957
1768
|
:host {
|
|
958
1769
|
display: block;
|
|
959
1770
|
position: relative;
|
|
@@ -970,49 +1781,49 @@ DawPianoRollElement.styles = import_lit4.css`
|
|
|
970
1781
|
}
|
|
971
1782
|
`;
|
|
972
1783
|
__decorateClass([
|
|
973
|
-
(0,
|
|
1784
|
+
(0, import_decorators7.property)({ attribute: false })
|
|
974
1785
|
], DawPianoRollElement.prototype, "midiNotes", 2);
|
|
975
1786
|
__decorateClass([
|
|
976
|
-
(0,
|
|
1787
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
977
1788
|
], DawPianoRollElement.prototype, "length", 2);
|
|
978
1789
|
__decorateClass([
|
|
979
|
-
(0,
|
|
1790
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
980
1791
|
], DawPianoRollElement.prototype, "waveHeight", 2);
|
|
981
1792
|
__decorateClass([
|
|
982
|
-
(0,
|
|
1793
|
+
(0, import_decorators7.property)({ type: Number, attribute: "samples-per-pixel", noAccessor: true })
|
|
983
1794
|
], DawPianoRollElement.prototype, "samplesPerPixel", 1);
|
|
984
1795
|
__decorateClass([
|
|
985
|
-
(0,
|
|
1796
|
+
(0, import_decorators7.property)({ type: Number, attribute: "sample-rate", noAccessor: true })
|
|
986
1797
|
], DawPianoRollElement.prototype, "sampleRate", 1);
|
|
987
1798
|
__decorateClass([
|
|
988
|
-
(0,
|
|
1799
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
989
1800
|
], DawPianoRollElement.prototype, "clipOffsetSeconds", 2);
|
|
990
1801
|
__decorateClass([
|
|
991
|
-
(0,
|
|
1802
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
992
1803
|
], DawPianoRollElement.prototype, "visibleStart", 2);
|
|
993
1804
|
__decorateClass([
|
|
994
|
-
(0,
|
|
1805
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
995
1806
|
], DawPianoRollElement.prototype, "visibleEnd", 2);
|
|
996
1807
|
__decorateClass([
|
|
997
|
-
(0,
|
|
1808
|
+
(0, import_decorators7.property)({ type: Number, attribute: false })
|
|
998
1809
|
], DawPianoRollElement.prototype, "originX", 2);
|
|
999
1810
|
__decorateClass([
|
|
1000
|
-
(0,
|
|
1811
|
+
(0, import_decorators7.property)({ type: Boolean, reflect: true })
|
|
1001
1812
|
], DawPianoRollElement.prototype, "selected", 2);
|
|
1002
1813
|
DawPianoRollElement = __decorateClass([
|
|
1003
|
-
(0,
|
|
1814
|
+
(0, import_decorators7.customElement)("daw-piano-roll")
|
|
1004
1815
|
], DawPianoRollElement);
|
|
1005
1816
|
|
|
1006
1817
|
// src/elements/daw-playhead.ts
|
|
1007
|
-
var
|
|
1008
|
-
var
|
|
1009
|
-
var DawPlayheadElement = class extends
|
|
1818
|
+
var import_lit8 = require("lit");
|
|
1819
|
+
var import_decorators8 = require("lit/decorators.js");
|
|
1820
|
+
var DawPlayheadElement = class extends import_lit8.LitElement {
|
|
1010
1821
|
constructor() {
|
|
1011
1822
|
super(...arguments);
|
|
1012
1823
|
this._line = null;
|
|
1013
1824
|
}
|
|
1014
1825
|
render() {
|
|
1015
|
-
return
|
|
1826
|
+
return import_lit8.html`<div></div>`;
|
|
1016
1827
|
}
|
|
1017
1828
|
firstUpdated() {
|
|
1018
1829
|
this._line = this.shadowRoot.querySelector("div");
|
|
@@ -1026,7 +1837,7 @@ var DawPlayheadElement = class extends import_lit5.LitElement {
|
|
|
1026
1837
|
}
|
|
1027
1838
|
}
|
|
1028
1839
|
};
|
|
1029
|
-
DawPlayheadElement.styles =
|
|
1840
|
+
DawPlayheadElement.styles = import_lit8.css`
|
|
1030
1841
|
:host {
|
|
1031
1842
|
position: absolute;
|
|
1032
1843
|
top: 0;
|
|
@@ -1045,13 +1856,13 @@ DawPlayheadElement.styles = import_lit5.css`
|
|
|
1045
1856
|
}
|
|
1046
1857
|
`;
|
|
1047
1858
|
DawPlayheadElement = __decorateClass([
|
|
1048
|
-
(0,
|
|
1859
|
+
(0, import_decorators8.customElement)("daw-playhead")
|
|
1049
1860
|
], DawPlayheadElement);
|
|
1050
1861
|
|
|
1051
1862
|
// src/elements/daw-transport.ts
|
|
1052
|
-
var
|
|
1053
|
-
var
|
|
1054
|
-
var DawTransportElement = class extends
|
|
1863
|
+
var import_lit9 = require("lit");
|
|
1864
|
+
var import_decorators9 = require("lit/decorators.js");
|
|
1865
|
+
var DawTransportElement = class extends import_lit9.LitElement {
|
|
1055
1866
|
constructor() {
|
|
1056
1867
|
super(...arguments);
|
|
1057
1868
|
this.for = "";
|
|
@@ -1066,18 +1877,18 @@ var DawTransportElement = class extends import_lit6.LitElement {
|
|
|
1066
1877
|
}
|
|
1067
1878
|
};
|
|
1068
1879
|
__decorateClass([
|
|
1069
|
-
(0,
|
|
1880
|
+
(0, import_decorators9.property)()
|
|
1070
1881
|
], DawTransportElement.prototype, "for", 2);
|
|
1071
1882
|
DawTransportElement = __decorateClass([
|
|
1072
|
-
(0,
|
|
1883
|
+
(0, import_decorators9.customElement)("daw-transport")
|
|
1073
1884
|
], DawTransportElement);
|
|
1074
1885
|
|
|
1075
1886
|
// src/elements/daw-play-button.ts
|
|
1076
|
-
var
|
|
1077
|
-
var
|
|
1887
|
+
var import_lit11 = require("lit");
|
|
1888
|
+
var import_decorators10 = require("lit/decorators.js");
|
|
1078
1889
|
|
|
1079
1890
|
// src/elements/daw-transport-button.ts
|
|
1080
|
-
var
|
|
1891
|
+
var import_lit10 = require("lit");
|
|
1081
1892
|
|
|
1082
1893
|
// src/utils/transport-capability.ts
|
|
1083
1894
|
function resolveTransportTarget(el) {
|
|
@@ -1118,7 +1929,7 @@ function warnUnsupportedOnce(element, methods) {
|
|
|
1118
1929
|
}
|
|
1119
1930
|
|
|
1120
1931
|
// src/elements/daw-transport-button.ts
|
|
1121
|
-
var DawTransportButton = class extends
|
|
1932
|
+
var DawTransportButton = class extends import_lit10.LitElement {
|
|
1122
1933
|
constructor() {
|
|
1123
1934
|
super(...arguments);
|
|
1124
1935
|
this._onCapabilityPointerEnter = () => {
|
|
@@ -1174,7 +1985,7 @@ var DawTransportButton = class extends import_lit7.LitElement {
|
|
|
1174
1985
|
/** Methods the transport target must implement for this control to be
|
|
1175
1986
|
* enabled. Empty = works with any target. */
|
|
1176
1987
|
DawTransportButton.requiredTargetMethods = [];
|
|
1177
|
-
DawTransportButton.styles =
|
|
1988
|
+
DawTransportButton.styles = import_lit10.css`
|
|
1178
1989
|
button {
|
|
1179
1990
|
cursor: pointer;
|
|
1180
1991
|
background: var(--daw-controls-background, #1a1a2e);
|
|
@@ -1241,7 +2052,7 @@ var DawPlayButtonElement = class extends DawTransportButton {
|
|
|
1241
2052
|
}
|
|
1242
2053
|
}
|
|
1243
2054
|
render() {
|
|
1244
|
-
return
|
|
2055
|
+
return import_lit11.html`
|
|
1245
2056
|
<button part="button" ?disabled=${this._isRecording} @click=${this._onClick}>
|
|
1246
2057
|
<slot>Play</slot>
|
|
1247
2058
|
</button>
|
|
@@ -1259,15 +2070,15 @@ var DawPlayButtonElement = class extends DawTransportButton {
|
|
|
1259
2070
|
}
|
|
1260
2071
|
};
|
|
1261
2072
|
__decorateClass([
|
|
1262
|
-
(0,
|
|
2073
|
+
(0, import_decorators10.state)()
|
|
1263
2074
|
], DawPlayButtonElement.prototype, "_isRecording", 2);
|
|
1264
2075
|
DawPlayButtonElement = __decorateClass([
|
|
1265
|
-
(0,
|
|
2076
|
+
(0, import_decorators10.customElement)("daw-play-button")
|
|
1266
2077
|
], DawPlayButtonElement);
|
|
1267
2078
|
|
|
1268
2079
|
// src/elements/daw-pause-button.ts
|
|
1269
|
-
var
|
|
1270
|
-
var
|
|
2080
|
+
var import_lit12 = require("lit");
|
|
2081
|
+
var import_decorators11 = require("lit/decorators.js");
|
|
1271
2082
|
var DawPauseButtonElement = class extends DawTransportButton {
|
|
1272
2083
|
constructor() {
|
|
1273
2084
|
super(...arguments);
|
|
@@ -1329,7 +2140,7 @@ var DawPauseButtonElement = class extends DawTransportButton {
|
|
|
1329
2140
|
}
|
|
1330
2141
|
}
|
|
1331
2142
|
render() {
|
|
1332
|
-
return
|
|
2143
|
+
return import_lit12.html`
|
|
1333
2144
|
<button part="button" ?data-paused=${this._isPaused} @click=${this._onClick}>
|
|
1334
2145
|
<slot>Pause</slot>
|
|
1335
2146
|
</button>
|
|
@@ -1352,7 +2163,7 @@ var DawPauseButtonElement = class extends DawTransportButton {
|
|
|
1352
2163
|
};
|
|
1353
2164
|
DawPauseButtonElement.styles = [
|
|
1354
2165
|
DawTransportButton.styles,
|
|
1355
|
-
|
|
2166
|
+
import_lit12.css`
|
|
1356
2167
|
button[data-paused] {
|
|
1357
2168
|
background: rgba(255, 255, 255, 0.1);
|
|
1358
2169
|
border-color: var(--daw-controls-text, #e0d4c8);
|
|
@@ -1360,21 +2171,21 @@ DawPauseButtonElement.styles = [
|
|
|
1360
2171
|
`
|
|
1361
2172
|
];
|
|
1362
2173
|
__decorateClass([
|
|
1363
|
-
(0,
|
|
2174
|
+
(0, import_decorators11.state)()
|
|
1364
2175
|
], DawPauseButtonElement.prototype, "_isPaused", 2);
|
|
1365
2176
|
__decorateClass([
|
|
1366
|
-
(0,
|
|
2177
|
+
(0, import_decorators11.state)()
|
|
1367
2178
|
], DawPauseButtonElement.prototype, "_isRecording", 2);
|
|
1368
2179
|
DawPauseButtonElement = __decorateClass([
|
|
1369
|
-
(0,
|
|
2180
|
+
(0, import_decorators11.customElement)("daw-pause-button")
|
|
1370
2181
|
], DawPauseButtonElement);
|
|
1371
2182
|
|
|
1372
2183
|
// src/elements/daw-stop-button.ts
|
|
1373
|
-
var
|
|
1374
|
-
var
|
|
2184
|
+
var import_lit13 = require("lit");
|
|
2185
|
+
var import_decorators12 = require("lit/decorators.js");
|
|
1375
2186
|
var DawStopButtonElement = class extends DawTransportButton {
|
|
1376
2187
|
render() {
|
|
1377
|
-
return
|
|
2188
|
+
return import_lit13.html`
|
|
1378
2189
|
<button part="button" @click=${this._onClick}>
|
|
1379
2190
|
<slot>Stop</slot>
|
|
1380
2191
|
</button>
|
|
@@ -1408,12 +2219,12 @@ var DawStopButtonElement = class extends DawTransportButton {
|
|
|
1408
2219
|
}
|
|
1409
2220
|
};
|
|
1410
2221
|
DawStopButtonElement = __decorateClass([
|
|
1411
|
-
(0,
|
|
2222
|
+
(0, import_decorators12.customElement)("daw-stop-button")
|
|
1412
2223
|
], DawStopButtonElement);
|
|
1413
2224
|
|
|
1414
2225
|
// src/elements/daw-editor.ts
|
|
1415
|
-
var
|
|
1416
|
-
var
|
|
2226
|
+
var import_lit19 = require("lit");
|
|
2227
|
+
var import_decorators16 = require("lit/decorators.js");
|
|
1417
2228
|
|
|
1418
2229
|
// src/types.ts
|
|
1419
2230
|
function isDomClip(desc) {
|
|
@@ -1421,7 +2232,7 @@ function isDomClip(desc) {
|
|
|
1421
2232
|
}
|
|
1422
2233
|
|
|
1423
2234
|
// src/elements/daw-editor.ts
|
|
1424
|
-
var
|
|
2235
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
1425
2236
|
|
|
1426
2237
|
// src/workers/peaksWorker.ts
|
|
1427
2238
|
var import_waveform_data = __toESM(require("waveform-data"));
|
|
@@ -1908,8 +2719,8 @@ var PeakPipeline = class {
|
|
|
1908
2719
|
};
|
|
1909
2720
|
|
|
1910
2721
|
// src/elements/daw-ruler.ts
|
|
1911
|
-
var
|
|
1912
|
-
var
|
|
2722
|
+
var import_lit14 = require("lit");
|
|
2723
|
+
var import_decorators13 = require("lit/decorators.js");
|
|
1913
2724
|
|
|
1914
2725
|
// src/utils/time-format.ts
|
|
1915
2726
|
function formatTime(milliseconds) {
|
|
@@ -1960,7 +2771,7 @@ function computeTemporalTicks(samplesPerPixel, sampleRate, duration, rulerHeight
|
|
|
1960
2771
|
}
|
|
1961
2772
|
|
|
1962
2773
|
// src/utils/musical-tick-cache.ts
|
|
1963
|
-
var
|
|
2774
|
+
var import_core3 = require("@waveform-playlist/core");
|
|
1964
2775
|
var cachedParams = null;
|
|
1965
2776
|
var cachedResult = null;
|
|
1966
2777
|
function meterEntriesMatch(a, b) {
|
|
@@ -1978,7 +2789,7 @@ function getCachedMusicalTicks(params) {
|
|
|
1978
2789
|
if (cachedParams && cachedResult && paramsMatch(cachedParams, params)) {
|
|
1979
2790
|
return cachedResult;
|
|
1980
2791
|
}
|
|
1981
|
-
cachedResult = (0,
|
|
2792
|
+
cachedResult = (0, import_core3.computeMusicalTicks)(params);
|
|
1982
2793
|
cachedParams = {
|
|
1983
2794
|
...params,
|
|
1984
2795
|
meterEntries: params.meterEntries.map((e) => ({ ...e }))
|
|
@@ -1988,7 +2799,7 @@ function getCachedMusicalTicks(params) {
|
|
|
1988
2799
|
|
|
1989
2800
|
// src/elements/daw-ruler.ts
|
|
1990
2801
|
var MAX_CANVAS_WIDTH3 = 1e3;
|
|
1991
|
-
var DawRulerElement = class extends
|
|
2802
|
+
var DawRulerElement = class extends import_lit14.LitElement {
|
|
1992
2803
|
constructor() {
|
|
1993
2804
|
super(...arguments);
|
|
1994
2805
|
this.samplesPerPixel = 1024;
|
|
@@ -2032,17 +2843,17 @@ var DawRulerElement = class extends import_lit11.LitElement {
|
|
|
2032
2843
|
}
|
|
2033
2844
|
render() {
|
|
2034
2845
|
const widthX = this.scaleMode === "beats" ? this.totalWidth : this._tickData?.widthX ?? 0;
|
|
2035
|
-
if (widthX <= 0) return
|
|
2846
|
+
if (widthX <= 0) return import_lit14.html``;
|
|
2036
2847
|
const totalChunks = Math.ceil(widthX / MAX_CANVAS_WIDTH3);
|
|
2037
2848
|
const indices = Array.from({ length: totalChunks }, (_, i) => i);
|
|
2038
2849
|
const dpr = typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
|
|
2039
2850
|
const beatsLabels = this.scaleMode === "beats" ? this._musicalTickData?.ticks.filter((t) => t.label) ?? [] : [];
|
|
2040
2851
|
const temporalLabels = this.scaleMode !== "beats" ? this._tickData?.labels ?? [] : [];
|
|
2041
|
-
return
|
|
2852
|
+
return import_lit14.html`
|
|
2042
2853
|
<div class="container" style="width: ${widthX}px; height: ${this.rulerHeight}px;">
|
|
2043
2854
|
${indices.map((i) => {
|
|
2044
2855
|
const width = Math.min(MAX_CANVAS_WIDTH3, widthX - i * MAX_CANVAS_WIDTH3);
|
|
2045
|
-
return
|
|
2856
|
+
return import_lit14.html`
|
|
2046
2857
|
<canvas
|
|
2047
2858
|
data-index=${i}
|
|
2048
2859
|
width=${width * dpr}
|
|
@@ -2052,13 +2863,13 @@ var DawRulerElement = class extends import_lit11.LitElement {
|
|
|
2052
2863
|
`;
|
|
2053
2864
|
})}
|
|
2054
2865
|
${this.scaleMode === "beats" ? beatsLabels.map(
|
|
2055
|
-
(t) =>
|
|
2866
|
+
(t) => import_lit14.html`<span
|
|
2056
2867
|
class="label ${t.pixel > 0 ? "centered" : ""}"
|
|
2057
2868
|
style="left: ${t.pixel > 0 ? t.pixel : t.pixel + 4}px;"
|
|
2058
2869
|
>${t.label}</span
|
|
2059
2870
|
>`
|
|
2060
2871
|
) : temporalLabels.map(
|
|
2061
|
-
({ pix, text }) =>
|
|
2872
|
+
({ pix, text }) => import_lit14.html`<span class="label" style="left: ${pix + 4}px;">${text}</span>`
|
|
2062
2873
|
)}
|
|
2063
2874
|
</div>
|
|
2064
2875
|
`;
|
|
@@ -2109,7 +2920,7 @@ var DawRulerElement = class extends import_lit11.LitElement {
|
|
|
2109
2920
|
}
|
|
2110
2921
|
}
|
|
2111
2922
|
};
|
|
2112
|
-
DawRulerElement.styles =
|
|
2923
|
+
DawRulerElement.styles = import_lit14.css`
|
|
2113
2924
|
:host {
|
|
2114
2925
|
display: block;
|
|
2115
2926
|
position: relative;
|
|
@@ -2135,40 +2946,40 @@ DawRulerElement.styles = import_lit11.css`
|
|
|
2135
2946
|
}
|
|
2136
2947
|
`;
|
|
2137
2948
|
__decorateClass([
|
|
2138
|
-
(0,
|
|
2949
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2139
2950
|
], DawRulerElement.prototype, "samplesPerPixel", 2);
|
|
2140
2951
|
__decorateClass([
|
|
2141
|
-
(0,
|
|
2952
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2142
2953
|
], DawRulerElement.prototype, "sampleRate", 2);
|
|
2143
2954
|
__decorateClass([
|
|
2144
|
-
(0,
|
|
2955
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2145
2956
|
], DawRulerElement.prototype, "duration", 2);
|
|
2146
2957
|
__decorateClass([
|
|
2147
|
-
(0,
|
|
2958
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2148
2959
|
], DawRulerElement.prototype, "rulerHeight", 2);
|
|
2149
2960
|
__decorateClass([
|
|
2150
|
-
(0,
|
|
2961
|
+
(0, import_decorators13.property)({ type: String, attribute: false })
|
|
2151
2962
|
], DawRulerElement.prototype, "scaleMode", 2);
|
|
2152
2963
|
__decorateClass([
|
|
2153
|
-
(0,
|
|
2964
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2154
2965
|
], DawRulerElement.prototype, "ticksPerPixel", 2);
|
|
2155
2966
|
__decorateClass([
|
|
2156
|
-
(0,
|
|
2967
|
+
(0, import_decorators13.property)({ attribute: false })
|
|
2157
2968
|
], DawRulerElement.prototype, "meterEntries", 2);
|
|
2158
2969
|
__decorateClass([
|
|
2159
|
-
(0,
|
|
2970
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2160
2971
|
], DawRulerElement.prototype, "ppqn", 2);
|
|
2161
2972
|
__decorateClass([
|
|
2162
|
-
(0,
|
|
2973
|
+
(0, import_decorators13.property)({ type: Number, attribute: false })
|
|
2163
2974
|
], DawRulerElement.prototype, "totalWidth", 2);
|
|
2164
2975
|
DawRulerElement = __decorateClass([
|
|
2165
|
-
(0,
|
|
2976
|
+
(0, import_decorators13.customElement)("daw-ruler")
|
|
2166
2977
|
], DawRulerElement);
|
|
2167
2978
|
|
|
2168
2979
|
// src/elements/daw-track-controls.ts
|
|
2169
|
-
var
|
|
2170
|
-
var
|
|
2171
|
-
var DawTrackControlsElement = class extends
|
|
2980
|
+
var import_lit15 = require("lit");
|
|
2981
|
+
var import_decorators14 = require("lit/decorators.js");
|
|
2982
|
+
var DawTrackControlsElement = class extends import_lit15.LitElement {
|
|
2172
2983
|
constructor() {
|
|
2173
2984
|
super(...arguments);
|
|
2174
2985
|
this.trackId = null;
|
|
@@ -2177,6 +2988,9 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2177
2988
|
this.pan = 0;
|
|
2178
2989
|
this.muted = false;
|
|
2179
2990
|
this.soloed = false;
|
|
2991
|
+
this.reorderable = false;
|
|
2992
|
+
this.trackIndex = 0;
|
|
2993
|
+
this.trackCount = 1;
|
|
2180
2994
|
this._onVolumeInput = (e) => {
|
|
2181
2995
|
const value = Number(e.target.value);
|
|
2182
2996
|
if (Number.isFinite(value)) this._dispatchControl("volume", value);
|
|
@@ -2201,6 +3015,23 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2201
3015
|
})
|
|
2202
3016
|
);
|
|
2203
3017
|
};
|
|
3018
|
+
this._onMoveUp = () => this._dispatchReorder(this.trackIndex - 1);
|
|
3019
|
+
this._onMoveDown = () => this._dispatchReorder(this.trackIndex + 1);
|
|
3020
|
+
this._onGripPointerDown = (e) => {
|
|
3021
|
+
if (!this.trackId) return;
|
|
3022
|
+
e.preventDefault();
|
|
3023
|
+
this.dispatchEvent(
|
|
3024
|
+
new CustomEvent("daw-track-reorder-grab", {
|
|
3025
|
+
bubbles: true,
|
|
3026
|
+
composed: true,
|
|
3027
|
+
detail: {
|
|
3028
|
+
trackId: this.trackId,
|
|
3029
|
+
pointerEvent: e,
|
|
3030
|
+
gripElement: e.currentTarget
|
|
3031
|
+
}
|
|
3032
|
+
})
|
|
3033
|
+
);
|
|
3034
|
+
};
|
|
2204
3035
|
}
|
|
2205
3036
|
firstUpdated() {
|
|
2206
3037
|
requestAnimationFrame(() => {
|
|
@@ -2223,12 +3054,30 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2223
3054
|
})
|
|
2224
3055
|
);
|
|
2225
3056
|
}
|
|
3057
|
+
_dispatchReorder(toIndex) {
|
|
3058
|
+
if (!this.trackId) return;
|
|
3059
|
+
this.dispatchEvent(
|
|
3060
|
+
new CustomEvent("daw-track-reorder", {
|
|
3061
|
+
bubbles: true,
|
|
3062
|
+
composed: true,
|
|
3063
|
+
detail: { trackId: this.trackId, fromIndex: this.trackIndex, toIndex }
|
|
3064
|
+
})
|
|
3065
|
+
);
|
|
3066
|
+
}
|
|
2226
3067
|
render() {
|
|
2227
3068
|
const volPercent = Math.round(this.volume * 100);
|
|
2228
3069
|
const panPercent = Math.round(Math.abs(this.pan) * 100);
|
|
2229
3070
|
const panDisplay = this.pan === 0 ? "C" : (this.pan > 0 ? "R" : "L") + panPercent;
|
|
2230
|
-
return
|
|
3071
|
+
return import_lit15.html`
|
|
2231
3072
|
<div class="header">
|
|
3073
|
+
${this.reorderable ? import_lit15.html`<button
|
|
3074
|
+
class="grip"
|
|
3075
|
+
title="Drag to reorder track"
|
|
3076
|
+
aria-label="Drag to reorder track"
|
|
3077
|
+
@pointerdown=${this._onGripPointerDown}
|
|
3078
|
+
>
|
|
3079
|
+
⠿
|
|
3080
|
+
</button>` : ""}
|
|
2232
3081
|
<span class="name" title=${this.trackName}>${this.trackName || "Untitled"}</span>
|
|
2233
3082
|
<button class="remove-btn" @click=${this._onRemoveClick} title="Remove track">
|
|
2234
3083
|
×
|
|
@@ -2245,6 +3094,24 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2245
3094
|
<button class="btn ${this.soloed ? "active" : ""}" @click=${this._onSoloClick} title="Solo">
|
|
2246
3095
|
S
|
|
2247
3096
|
</button>
|
|
3097
|
+
${this.reorderable ? import_lit15.html`<button
|
|
3098
|
+
class="btn reorder-up"
|
|
3099
|
+
title="Move track up"
|
|
3100
|
+
aria-label="Move track up"
|
|
3101
|
+
?disabled=${this.trackIndex <= 0}
|
|
3102
|
+
@click=${this._onMoveUp}
|
|
3103
|
+
>
|
|
3104
|
+
▲
|
|
3105
|
+
</button>
|
|
3106
|
+
<button
|
|
3107
|
+
class="btn reorder-down"
|
|
3108
|
+
title="Move track down"
|
|
3109
|
+
aria-label="Move track down"
|
|
3110
|
+
?disabled=${this.trackIndex >= this.trackCount - 1}
|
|
3111
|
+
@click=${this._onMoveDown}
|
|
3112
|
+
>
|
|
3113
|
+
▼
|
|
3114
|
+
</button>` : ""}
|
|
2248
3115
|
</div>
|
|
2249
3116
|
<div class="slider-row vol-row">
|
|
2250
3117
|
<span class="slider-label">
|
|
@@ -2277,7 +3144,7 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2277
3144
|
`;
|
|
2278
3145
|
}
|
|
2279
3146
|
};
|
|
2280
|
-
DawTrackControlsElement.styles =
|
|
3147
|
+
DawTrackControlsElement.styles = import_lit15.css`
|
|
2281
3148
|
:host {
|
|
2282
3149
|
display: flex;
|
|
2283
3150
|
flex-direction: column;
|
|
@@ -2321,6 +3188,20 @@ DawTrackControlsElement.styles = import_lit12.css`
|
|
|
2321
3188
|
opacity: 1;
|
|
2322
3189
|
color: #d08070;
|
|
2323
3190
|
}
|
|
3191
|
+
.grip {
|
|
3192
|
+
background: none;
|
|
3193
|
+
border: none;
|
|
3194
|
+
color: var(--daw-controls-text, #c49a6c);
|
|
3195
|
+
cursor: grab;
|
|
3196
|
+
padding: 0 2px;
|
|
3197
|
+
font-size: 12px;
|
|
3198
|
+
line-height: 1;
|
|
3199
|
+
opacity: 0.4;
|
|
3200
|
+
touch-action: none;
|
|
3201
|
+
}
|
|
3202
|
+
.grip:hover {
|
|
3203
|
+
opacity: 1;
|
|
3204
|
+
}
|
|
2324
3205
|
.buttons {
|
|
2325
3206
|
display: flex;
|
|
2326
3207
|
gap: 3px;
|
|
@@ -2350,6 +3231,10 @@ DawTrackControlsElement.styles = import_lit12.css`
|
|
|
2350
3231
|
border-color: rgba(208, 128, 112, 0.5);
|
|
2351
3232
|
color: #d08070;
|
|
2352
3233
|
}
|
|
3234
|
+
.btn:disabled {
|
|
3235
|
+
opacity: 0.3;
|
|
3236
|
+
cursor: default;
|
|
3237
|
+
}
|
|
2353
3238
|
.slider-row {
|
|
2354
3239
|
display: flex;
|
|
2355
3240
|
align-items: center;
|
|
@@ -2429,33 +3314,42 @@ DawTrackControlsElement.styles = import_lit12.css`
|
|
|
2429
3314
|
}
|
|
2430
3315
|
`;
|
|
2431
3316
|
__decorateClass([
|
|
2432
|
-
(0,
|
|
3317
|
+
(0, import_decorators14.property)({ attribute: false })
|
|
2433
3318
|
], DawTrackControlsElement.prototype, "trackId", 2);
|
|
2434
3319
|
__decorateClass([
|
|
2435
|
-
(0,
|
|
3320
|
+
(0, import_decorators14.property)({ attribute: false })
|
|
2436
3321
|
], DawTrackControlsElement.prototype, "trackName", 2);
|
|
2437
3322
|
__decorateClass([
|
|
2438
|
-
(0,
|
|
3323
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
2439
3324
|
], DawTrackControlsElement.prototype, "volume", 2);
|
|
2440
3325
|
__decorateClass([
|
|
2441
|
-
(0,
|
|
3326
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
2442
3327
|
], DawTrackControlsElement.prototype, "pan", 2);
|
|
2443
3328
|
__decorateClass([
|
|
2444
|
-
(0,
|
|
3329
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
2445
3330
|
], DawTrackControlsElement.prototype, "muted", 2);
|
|
2446
3331
|
__decorateClass([
|
|
2447
|
-
(0,
|
|
3332
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
2448
3333
|
], DawTrackControlsElement.prototype, "soloed", 2);
|
|
3334
|
+
__decorateClass([
|
|
3335
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
3336
|
+
], DawTrackControlsElement.prototype, "reorderable", 2);
|
|
3337
|
+
__decorateClass([
|
|
3338
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
3339
|
+
], DawTrackControlsElement.prototype, "trackIndex", 2);
|
|
3340
|
+
__decorateClass([
|
|
3341
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
3342
|
+
], DawTrackControlsElement.prototype, "trackCount", 2);
|
|
2449
3343
|
DawTrackControlsElement = __decorateClass([
|
|
2450
|
-
(0,
|
|
3344
|
+
(0, import_decorators14.customElement)("daw-track-controls")
|
|
2451
3345
|
], DawTrackControlsElement);
|
|
2452
3346
|
|
|
2453
3347
|
// src/elements/daw-grid.ts
|
|
2454
|
-
var
|
|
2455
|
-
var
|
|
2456
|
-
var
|
|
3348
|
+
var import_lit16 = require("lit");
|
|
3349
|
+
var import_decorators15 = require("lit/decorators.js");
|
|
3350
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
2457
3351
|
var MAX_CANVAS_WIDTH4 = 1e3;
|
|
2458
|
-
var DawGridElement = class extends
|
|
3352
|
+
var DawGridElement = class extends import_lit16.LitElement {
|
|
2459
3353
|
constructor() {
|
|
2460
3354
|
super(...arguments);
|
|
2461
3355
|
this.ticksPerPixel = 24;
|
|
@@ -2483,7 +3377,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2483
3377
|
}
|
|
2484
3378
|
}
|
|
2485
3379
|
render() {
|
|
2486
|
-
if (!this._tickData) return
|
|
3380
|
+
if (!this._tickData) return import_lit16.html``;
|
|
2487
3381
|
const totalWidth = this.length;
|
|
2488
3382
|
const dpr = typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
|
|
2489
3383
|
const indices = getVisibleChunkIndices(
|
|
@@ -2492,11 +3386,11 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2492
3386
|
this.visibleStart,
|
|
2493
3387
|
this.visibleEnd
|
|
2494
3388
|
);
|
|
2495
|
-
return
|
|
3389
|
+
return import_lit16.html`
|
|
2496
3390
|
<div class="container" style="width: ${totalWidth}px; height: ${this.height}px;">
|
|
2497
3391
|
${indices.map((i) => {
|
|
2498
3392
|
const width = Math.min(MAX_CANVAS_WIDTH4, totalWidth - i * MAX_CANVAS_WIDTH4);
|
|
2499
|
-
return
|
|
3393
|
+
return import_lit16.html`
|
|
2500
3394
|
<canvas
|
|
2501
3395
|
data-index=${i}
|
|
2502
3396
|
width=${width * dpr}
|
|
@@ -2530,7 +3424,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2530
3424
|
ctx.resetTransform();
|
|
2531
3425
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2532
3426
|
ctx.scale(dpr, dpr);
|
|
2533
|
-
if (pixelsPerQuarterNote * 4 >=
|
|
3427
|
+
if (pixelsPerQuarterNote * 4 >= import_core4.MIN_PIXELS_PER_UNIT) {
|
|
2534
3428
|
ctx.fillStyle = barHighlight;
|
|
2535
3429
|
const majorTicks = ticks.filter((t) => t.type === "major");
|
|
2536
3430
|
for (let i = 0; i < majorTicks.length; i++) {
|
|
@@ -2557,7 +3451,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2557
3451
|
}
|
|
2558
3452
|
}
|
|
2559
3453
|
};
|
|
2560
|
-
DawGridElement.styles =
|
|
3454
|
+
DawGridElement.styles = import_lit16.css`
|
|
2561
3455
|
:host {
|
|
2562
3456
|
display: block;
|
|
2563
3457
|
position: absolute;
|
|
@@ -2575,33 +3469,33 @@ DawGridElement.styles = import_lit13.css`
|
|
|
2575
3469
|
}
|
|
2576
3470
|
`;
|
|
2577
3471
|
__decorateClass([
|
|
2578
|
-
(0,
|
|
3472
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2579
3473
|
], DawGridElement.prototype, "ticksPerPixel", 2);
|
|
2580
3474
|
__decorateClass([
|
|
2581
|
-
(0,
|
|
3475
|
+
(0, import_decorators15.property)({ attribute: false })
|
|
2582
3476
|
], DawGridElement.prototype, "meterEntries", 2);
|
|
2583
3477
|
__decorateClass([
|
|
2584
|
-
(0,
|
|
3478
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2585
3479
|
], DawGridElement.prototype, "ppqn", 2);
|
|
2586
3480
|
__decorateClass([
|
|
2587
|
-
(0,
|
|
3481
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2588
3482
|
], DawGridElement.prototype, "visibleStart", 2);
|
|
2589
3483
|
__decorateClass([
|
|
2590
|
-
(0,
|
|
3484
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2591
3485
|
], DawGridElement.prototype, "visibleEnd", 2);
|
|
2592
3486
|
__decorateClass([
|
|
2593
|
-
(0,
|
|
3487
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2594
3488
|
], DawGridElement.prototype, "length", 2);
|
|
2595
3489
|
__decorateClass([
|
|
2596
|
-
(0,
|
|
3490
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2597
3491
|
], DawGridElement.prototype, "height", 2);
|
|
2598
3492
|
DawGridElement = __decorateClass([
|
|
2599
|
-
(0,
|
|
3493
|
+
(0, import_decorators15.customElement)("daw-grid")
|
|
2600
3494
|
], DawGridElement);
|
|
2601
3495
|
|
|
2602
3496
|
// src/styles/theme.ts
|
|
2603
|
-
var
|
|
2604
|
-
var hostStyles =
|
|
3497
|
+
var import_lit17 = require("lit");
|
|
3498
|
+
var hostStyles = import_lit17.css`
|
|
2605
3499
|
:host {
|
|
2606
3500
|
--daw-wave-color: #c49a6c;
|
|
2607
3501
|
--daw-progress-color: #63c75f;
|
|
@@ -2617,7 +3511,7 @@ var hostStyles = import_lit14.css`
|
|
|
2617
3511
|
--daw-clip-header-text: #e0d4c8;
|
|
2618
3512
|
}
|
|
2619
3513
|
`;
|
|
2620
|
-
var clipStyles =
|
|
3514
|
+
var clipStyles = import_lit17.css`
|
|
2621
3515
|
.clip-container {
|
|
2622
3516
|
position: absolute;
|
|
2623
3517
|
overflow: hidden;
|
|
@@ -2857,7 +3751,7 @@ var AudioResumeController = class {
|
|
|
2857
3751
|
};
|
|
2858
3752
|
|
|
2859
3753
|
// src/controllers/recording-controller.ts
|
|
2860
|
-
var
|
|
3754
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
2861
3755
|
var RecordingController = class {
|
|
2862
3756
|
constructor(host) {
|
|
2863
3757
|
this._sessions = /* @__PURE__ */ new Map();
|
|
@@ -2951,7 +3845,7 @@ var RecordingController = class {
|
|
|
2951
3845
|
}
|
|
2952
3846
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
2953
3847
|
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
2954
|
-
const latencySamples = (0,
|
|
3848
|
+
const latencySamples = (0, import_core5.resolveRecordingOffsetSamples)({
|
|
2955
3849
|
overrideSeconds: options.latencyOffset,
|
|
2956
3850
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
2957
3851
|
lookAhead: 0,
|
|
@@ -3125,8 +4019,8 @@ var RecordingController = class {
|
|
|
3125
4019
|
return;
|
|
3126
4020
|
}
|
|
3127
4021
|
const stopCtx = this._host.audioContext;
|
|
3128
|
-
const channelData = session.chunks.map((chunkArr) => (0,
|
|
3129
|
-
const audioBuffer = (0,
|
|
4022
|
+
const channelData = session.chunks.map((chunkArr) => (0, import_core5.concatenateAudioData)(chunkArr));
|
|
4023
|
+
const audioBuffer = (0, import_core5.createAudioBuffer)(
|
|
3130
4024
|
stopCtx,
|
|
3131
4025
|
channelData,
|
|
3132
4026
|
session.captureSampleRate,
|
|
@@ -3220,7 +4114,7 @@ var RecordingController = class {
|
|
|
3220
4114
|
for (let ch = 0; ch < session.channelCount; ch++) {
|
|
3221
4115
|
if (!channels[ch]) continue;
|
|
3222
4116
|
const oldPeakCount = Math.floor(session.peaks[ch].length / 2);
|
|
3223
|
-
session.peaks[ch] = (0,
|
|
4117
|
+
session.peaks[ch] = (0, import_core5.appendPeaks)(
|
|
3224
4118
|
session.peaks[ch],
|
|
3225
4119
|
channels[ch],
|
|
3226
4120
|
// Render-space scale — in beats mode this differs from
|
|
@@ -3331,9 +4225,191 @@ var RecordingController = class {
|
|
|
3331
4225
|
}
|
|
3332
4226
|
};
|
|
3333
4227
|
|
|
4228
|
+
// src/controllers/annotation-controller.ts
|
|
4229
|
+
var import_lit18 = require("lit");
|
|
4230
|
+
var ANNOTATION_LANE_HEIGHT = 32;
|
|
4231
|
+
var AnnotationController = class {
|
|
4232
|
+
constructor(host) {
|
|
4233
|
+
this._tracks = [];
|
|
4234
|
+
this._removalObserver = null;
|
|
4235
|
+
/** Playback-following highlight per track, separate from each track's
|
|
4236
|
+
* `activeAnnotationId` (selection) so playback never disturbs selection.
|
|
4237
|
+
* Driven by daw-timeupdate, cleared on daw-stop, retained on pause.
|
|
4238
|
+
* Replaced immutably (a fresh Map) on every change. */
|
|
4239
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4240
|
+
this._onDataChange = () => {
|
|
4241
|
+
this.deriveSecondsCaches();
|
|
4242
|
+
this._host.requestUpdate();
|
|
4243
|
+
};
|
|
4244
|
+
/**
|
|
4245
|
+
* Update only on annotation-boundary crossings, not per animation frame.
|
|
4246
|
+
*/
|
|
4247
|
+
this._onTimeUpdate = (e) => {
|
|
4248
|
+
const time = e.detail.time;
|
|
4249
|
+
let changed = false;
|
|
4250
|
+
const next = new Map(this._playingIds);
|
|
4251
|
+
for (const track of this._tracks) {
|
|
4252
|
+
const playingId = computePlayingAnnotationId(track.annotations, time);
|
|
4253
|
+
if (playingId !== (this._playingIds.get(track) ?? null)) {
|
|
4254
|
+
next.set(track, playingId);
|
|
4255
|
+
changed = true;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
if (!changed) return;
|
|
4259
|
+
this._playingIds = next;
|
|
4260
|
+
this._host.requestUpdate();
|
|
4261
|
+
};
|
|
4262
|
+
this._onStop = () => {
|
|
4263
|
+
if (this._playingIds.size === 0) return;
|
|
4264
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4265
|
+
this._host.requestUpdate();
|
|
4266
|
+
};
|
|
4267
|
+
this._host = host;
|
|
4268
|
+
host.addController(this);
|
|
4269
|
+
}
|
|
4270
|
+
get tracks() {
|
|
4271
|
+
return this._tracks;
|
|
4272
|
+
}
|
|
4273
|
+
/** Current playback-following highlight id for a track, or `null` when the
|
|
4274
|
+
* playhead isn't inside any of the track's annotations. */
|
|
4275
|
+
getPlayingAnnotationId(track) {
|
|
4276
|
+
return this._playingIds.get(track) ?? null;
|
|
4277
|
+
}
|
|
4278
|
+
get totalLaneHeight() {
|
|
4279
|
+
return this._tracks.length * ANNOTATION_LANE_HEIGHT;
|
|
4280
|
+
}
|
|
4281
|
+
/** Max annotation end (seconds) across registered tracks — 0 when none.
|
|
4282
|
+
* Lets the editor extend the timeline so annotations past the audio stay
|
|
4283
|
+
* reachable/scrollable. */
|
|
4284
|
+
get maxAnnotationEndSeconds() {
|
|
4285
|
+
return this._tracks.reduce(
|
|
4286
|
+
(max, track) => track.annotations.reduce((m, a) => Math.max(m, a.end), max),
|
|
4287
|
+
0
|
|
4288
|
+
);
|
|
4289
|
+
}
|
|
4290
|
+
hostConnected() {
|
|
4291
|
+
this._host.addEventListener("daw-annotation-update", this._onDataChange);
|
|
4292
|
+
this._host.addEventListener("daw-annotation-select", this._onDataChange);
|
|
4293
|
+
this._host.addEventListener("daw-annotation-connected", this._onDataChange);
|
|
4294
|
+
this._host.addEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
4295
|
+
this._host.addEventListener("daw-stop", this._onStop);
|
|
4296
|
+
this._removalObserver = new MutationObserver((mutations) => {
|
|
4297
|
+
let changed = false;
|
|
4298
|
+
for (const m of mutations) {
|
|
4299
|
+
for (const node of Array.from(m.removedNodes)) {
|
|
4300
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
4301
|
+
if (node.tagName === "DAW-ANNOTATION-TRACK") {
|
|
4302
|
+
this._tracks = this._tracks.filter((t) => t !== node);
|
|
4303
|
+
changed = true;
|
|
4304
|
+
} else if (node.tagName === "DAW-ANNOTATION") {
|
|
4305
|
+
changed = true;
|
|
4306
|
+
}
|
|
4307
|
+
const nestedTracks = node.querySelectorAll?.("daw-annotation-track");
|
|
4308
|
+
if (nestedTracks) {
|
|
4309
|
+
for (const nested of nestedTracks) {
|
|
4310
|
+
this._tracks = this._tracks.filter((t) => t !== nested);
|
|
4311
|
+
changed = true;
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
const nestedAnnotations = node.querySelectorAll?.("daw-annotation");
|
|
4315
|
+
if (nestedAnnotations && nestedAnnotations.length > 0) {
|
|
4316
|
+
changed = true;
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
if (changed) this._host.requestUpdate();
|
|
4321
|
+
});
|
|
4322
|
+
this._removalObserver.observe(this._host, { childList: true, subtree: true });
|
|
4323
|
+
}
|
|
4324
|
+
hostDisconnected() {
|
|
4325
|
+
this._host.removeEventListener("daw-annotation-update", this._onDataChange);
|
|
4326
|
+
this._host.removeEventListener("daw-annotation-select", this._onDataChange);
|
|
4327
|
+
this._host.removeEventListener("daw-annotation-connected", this._onDataChange);
|
|
4328
|
+
this._host.removeEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
4329
|
+
this._host.removeEventListener("daw-stop", this._onStop);
|
|
4330
|
+
this._removalObserver?.disconnect();
|
|
4331
|
+
this._removalObserver = null;
|
|
4332
|
+
this._tracks = [];
|
|
4333
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4334
|
+
}
|
|
4335
|
+
handleTrackConnected(el) {
|
|
4336
|
+
if (this._tracks.includes(el)) return;
|
|
4337
|
+
this._tracks = [...this._tracks, el];
|
|
4338
|
+
this._host.requestUpdate();
|
|
4339
|
+
this.deriveSecondsCaches();
|
|
4340
|
+
}
|
|
4341
|
+
/**
|
|
4342
|
+
* Keep the seconds attributes (derived cache) of tick-based annotations in
|
|
4343
|
+
* sync with the host's tempo. Write-only-on-change: a write fires
|
|
4344
|
+
* daw-annotation-update → _onDataChange → this sweep again → values equal →
|
|
4345
|
+
* no write → the loop settles (idempotent).
|
|
4346
|
+
*/
|
|
4347
|
+
deriveSecondsCaches() {
|
|
4348
|
+
for (const track of this._tracks) {
|
|
4349
|
+
for (const el of track.annotationElements) {
|
|
4350
|
+
if (!el.isTickBased) continue;
|
|
4351
|
+
const startSeconds = this._host._ticksToSeconds(el.startTick);
|
|
4352
|
+
const endSeconds = this._host._ticksToSeconds(el.endTick);
|
|
4353
|
+
if (el.start !== startSeconds) el.start = startSeconds;
|
|
4354
|
+
if (el.end !== endSeconds) el.end = endSeconds;
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
/** Pixel geometry for one annotation box. Tick-based annotations in beats
|
|
4359
|
+
* mode use CLIP-IDENTICAL tick math (round(tick / ticksPerPixel)) so they
|
|
4360
|
+
* align pixel-exactly with <daw-grid>; everything else uses the floor-based
|
|
4361
|
+
* seconds math (temporal mode reads the always-fresh seconds cache). */
|
|
4362
|
+
boxGeometry(a, spp, sampleRate, ticksPerPixel = null) {
|
|
4363
|
+
if (ticksPerPixel !== null && ticksPerPixel > 0 && a.startTick !== void 0 && a.endTick !== void 0) {
|
|
4364
|
+
const left2 = Math.round(a.startTick / ticksPerPixel);
|
|
4365
|
+
const width2 = Math.round(a.endTick / ticksPerPixel) - left2;
|
|
4366
|
+
return { left: left2, width: width2 };
|
|
4367
|
+
}
|
|
4368
|
+
const left = Math.floor(a.start * sampleRate / spp);
|
|
4369
|
+
const width = Math.floor(a.end * sampleRate / spp) - left;
|
|
4370
|
+
return { left, width };
|
|
4371
|
+
}
|
|
4372
|
+
/**
|
|
4373
|
+
* Lane templates for the editor's .timeline. onPointerDown is supplied by
|
|
4374
|
+
* the editor and dispatches into the drag interaction (Task 9).
|
|
4375
|
+
*/
|
|
4376
|
+
renderLanes(spp, sampleRate, onPointerDown = () => {
|
|
4377
|
+
}, ticksPerPixel = null) {
|
|
4378
|
+
return this._tracks.map((track) => {
|
|
4379
|
+
const activeId = track.activeAnnotationId;
|
|
4380
|
+
const playingId = this._playingIds.get(track) ?? null;
|
|
4381
|
+
const elements = track.annotationElements;
|
|
4382
|
+
return import_lit18.html`
|
|
4383
|
+
<div
|
|
4384
|
+
class="annotation-lane"
|
|
4385
|
+
style="height: ${ANNOTATION_LANE_HEIGHT}px;"
|
|
4386
|
+
@pointerdown=${(e) => onPointerDown(e, track)}
|
|
4387
|
+
>
|
|
4388
|
+
${elements.map((el, i) => {
|
|
4389
|
+
const a = el.toAnnotationData();
|
|
4390
|
+
const geo = this.boxGeometry(a, spp, sampleRate, ticksPerPixel);
|
|
4391
|
+
const label = track.boxLabel === "none" ? "" : track.boxLabel === "id" ? el.id || String(i + 1) : a.lines.join(" ");
|
|
4392
|
+
return import_lit18.html`
|
|
4393
|
+
<div
|
|
4394
|
+
class="annotation-box ${a.id === activeId ? "active" : ""} ${a.id === playingId ? "playing" : ""}"
|
|
4395
|
+
data-annotation-id=${a.id}
|
|
4396
|
+
style="left: ${geo.left}px; width: ${geo.width}px;"
|
|
4397
|
+
>
|
|
4398
|
+
${track.editable ? import_lit18.html`<div class="annotation-boundary" data-edge="start"></div>` : ""}
|
|
4399
|
+
<span class="annotation-box-text">${label}</span>
|
|
4400
|
+
${track.editable ? import_lit18.html`<div class="annotation-boundary" data-edge="end"></div>` : ""}
|
|
4401
|
+
</div>
|
|
4402
|
+
`;
|
|
4403
|
+
})}
|
|
4404
|
+
</div>
|
|
4405
|
+
`;
|
|
4406
|
+
});
|
|
4407
|
+
}
|
|
4408
|
+
};
|
|
4409
|
+
|
|
3334
4410
|
// src/controllers/spectrogram-controller.ts
|
|
3335
4411
|
var import_spectrogram = require("@dawcore/spectrogram");
|
|
3336
|
-
var
|
|
4412
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
3337
4413
|
var SpectrogramController = class {
|
|
3338
4414
|
constructor(host, workerFactory) {
|
|
3339
4415
|
this.orchestrator = null;
|
|
@@ -3386,8 +4462,8 @@ var SpectrogramController = class {
|
|
|
3386
4462
|
unregisterCanvas(canvasId) {
|
|
3387
4463
|
this.orchestrator?.unregisterCanvas(canvasId);
|
|
3388
4464
|
}
|
|
3389
|
-
setViewport(
|
|
3390
|
-
this.orchestrator?.setViewport(
|
|
4465
|
+
setViewport(state9) {
|
|
4466
|
+
this.orchestrator?.setViewport(state9);
|
|
3391
4467
|
}
|
|
3392
4468
|
dispose() {
|
|
3393
4469
|
if (this.orchestrator) {
|
|
@@ -3442,18 +4518,18 @@ var SpectrogramController = class {
|
|
|
3442
4518
|
track = c;
|
|
3443
4519
|
break;
|
|
3444
4520
|
}
|
|
3445
|
-
return { ...
|
|
4521
|
+
return { ...import_core6.SPECTROGRAM_DEFAULTS, ...this.editorConfig ?? {}, ...track ?? {} };
|
|
3446
4522
|
}
|
|
3447
4523
|
mergedColorMap() {
|
|
3448
4524
|
for (const c of this.trackColorMaps.values()) {
|
|
3449
|
-
return c ??
|
|
4525
|
+
return c ?? import_core6.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
3450
4526
|
}
|
|
3451
|
-
return this.editorColorMap ??
|
|
4527
|
+
return this.editorColorMap ?? import_core6.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
3452
4528
|
}
|
|
3453
4529
|
};
|
|
3454
4530
|
|
|
3455
4531
|
// src/interactions/pointer-handler.ts
|
|
3456
|
-
var
|
|
4532
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
3457
4533
|
|
|
3458
4534
|
// src/interactions/constants.ts
|
|
3459
4535
|
var DRAG_THRESHOLD = 3;
|
|
@@ -3610,10 +4686,10 @@ var PointerHandler = class {
|
|
|
3610
4686
|
const h = this._host;
|
|
3611
4687
|
if (h.scaleMode === "beats") {
|
|
3612
4688
|
let tick = px * h.ticksPerPixel;
|
|
3613
|
-
tick = (0,
|
|
4689
|
+
tick = (0, import_core7.snapTickToGrid)(tick, h.snapTo, h._meterEntries, h.ppqn);
|
|
3614
4690
|
return h._ticksToSeconds(tick);
|
|
3615
4691
|
}
|
|
3616
|
-
return (0,
|
|
4692
|
+
return (0, import_core7.pixelsToSeconds)(px, h.samplesPerPixel, h.effectiveSampleRate);
|
|
3617
4693
|
}
|
|
3618
4694
|
_timeToPx(time) {
|
|
3619
4695
|
const h = this._host;
|
|
@@ -3732,7 +4808,7 @@ var PointerHandler = class {
|
|
|
3732
4808
|
};
|
|
3733
4809
|
|
|
3734
4810
|
// src/interactions/clip-pointer-handler.ts
|
|
3735
|
-
var
|
|
4811
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
3736
4812
|
var ClipPointerHandler = class {
|
|
3737
4813
|
constructor(host) {
|
|
3738
4814
|
this._mode = null;
|
|
@@ -3766,7 +4842,7 @@ var ClipPointerHandler = class {
|
|
|
3766
4842
|
const anchorTick = h._secondsToTicks(anchorSeconds);
|
|
3767
4843
|
const deltaTicks = totalDeltaPx * h.ticksPerPixel;
|
|
3768
4844
|
const targetTick = anchorTick + deltaTicks;
|
|
3769
|
-
const snappedTick = h.snapTo !== "off" ? (0,
|
|
4845
|
+
const snappedTick = h.snapTo !== "off" ? (0, import_core8.snapTickToGrid)(targetTick, h.snapTo, h._meterEntries, h.ppqn) : targetTick;
|
|
3770
4846
|
const snappedSeconds = h._ticksToSeconds(snappedTick);
|
|
3771
4847
|
const snappedSample = Math.round(snappedSeconds * h.effectiveSampleRate);
|
|
3772
4848
|
return snappedSample - anchorSample;
|
|
@@ -4027,26 +5103,338 @@ var ClipPointerHandler = class {
|
|
|
4027
5103
|
for (const wf of waveforms) {
|
|
4028
5104
|
wf.style.left = "0px";
|
|
4029
5105
|
}
|
|
4030
|
-
this._updateWaveformPeaks(this._originalOffsetSamples, this._originalDurationSamples);
|
|
5106
|
+
this._updateWaveformPeaks(this._originalOffsetSamples, this._originalDurationSamples);
|
|
5107
|
+
}
|
|
5108
|
+
}
|
|
5109
|
+
_reset() {
|
|
5110
|
+
if (this._boundaryEl) {
|
|
5111
|
+
this._boundaryEl.classList.remove("dragging");
|
|
5112
|
+
this._boundaryEl = null;
|
|
5113
|
+
}
|
|
5114
|
+
this._mode = null;
|
|
5115
|
+
this._clipId = "";
|
|
5116
|
+
this._trackId = "";
|
|
5117
|
+
this._startPx = 0;
|
|
5118
|
+
this._isDragging = false;
|
|
5119
|
+
this._cumulativeDeltaSamples = 0;
|
|
5120
|
+
this._clipContainer = null;
|
|
5121
|
+
this._originalLeft = 0;
|
|
5122
|
+
this._originalWidth = 0;
|
|
5123
|
+
this._originalOffsetSamples = 0;
|
|
5124
|
+
this._originalDurationSamples = 0;
|
|
5125
|
+
this._originalStartSample = 0;
|
|
5126
|
+
}
|
|
5127
|
+
};
|
|
5128
|
+
|
|
5129
|
+
// src/interactions/annotation-drag.ts
|
|
5130
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
5131
|
+
var import_core10 = require("@waveform-playlist/core");
|
|
5132
|
+
var AnnotationDragHandler = class {
|
|
5133
|
+
constructor(host) {
|
|
5134
|
+
this._drag = null;
|
|
5135
|
+
this.onPointerDown = (e, track) => {
|
|
5136
|
+
const target = e.target;
|
|
5137
|
+
const boundary = target.closest(".annotation-boundary");
|
|
5138
|
+
const box = target.closest(".annotation-box");
|
|
5139
|
+
if (!box) return;
|
|
5140
|
+
const annotationId = box.getAttribute("data-annotation-id") ?? "";
|
|
5141
|
+
const isBoundary = boundary !== null && track.editable;
|
|
5142
|
+
if (boundary !== null && !track.editable) {
|
|
5143
|
+
return;
|
|
5144
|
+
}
|
|
5145
|
+
e.stopPropagation();
|
|
5146
|
+
e.preventDefault();
|
|
5147
|
+
const elements = track.annotationElements;
|
|
5148
|
+
const el = elements.find((x) => x.annotationId === annotationId);
|
|
5149
|
+
if (!el) return;
|
|
5150
|
+
const mode = el.isTickBased ? "ticks" : "seconds";
|
|
5151
|
+
const snapshot = mode === "ticks" ? elements.map((x) => tickSpaceData(x, this._host)) : track.annotations;
|
|
5152
|
+
const index = snapshot.findIndex((a) => a.id === annotationId);
|
|
5153
|
+
if (index === -1) return;
|
|
5154
|
+
const edge = isBoundary ? boundary.getAttribute("data-edge") : null;
|
|
5155
|
+
const captureEl = isBoundary ? boundary : box;
|
|
5156
|
+
this._drag = {
|
|
5157
|
+
track,
|
|
5158
|
+
captureEl,
|
|
5159
|
+
pointerId: e.pointerId,
|
|
5160
|
+
startClientX: e.clientX,
|
|
5161
|
+
moved: false,
|
|
5162
|
+
edge,
|
|
5163
|
+
annotationId,
|
|
5164
|
+
mode,
|
|
5165
|
+
snapshot,
|
|
5166
|
+
// edgeTime holds ticks in 'ticks' mode, seconds in 'seconds' mode.
|
|
5167
|
+
edgeTime: edge === "start" ? snapshot[index].start : snapshot[index].end
|
|
5168
|
+
};
|
|
5169
|
+
try {
|
|
5170
|
+
captureEl.setPointerCapture(e.pointerId);
|
|
5171
|
+
} catch {
|
|
5172
|
+
}
|
|
5173
|
+
captureEl.addEventListener("pointermove", this._onPointerMove);
|
|
5174
|
+
captureEl.addEventListener("pointerup", this._onPointerUp);
|
|
5175
|
+
captureEl.addEventListener("pointercancel", this._onPointerCancel);
|
|
5176
|
+
};
|
|
5177
|
+
/** Non-private (underscore convention) so tests can drive moves directly. */
|
|
5178
|
+
this._onPointerMove = (e) => {
|
|
5179
|
+
const drag = this._drag;
|
|
5180
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5181
|
+
const deltaPx = e.clientX - drag.startClientX;
|
|
5182
|
+
if (Math.abs(deltaPx) >= DRAG_THRESHOLD) drag.moved = true;
|
|
5183
|
+
if (drag.edge === null || !drag.moved) return;
|
|
5184
|
+
const elements = drag.track.annotationElements;
|
|
5185
|
+
const index = drag.snapshot.findIndex((a) => a.id === drag.annotationId);
|
|
5186
|
+
if (index === -1) return;
|
|
5187
|
+
if (drag.mode === "ticks") {
|
|
5188
|
+
const deltaTicks = this._host.scaleMode === "beats" ? deltaPx * this._host.ticksPerPixel : this._host._secondsToTicks(
|
|
5189
|
+
this._host._ticksToSeconds(drag.edgeTime) + deltaPx * this._host._renderSpp / this._host.effectiveSampleRate
|
|
5190
|
+
) - drag.edgeTime;
|
|
5191
|
+
let newTick = drag.edgeTime + deltaTicks;
|
|
5192
|
+
if (this._host.scaleMode === "beats" && this._host.snapTo !== "off") {
|
|
5193
|
+
newTick = (0, import_core9.snapTickToGrid)(
|
|
5194
|
+
newTick,
|
|
5195
|
+
this._host.snapTo,
|
|
5196
|
+
this._host._meterEntries,
|
|
5197
|
+
this._host.ppqn
|
|
5198
|
+
);
|
|
5199
|
+
}
|
|
5200
|
+
const clamp = this._host._annotationClampDuration;
|
|
5201
|
+
const updated2 = (0, import_core9.updateAnnotationBoundaries)(
|
|
5202
|
+
{
|
|
5203
|
+
annotationIndex: index,
|
|
5204
|
+
newTime: newTick,
|
|
5205
|
+
isDraggingStart: drag.edge === "start",
|
|
5206
|
+
annotations: drag.snapshot,
|
|
5207
|
+
duration: clamp === Infinity ? Infinity : this._host._secondsToTicks(clamp),
|
|
5208
|
+
linkEndpoints: drag.track.linkEndpoints
|
|
5209
|
+
},
|
|
5210
|
+
{
|
|
5211
|
+
linkThreshold: import_core10.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
5212
|
+
minDuration: (0, import_core10.annotationMinDurationTicks)(this._host.ppqn)
|
|
5213
|
+
}
|
|
5214
|
+
);
|
|
5215
|
+
applyTickBoundaryResults(elements, updated2, (t) => this._host._ticksToSeconds(t));
|
|
5216
|
+
return;
|
|
5217
|
+
}
|
|
5218
|
+
const deltaSeconds = deltaPx * this._host._renderSpp / this._host.effectiveSampleRate;
|
|
5219
|
+
const updated = (0, import_core9.updateAnnotationBoundaries)({
|
|
5220
|
+
annotationIndex: index,
|
|
5221
|
+
newTime: drag.edgeTime + deltaSeconds,
|
|
5222
|
+
isDraggingStart: drag.edge === "start",
|
|
5223
|
+
annotations: drag.snapshot,
|
|
5224
|
+
duration: this._host._annotationClampDuration,
|
|
5225
|
+
linkEndpoints: drag.track.linkEndpoints
|
|
5226
|
+
});
|
|
5227
|
+
applyBoundaryResults(elements, updated);
|
|
5228
|
+
};
|
|
5229
|
+
this._onPointerUp = (e) => {
|
|
5230
|
+
const drag = this._drag;
|
|
5231
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5232
|
+
if (!drag.moved && drag.edge === null) {
|
|
5233
|
+
const data = drag.track.annotations.find((a) => a.id === drag.annotationId);
|
|
5234
|
+
if (data) {
|
|
5235
|
+
drag.track.activeAnnotationId = drag.annotationId;
|
|
5236
|
+
this._host.seekTo(data.start);
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
this._teardown();
|
|
5240
|
+
};
|
|
5241
|
+
this._onPointerCancel = (e) => {
|
|
5242
|
+
const drag = this._drag;
|
|
5243
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5244
|
+
const elements = drag.track.annotationElements;
|
|
5245
|
+
if (drag.mode === "ticks") {
|
|
5246
|
+
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5247
|
+
} else {
|
|
5248
|
+
applyBoundaryResults(elements, drag.snapshot);
|
|
5249
|
+
}
|
|
5250
|
+
this._teardown();
|
|
5251
|
+
};
|
|
5252
|
+
this._host = host;
|
|
5253
|
+
}
|
|
5254
|
+
_teardown() {
|
|
5255
|
+
const drag = this._drag;
|
|
5256
|
+
if (!drag) return;
|
|
5257
|
+
try {
|
|
5258
|
+
drag.captureEl.releasePointerCapture(drag.pointerId);
|
|
5259
|
+
} catch {
|
|
4031
5260
|
}
|
|
5261
|
+
drag.captureEl.removeEventListener("pointermove", this._onPointerMove);
|
|
5262
|
+
drag.captureEl.removeEventListener("pointerup", this._onPointerUp);
|
|
5263
|
+
drag.captureEl.removeEventListener("pointercancel", this._onPointerCancel);
|
|
5264
|
+
this._drag = null;
|
|
4032
5265
|
}
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
5266
|
+
};
|
|
5267
|
+
|
|
5268
|
+
// src/interactions/track-reorder-handler.ts
|
|
5269
|
+
var TrackReorderHandler = class _TrackReorderHandler {
|
|
5270
|
+
constructor(host) {
|
|
5271
|
+
this._trackId = null;
|
|
5272
|
+
this._pointerId = -1;
|
|
5273
|
+
this._startY = 0;
|
|
5274
|
+
this._rows = [];
|
|
5275
|
+
this._lanes = [];
|
|
5276
|
+
// aligned with _rows indices; null = lane not found
|
|
5277
|
+
this._fromIndex = 0;
|
|
5278
|
+
this._targetIndex = 0;
|
|
5279
|
+
this._gripEl = null;
|
|
5280
|
+
this.onGrab = (trackId, e, gripEl) => {
|
|
5281
|
+
if (this._trackId !== null) return;
|
|
5282
|
+
const column = this._host.shadowRoot?.querySelector(".controls-column");
|
|
5283
|
+
if (!column) return;
|
|
5284
|
+
const rows = [...column.querySelectorAll("daw-track-controls")];
|
|
5285
|
+
this._rows = rows.map((el) => {
|
|
5286
|
+
const rect = el.getBoundingClientRect();
|
|
5287
|
+
return {
|
|
5288
|
+
el,
|
|
5289
|
+
top: rect.top,
|
|
5290
|
+
height: rect.height,
|
|
5291
|
+
trackId: el.trackId ?? ""
|
|
5292
|
+
};
|
|
5293
|
+
});
|
|
5294
|
+
this._fromIndex = this._rows.findIndex((r) => r.trackId === trackId);
|
|
5295
|
+
if (this._fromIndex === -1) {
|
|
5296
|
+
this._rows = [];
|
|
5297
|
+
return;
|
|
5298
|
+
}
|
|
5299
|
+
this._trackId = trackId;
|
|
5300
|
+
this._targetIndex = this._fromIndex;
|
|
5301
|
+
this._pointerId = e.pointerId;
|
|
5302
|
+
this._startY = e.clientY;
|
|
5303
|
+
this._gripEl = gripEl;
|
|
5304
|
+
const timeline = this._host.shadowRoot?.querySelector(".timeline");
|
|
5305
|
+
const laneEls = timeline ? [...timeline.querySelectorAll(".track-row")] : [];
|
|
5306
|
+
this._lanes = this._rows.map((r) => {
|
|
5307
|
+
const el = laneEls.find((l) => l.getAttribute("data-track-id") === r.trackId) ?? null;
|
|
5308
|
+
if (!el) return null;
|
|
5309
|
+
const rect = el.getBoundingClientRect();
|
|
5310
|
+
return { el, top: rect.top, height: rect.height, trackId: r.trackId };
|
|
5311
|
+
});
|
|
5312
|
+
const draggedLane = this._lanes[this._fromIndex];
|
|
5313
|
+
if (draggedLane) {
|
|
5314
|
+
draggedLane.el.setAttribute("data-track-drag-source", "");
|
|
5315
|
+
draggedLane.el.style.zIndex = "10";
|
|
5316
|
+
draggedLane.el.style.position = "relative";
|
|
5317
|
+
}
|
|
5318
|
+
if (!_TrackReorderHandler._reducedMotion()) {
|
|
5319
|
+
for (let i = 0; i < this._rows.length; i++) {
|
|
5320
|
+
if (i !== this._fromIndex) this._rows[i].el.style.transition = "transform 150ms ease";
|
|
5321
|
+
const lane = this._lanes[i];
|
|
5322
|
+
if (lane) lane.el.style.transition = "transform 150ms ease";
|
|
5323
|
+
}
|
|
5324
|
+
}
|
|
5325
|
+
try {
|
|
5326
|
+
gripEl.setPointerCapture(e.pointerId);
|
|
5327
|
+
} catch {
|
|
5328
|
+
}
|
|
5329
|
+
gripEl.addEventListener("pointermove", this._onPointerMove);
|
|
5330
|
+
gripEl.addEventListener("pointerup", this._onPointerUp);
|
|
5331
|
+
gripEl.addEventListener("pointercancel", this._onPointerCancel);
|
|
5332
|
+
};
|
|
5333
|
+
this._onPointerMove = (e) => {
|
|
5334
|
+
if (e.pointerId !== this._pointerId || this._trackId === null) return;
|
|
5335
|
+
const dragged = this._rows[this._fromIndex];
|
|
5336
|
+
const dy = e.clientY - this._startY;
|
|
5337
|
+
dragged.el.style.transform = "translateY(" + dy + "px)";
|
|
5338
|
+
dragged.el.style.zIndex = "10";
|
|
5339
|
+
dragged.el.style.position = "relative";
|
|
5340
|
+
let target = this._fromIndex;
|
|
5341
|
+
for (let i = 0; i < this._rows.length; i++) {
|
|
5342
|
+
if (i === this._fromIndex) continue;
|
|
5343
|
+
const mid = this._rows[i].top + this._rows[i].height / 2;
|
|
5344
|
+
if (i < this._fromIndex && e.clientY < mid) {
|
|
5345
|
+
target = i;
|
|
5346
|
+
break;
|
|
5347
|
+
}
|
|
5348
|
+
if (i > this._fromIndex && e.clientY > mid) {
|
|
5349
|
+
target = i;
|
|
5350
|
+
}
|
|
5351
|
+
}
|
|
5352
|
+
this._targetIndex = target;
|
|
5353
|
+
for (let i = 0; i < this._rows.length; i++) {
|
|
5354
|
+
if (i === this._fromIndex) continue;
|
|
5355
|
+
const row = this._rows[i];
|
|
5356
|
+
let shift = 0;
|
|
5357
|
+
if (i > this._fromIndex && i <= target) shift = -dragged.height;
|
|
5358
|
+
else if (i < this._fromIndex && i >= target) shift = dragged.height;
|
|
5359
|
+
row.el.style.transform = shift === 0 ? "" : "translateY(" + shift + "px)";
|
|
5360
|
+
}
|
|
5361
|
+
const draggedLaneInfo = this._lanes[this._fromIndex];
|
|
5362
|
+
for (let i = 0; i < this._lanes.length; i++) {
|
|
5363
|
+
const lane = this._lanes[i];
|
|
5364
|
+
if (!lane || !draggedLaneInfo) continue;
|
|
5365
|
+
if (i === this._fromIndex) {
|
|
5366
|
+
let offset = 0;
|
|
5367
|
+
const targetLane = this._lanes[target];
|
|
5368
|
+
if (targetLane && target > this._fromIndex) {
|
|
5369
|
+
offset = targetLane.top + targetLane.height - (draggedLaneInfo.top + draggedLaneInfo.height);
|
|
5370
|
+
} else if (targetLane && target < this._fromIndex) {
|
|
5371
|
+
offset = targetLane.top - draggedLaneInfo.top;
|
|
5372
|
+
}
|
|
5373
|
+
lane.el.style.transform = offset === 0 ? "" : "translateY(" + offset + "px)";
|
|
5374
|
+
continue;
|
|
5375
|
+
}
|
|
5376
|
+
let laneShift = 0;
|
|
5377
|
+
if (i > this._fromIndex && i <= target) laneShift = -draggedLaneInfo.height;
|
|
5378
|
+
else if (i < this._fromIndex && i >= target) laneShift = draggedLaneInfo.height;
|
|
5379
|
+
lane.el.style.transform = laneShift === 0 ? "" : "translateY(" + laneShift + "px)";
|
|
5380
|
+
}
|
|
5381
|
+
};
|
|
5382
|
+
this._onPointerUp = (e) => {
|
|
5383
|
+
if (e.pointerId !== this._pointerId || this._trackId === null) return;
|
|
5384
|
+
const trackId = this._trackId;
|
|
5385
|
+
const target = this._targetIndex;
|
|
5386
|
+
const from = this._fromIndex;
|
|
5387
|
+
this._cleanup();
|
|
5388
|
+
if (target !== from) {
|
|
5389
|
+
this._host.reorderTrack(trackId, target);
|
|
5390
|
+
}
|
|
5391
|
+
};
|
|
5392
|
+
this._onPointerCancel = (e) => {
|
|
5393
|
+
if (e.pointerId !== this._pointerId) return;
|
|
5394
|
+
this._cleanup();
|
|
5395
|
+
};
|
|
5396
|
+
this._host = host;
|
|
5397
|
+
}
|
|
5398
|
+
static _reducedMotion() {
|
|
5399
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
5400
|
+
}
|
|
5401
|
+
/** Abort any in-progress drag and reset state. Called by the editor on
|
|
5402
|
+
* disconnect — without this, a drag interrupted by editor removal (with no
|
|
5403
|
+
* pointercancel delivered) would leave the handler wedged and silently
|
|
5404
|
+
* block every future grab. */
|
|
5405
|
+
cancel() {
|
|
5406
|
+
this._cleanup();
|
|
5407
|
+
}
|
|
5408
|
+
_cleanup() {
|
|
5409
|
+
for (const row of this._rows) {
|
|
5410
|
+
row.el.style.transform = "";
|
|
5411
|
+
row.el.style.zIndex = "";
|
|
5412
|
+
row.el.style.position = "";
|
|
5413
|
+
row.el.style.transition = "";
|
|
5414
|
+
}
|
|
5415
|
+
for (const lane of this._lanes) {
|
|
5416
|
+
if (!lane) continue;
|
|
5417
|
+
lane.el.style.transform = "";
|
|
5418
|
+
lane.el.style.transition = "";
|
|
5419
|
+
lane.el.style.zIndex = "";
|
|
5420
|
+
lane.el.style.position = "";
|
|
5421
|
+
lane.el.removeAttribute("data-track-drag-source");
|
|
5422
|
+
}
|
|
5423
|
+
this._lanes = [];
|
|
5424
|
+
const grip = this._gripEl;
|
|
5425
|
+
if (grip) {
|
|
5426
|
+
grip.removeEventListener("pointermove", this._onPointerMove);
|
|
5427
|
+
grip.removeEventListener("pointerup", this._onPointerUp);
|
|
5428
|
+
grip.removeEventListener("pointercancel", this._onPointerCancel);
|
|
5429
|
+
try {
|
|
5430
|
+
grip.releasePointerCapture(this._pointerId);
|
|
5431
|
+
} catch {
|
|
5432
|
+
}
|
|
4037
5433
|
}
|
|
4038
|
-
this.
|
|
4039
|
-
this.
|
|
4040
|
-
this.
|
|
4041
|
-
this.
|
|
4042
|
-
this._isDragging = false;
|
|
4043
|
-
this._cumulativeDeltaSamples = 0;
|
|
4044
|
-
this._clipContainer = null;
|
|
4045
|
-
this._originalLeft = 0;
|
|
4046
|
-
this._originalWidth = 0;
|
|
4047
|
-
this._originalOffsetSamples = 0;
|
|
4048
|
-
this._originalDurationSamples = 0;
|
|
4049
|
-
this._originalStartSample = 0;
|
|
5434
|
+
this._gripEl = null;
|
|
5435
|
+
this._trackId = null;
|
|
5436
|
+
this._pointerId = -1;
|
|
5437
|
+
this._rows = [];
|
|
4050
5438
|
}
|
|
4051
5439
|
};
|
|
4052
5440
|
|
|
@@ -4102,7 +5490,6 @@ function parseDisplayTime(value, format) {
|
|
|
4102
5490
|
}
|
|
4103
5491
|
|
|
4104
5492
|
// src/interactions/file-loader.ts
|
|
4105
|
-
var import_core7 = require("@waveform-playlist/core");
|
|
4106
5493
|
async function loadFiles(host, files) {
|
|
4107
5494
|
if (!files) {
|
|
4108
5495
|
console.warn("[dawcore] loadFiles called with null/undefined");
|
|
@@ -4111,107 +5498,36 @@ async function loadFiles(host, files) {
|
|
|
4111
5498
|
const fileArray = Array.from(files);
|
|
4112
5499
|
const loaded = [];
|
|
4113
5500
|
const failed = [];
|
|
5501
|
+
const dispatchLoadError = (file, error) => {
|
|
5502
|
+
failed.push({ file, error });
|
|
5503
|
+
if (host.isConnected) {
|
|
5504
|
+
host.dispatchEvent(
|
|
5505
|
+
new CustomEvent("daw-files-load-error", {
|
|
5506
|
+
bubbles: true,
|
|
5507
|
+
composed: true,
|
|
5508
|
+
detail: { file, error }
|
|
5509
|
+
})
|
|
5510
|
+
);
|
|
5511
|
+
}
|
|
5512
|
+
};
|
|
4114
5513
|
for (const file of fileArray) {
|
|
4115
5514
|
if (file.type && !file.type.startsWith("audio/")) {
|
|
4116
5515
|
const error = new Error("Non-audio MIME type: " + file.type);
|
|
4117
|
-
failed.push({ file, error });
|
|
4118
5516
|
console.warn("[dawcore] Skipping non-audio file: " + file.name + " (" + file.type + ")");
|
|
4119
|
-
|
|
4120
|
-
host.dispatchEvent(
|
|
4121
|
-
new CustomEvent("daw-files-load-error", {
|
|
4122
|
-
bubbles: true,
|
|
4123
|
-
composed: true,
|
|
4124
|
-
detail: { file, error }
|
|
4125
|
-
})
|
|
4126
|
-
);
|
|
4127
|
-
}
|
|
5517
|
+
dispatchLoadError(file, error);
|
|
4128
5518
|
continue;
|
|
4129
5519
|
}
|
|
4130
5520
|
const blobUrl = URL.createObjectURL(file);
|
|
5521
|
+
const name = file.name.replace(/\.\w+$/, "");
|
|
4131
5522
|
try {
|
|
4132
|
-
const
|
|
4133
|
-
|
|
4134
|
-
host._audioCache.delete(blobUrl);
|
|
4135
|
-
host._resolvedSampleRate = audioBuffer.sampleRate;
|
|
4136
|
-
const name = file.name.replace(/\.\w+$/, "");
|
|
4137
|
-
const clip = (0, import_core7.createClip)({
|
|
4138
|
-
audioBuffer,
|
|
4139
|
-
startSample: 0,
|
|
4140
|
-
durationSamples: audioBuffer.length,
|
|
4141
|
-
offsetSamples: 0,
|
|
4142
|
-
gain: 1,
|
|
4143
|
-
name,
|
|
4144
|
-
sampleRate: audioBuffer.sampleRate,
|
|
4145
|
-
sourceDurationSamples: audioBuffer.length
|
|
4146
|
-
});
|
|
4147
|
-
host._clipBuffers = new Map(host._clipBuffers).set(clip.id, audioBuffer);
|
|
4148
|
-
host._clipOffsets = new Map(host._clipOffsets).set(clip.id, {
|
|
4149
|
-
offsetSamples: clip.offsetSamples,
|
|
4150
|
-
durationSamples: clip.durationSamples
|
|
4151
|
-
});
|
|
4152
|
-
const peakData = await host._peakPipeline.generatePeaks(
|
|
4153
|
-
audioBuffer,
|
|
4154
|
-
host.renderSamplesPerPixel,
|
|
4155
|
-
host.mono,
|
|
4156
|
-
clip.offsetSamples,
|
|
4157
|
-
clip.durationSamples
|
|
4158
|
-
);
|
|
4159
|
-
host._peaksData = new Map(host._peaksData).set(clip.id, peakData);
|
|
4160
|
-
const trackId = crypto.randomUUID();
|
|
4161
|
-
const track = (0, import_core7.createTrack)({ name, clips: [clip] });
|
|
4162
|
-
track.id = trackId;
|
|
4163
|
-
host._tracks = new Map(host._tracks).set(trackId, {
|
|
4164
|
-
name,
|
|
4165
|
-
src: "",
|
|
4166
|
-
volume: 1,
|
|
4167
|
-
pan: 0,
|
|
4168
|
-
muted: false,
|
|
4169
|
-
soloed: false,
|
|
4170
|
-
renderMode: "waveform",
|
|
4171
|
-
clips: [
|
|
4172
|
-
{
|
|
4173
|
-
kind: "drop",
|
|
4174
|
-
src: "",
|
|
4175
|
-
peaksSrc: "",
|
|
4176
|
-
start: 0,
|
|
4177
|
-
duration: audioBuffer.duration,
|
|
4178
|
-
offset: 0,
|
|
4179
|
-
gain: 1,
|
|
4180
|
-
name,
|
|
4181
|
-
fadeIn: 0,
|
|
4182
|
-
fadeOut: 0,
|
|
4183
|
-
fadeType: "linear",
|
|
4184
|
-
midiNotes: null,
|
|
4185
|
-
midiChannel: null,
|
|
4186
|
-
midiProgram: null
|
|
4187
|
-
}
|
|
4188
|
-
]
|
|
4189
|
-
});
|
|
4190
|
-
host._engineTracks = new Map(host._engineTracks).set(trackId, track);
|
|
4191
|
-
host._recomputeDuration();
|
|
4192
|
-
const engine = await host._ensureEngine();
|
|
4193
|
-
engine.setTracks([...host._engineTracks.values()]);
|
|
4194
|
-
loaded.push(trackId);
|
|
4195
|
-
host.dispatchEvent(
|
|
4196
|
-
new CustomEvent("daw-track-ready", {
|
|
4197
|
-
bubbles: true,
|
|
4198
|
-
composed: true,
|
|
4199
|
-
detail: { trackId }
|
|
4200
|
-
})
|
|
4201
|
-
);
|
|
5523
|
+
const trackEl = await host.addTrack({ name, clips: [{ src: blobUrl, name }] });
|
|
5524
|
+
loaded.push(trackEl.trackId);
|
|
4202
5525
|
} catch (err) {
|
|
4203
|
-
URL.revokeObjectURL(blobUrl);
|
|
4204
5526
|
console.warn("[dawcore] Failed to load file: " + file.name + " \u2014 " + String(err));
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
bubbles: true,
|
|
4210
|
-
composed: true,
|
|
4211
|
-
detail: { file, error: err }
|
|
4212
|
-
})
|
|
4213
|
-
);
|
|
4214
|
-
}
|
|
5527
|
+
dispatchLoadError(file, err);
|
|
5528
|
+
} finally {
|
|
5529
|
+
URL.revokeObjectURL(blobUrl);
|
|
5530
|
+
host._audioCache.delete(blobUrl);
|
|
4215
5531
|
}
|
|
4216
5532
|
}
|
|
4217
5533
|
return { loaded, failed };
|
|
@@ -4320,7 +5636,7 @@ function stringifyReason(reason) {
|
|
|
4320
5636
|
}
|
|
4321
5637
|
|
|
4322
5638
|
// src/interactions/recording-clip.ts
|
|
4323
|
-
var
|
|
5639
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
4324
5640
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
4325
5641
|
let trimmedBuf = buf;
|
|
4326
5642
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -4335,7 +5651,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4335
5651
|
}
|
|
4336
5652
|
trimmedBuf = trimmed;
|
|
4337
5653
|
}
|
|
4338
|
-
const clip = (0,
|
|
5654
|
+
const clip = (0, import_core11.createClip)({
|
|
4339
5655
|
audioBuffer: trimmedBuf,
|
|
4340
5656
|
startSample,
|
|
4341
5657
|
durationSamples: durSamples,
|
|
@@ -4362,7 +5678,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4362
5678
|
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
4363
5679
|
// startSample + durSamples) — carve overlapped content out of the
|
|
4364
5680
|
// existing clips before inserting (parity with the React provider).
|
|
4365
|
-
clips: [...(0,
|
|
5681
|
+
clips: [...(0, import_core11.carveClipRange)(t.clips, startSample, startSample + durSamples), clip]
|
|
4366
5682
|
});
|
|
4367
5683
|
const desc = host._tracks.get(trackId);
|
|
4368
5684
|
if (desc) {
|
|
@@ -4436,9 +5752,9 @@ function splitAtPlayhead(host) {
|
|
|
4436
5752
|
function canSplitAtTime(host, time) {
|
|
4437
5753
|
const { engine } = host;
|
|
4438
5754
|
if (!engine) return false;
|
|
4439
|
-
const
|
|
4440
|
-
if (!
|
|
4441
|
-
const track =
|
|
5755
|
+
const state9 = engine.getState();
|
|
5756
|
+
if (!state9.selectedTrackId) return false;
|
|
5757
|
+
const track = state9.tracks.find((t) => t.id === state9.selectedTrackId);
|
|
4442
5758
|
if (!track) return false;
|
|
4443
5759
|
const atSample = Math.round(time * host.effectiveSampleRate);
|
|
4444
5760
|
const clip = findClipAtSample(track.clips, atSample);
|
|
@@ -4631,9 +5947,9 @@ var EffectsChainController = class {
|
|
|
4631
5947
|
placeholder: true
|
|
4632
5948
|
};
|
|
4633
5949
|
}
|
|
4634
|
-
let
|
|
5950
|
+
let state9;
|
|
4635
5951
|
try {
|
|
4636
|
-
|
|
5952
|
+
state9 = await entry.instance.getState?.();
|
|
4637
5953
|
} catch (err) {
|
|
4638
5954
|
console.warn(
|
|
4639
5955
|
'[waveform-playlist] serialize: plugin "' + (entry.url ?? entry.label ?? entry.type) + '" getState failed: ' + String(err)
|
|
@@ -4643,7 +5959,7 @@ var EffectsChainController = class {
|
|
|
4643
5959
|
kind: "wam",
|
|
4644
5960
|
...sourceFields,
|
|
4645
5961
|
bypassed: entry.bypassed,
|
|
4646
|
-
...
|
|
5962
|
+
...state9 !== void 0 ? { state: state9 } : {}
|
|
4647
5963
|
};
|
|
4648
5964
|
}
|
|
4649
5965
|
if (entry.placeholder) {
|
|
@@ -5943,6 +7259,7 @@ var PlaybackAnimationController = class {
|
|
|
5943
7259
|
this._running = true;
|
|
5944
7260
|
this._animation.start(() => {
|
|
5945
7261
|
const time = getTime();
|
|
7262
|
+
if (!this._running) return;
|
|
5946
7263
|
this._options.getPlayhead()?.setPosition(this._options.timeToPixels(time));
|
|
5947
7264
|
this._dispatchTimeUpdate(time);
|
|
5948
7265
|
});
|
|
@@ -5980,7 +7297,7 @@ var TrackLoadCancelledError = class extends Error {
|
|
|
5980
7297
|
this.name = "TrackLoadCancelledError";
|
|
5981
7298
|
}
|
|
5982
7299
|
};
|
|
5983
|
-
var DawEditorElement = class extends
|
|
7300
|
+
var DawEditorElement = class extends import_lit19.LitElement {
|
|
5984
7301
|
constructor() {
|
|
5985
7302
|
super(...arguments);
|
|
5986
7303
|
this._samplesPerPixel = 1024;
|
|
@@ -5997,6 +7314,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
5997
7314
|
this.interactiveClips = false;
|
|
5998
7315
|
this.indefinitePlayback = false;
|
|
5999
7316
|
this.fillViewport = false;
|
|
7317
|
+
this.trackReordering = false;
|
|
6000
7318
|
this._spectrogramConfig = null;
|
|
6001
7319
|
this._spectrogramColorMap = null;
|
|
6002
7320
|
this.scaleMode = "temporal";
|
|
@@ -6018,6 +7336,13 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6018
7336
|
this._selectionStartTime = 0;
|
|
6019
7337
|
this._selectionEndTime = 0;
|
|
6020
7338
|
this._currentTime = 0;
|
|
7339
|
+
// Bounded-playback watermark for the current play(start, end) call
|
|
7340
|
+
// (selection/annotation playback). The adapter's own auto-stop at
|
|
7341
|
+
// endTime (e.g. native Transport's internal timer) tears down audio but
|
|
7342
|
+
// never notifies isPlaying/daw-stop back up — the _startPlayhead rAF
|
|
7343
|
+
// loop below is the sole place that detects reaching it, same pattern
|
|
7344
|
+
// as the whole-track _duration check.
|
|
7345
|
+
this._activePlayEndTime = null;
|
|
6021
7346
|
this._externalAdapter = null;
|
|
6022
7347
|
/** True after a disconnect disposed the consumer's adapter via the engine
|
|
6023
7348
|
* — rebuild attempts fail loudly until a fresh adapter is set. */
|
|
@@ -6044,6 +7369,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6044
7369
|
this._childObserver = null;
|
|
6045
7370
|
this._audioResume = new AudioResumeController(this);
|
|
6046
7371
|
this._recordingController = new RecordingController(this);
|
|
7372
|
+
this._annotations = new AnnotationController(this);
|
|
7373
|
+
/** Last engine BPM seen by the statechange handler — re-derives tick
|
|
7374
|
+
* annotation seconds caches only when it actually changes. */
|
|
7375
|
+
this._lastAnnotationBpm = null;
|
|
6047
7376
|
// Closures (not direct references) — _timeToPixels/_getPlayhead are
|
|
6048
7377
|
// declared later in the class body; class-field init order would read
|
|
6049
7378
|
// `undefined` for a direct reference here.
|
|
@@ -6058,8 +7387,18 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6058
7387
|
* play-start position). Non-private: pointer-handler's seek path sets it.
|
|
6059
7388
|
*/
|
|
6060
7389
|
this._inSeekTransition = false;
|
|
7390
|
+
/**
|
|
7391
|
+
* True while `stop()` (the public API) is actively calling `this._engine.stop()`.
|
|
7392
|
+
* Suppresses the engine 'stop' handler's own `daw-stop` dispatch — `stop()`
|
|
7393
|
+
* dispatches its own, and without this guard a consumer-initiated stop would
|
|
7394
|
+
* fire `daw-stop` twice. See the engine 'stop' handler for the counterpart
|
|
7395
|
+
* engine-initiated case this flag does NOT suppress.
|
|
7396
|
+
*/
|
|
7397
|
+
this._inConsumerStop = false;
|
|
6061
7398
|
this._spectrogramController = null;
|
|
6062
7399
|
this._clipPointer = new ClipPointerHandler(this);
|
|
7400
|
+
this._annotationDrag = new AnnotationDragHandler(this);
|
|
7401
|
+
this._trackReorderDrag = new TrackReorderHandler(this);
|
|
6063
7402
|
this._pointer = new PointerHandler(this);
|
|
6064
7403
|
this._viewport = (() => {
|
|
6065
7404
|
const v = new ViewportController(this);
|
|
@@ -6083,6 +7422,18 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6083
7422
|
* update for properties unrelated to the viewport.
|
|
6084
7423
|
*/
|
|
6085
7424
|
this._lastSpectrogramViewport = null;
|
|
7425
|
+
// --- Annotation Events ---
|
|
7426
|
+
this._onAnnotationTrackConnected = (e) => {
|
|
7427
|
+
this._annotations.handleTrackConnected(e.detail.element);
|
|
7428
|
+
};
|
|
7429
|
+
this._onAnnotationSelect = (e) => {
|
|
7430
|
+
const annotation = e.detail.annotation;
|
|
7431
|
+
if (!annotation) return;
|
|
7432
|
+
const scrollArea = this.shadowRoot?.querySelector(".scroll-area");
|
|
7433
|
+
if (!scrollArea) return;
|
|
7434
|
+
const px = Math.floor(annotation.start * this.effectiveSampleRate / this._renderSpp);
|
|
7435
|
+
scrollArea.scrollLeft = Math.max(0, px - scrollArea.clientWidth / 2);
|
|
7436
|
+
};
|
|
6086
7437
|
// --- Track Events ---
|
|
6087
7438
|
this._onTrackConnected = (e) => {
|
|
6088
7439
|
const trackId = e.detail?.trackId;
|
|
@@ -6091,6 +7442,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6091
7442
|
console.warn("[dawcore] Invalid daw-track-connected event detail: " + String(e.detail));
|
|
6092
7443
|
return;
|
|
6093
7444
|
}
|
|
7445
|
+
if (this._tracks.has(trackId)) {
|
|
7446
|
+
this._trackElements.set(trackId, trackEl);
|
|
7447
|
+
return;
|
|
7448
|
+
}
|
|
6094
7449
|
const descriptor = this._readTrackDescriptor(trackEl);
|
|
6095
7450
|
this._tracks = new Map(this._tracks).set(trackId, descriptor);
|
|
6096
7451
|
this._trackElements.set(trackId, trackEl);
|
|
@@ -6200,6 +7555,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6200
7555
|
}
|
|
6201
7556
|
return;
|
|
6202
7557
|
}
|
|
7558
|
+
const loadedDesc = this._tracks.get(trackId);
|
|
7559
|
+
if (loadedDesc && loadedDesc.clips.some((c) => isDomClip(c) && c.clipId === clipEl.clipId)) {
|
|
7560
|
+
return;
|
|
7561
|
+
}
|
|
6203
7562
|
const clipDesc = {
|
|
6204
7563
|
kind: "dom",
|
|
6205
7564
|
clipId: clipEl.clipId,
|
|
@@ -6264,6 +7623,13 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6264
7623
|
);
|
|
6265
7624
|
}
|
|
6266
7625
|
};
|
|
7626
|
+
this._onTrackReorder = (e) => {
|
|
7627
|
+
this.reorderTrack(e.detail.trackId, e.detail.toIndex);
|
|
7628
|
+
};
|
|
7629
|
+
this._onTrackReorderGrab = (e) => {
|
|
7630
|
+
if (!this.trackReordering) return;
|
|
7631
|
+
this._trackReorderDrag.onGrab(e.detail.trackId, e.detail.pointerEvent, e.detail.gripElement);
|
|
7632
|
+
};
|
|
6267
7633
|
// --- Recording ---
|
|
6268
7634
|
this.recordingStream = null;
|
|
6269
7635
|
/** Set in togglePauseRecording when Transport is paused alongside the
|
|
@@ -6277,6 +7643,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6277
7643
|
}
|
|
6278
7644
|
return time * this.effectiveSampleRate / this.samplesPerPixel;
|
|
6279
7645
|
};
|
|
7646
|
+
/** Guards the statechange handler's engine→DOM sync (Task: reorder #612)
|
|
7647
|
+
* while the observer is pushing DOM order INTO the engine — the intermediate
|
|
7648
|
+
* statechange emissions during the transaction would otherwise bounce
|
|
7649
|
+
* half-applied orders back into the DOM. */
|
|
7650
|
+
this._inOrderSync = false;
|
|
6280
7651
|
}
|
|
6281
7652
|
get samplesPerPixel() {
|
|
6282
7653
|
return this._samplesPerPixel;
|
|
@@ -6726,6 +8097,12 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6726
8097
|
}
|
|
6727
8098
|
return ticks * 60 / (this.bpm * this.ppqn);
|
|
6728
8099
|
}
|
|
8100
|
+
/** Clamp limit for annotation boundary edits. indefinite-playback removes the
|
|
8101
|
+
* end-of-timeline bound — annotations may extend past the audio (DAW-style
|
|
8102
|
+
* unbounded timeline); the shared boundary math treats Infinity as "no end cap". */
|
|
8103
|
+
get _annotationClampDuration() {
|
|
8104
|
+
return this.indefinitePlayback ? Infinity : this._duration;
|
|
8105
|
+
}
|
|
6729
8106
|
get _totalWidth() {
|
|
6730
8107
|
if (this.scaleMode === "beats") {
|
|
6731
8108
|
const contentTicks = this._secondsToTicks(this._duration);
|
|
@@ -6733,8 +8110,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6733
8110
|
const minTicks = 32 * num * this.ppqn;
|
|
6734
8111
|
return Math.ceil(Math.max(contentTicks, minTicks) / this.ticksPerPixel);
|
|
6735
8112
|
}
|
|
8113
|
+
const naturalDuration = Math.max(this._duration, this._annotations.maxAnnotationEndSeconds);
|
|
6736
8114
|
const naturalWidth = Math.ceil(
|
|
6737
|
-
|
|
8115
|
+
naturalDuration * this.effectiveSampleRate / this.samplesPerPixel
|
|
6738
8116
|
);
|
|
6739
8117
|
if (this.indefinitePlayback || this.fillViewport) {
|
|
6740
8118
|
return Math.max(naturalWidth, this._viewport.containerWidth);
|
|
@@ -6786,30 +8164,55 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6786
8164
|
this.addEventListener("daw-track-remove", this._onTrackRemoveRequest);
|
|
6787
8165
|
this.addEventListener("daw-clip-connected", this._onClipConnected);
|
|
6788
8166
|
this.addEventListener("daw-clip-update", this._onClipUpdate);
|
|
8167
|
+
this.addEventListener(
|
|
8168
|
+
"daw-annotation-track-connected",
|
|
8169
|
+
this._onAnnotationTrackConnected
|
|
8170
|
+
);
|
|
8171
|
+
this.addEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
8172
|
+
this.addEventListener("daw-track-reorder", this._onTrackReorder);
|
|
8173
|
+
this.addEventListener("daw-track-reorder-grab", this._onTrackReorderGrab);
|
|
6789
8174
|
this._childObserver = new MutationObserver((mutations) => {
|
|
8175
|
+
const removedTracks = /* @__PURE__ */ new Map();
|
|
8176
|
+
const removedClips = /* @__PURE__ */ new Set();
|
|
8177
|
+
const addedTrackIds = /* @__PURE__ */ new Set();
|
|
6790
8178
|
for (const mutation of mutations) {
|
|
8179
|
+
for (const node of mutation.addedNodes) {
|
|
8180
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
8181
|
+
if (node.tagName === "DAW-TRACK") {
|
|
8182
|
+
addedTrackIds.add(node.trackId);
|
|
8183
|
+
}
|
|
8184
|
+
node.querySelectorAll?.("daw-track").forEach((t) => {
|
|
8185
|
+
addedTrackIds.add(t.trackId);
|
|
8186
|
+
});
|
|
8187
|
+
}
|
|
6791
8188
|
for (const node of mutation.removedNodes) {
|
|
6792
|
-
if (node instanceof HTMLElement)
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
}
|
|
6798
|
-
const nestedTracks = node.querySelectorAll?.("daw-track");
|
|
6799
|
-
if (nestedTracks) {
|
|
6800
|
-
for (const track of nestedTracks) {
|
|
6801
|
-
this._onTrackRemoved(track.trackId);
|
|
6802
|
-
}
|
|
6803
|
-
}
|
|
6804
|
-
const nestedClips = node.querySelectorAll?.("daw-clip");
|
|
6805
|
-
if (nestedClips) {
|
|
6806
|
-
for (const clip of nestedClips) {
|
|
6807
|
-
this._onClipRemovedFromDom(clip);
|
|
6808
|
-
}
|
|
6809
|
-
}
|
|
8189
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
8190
|
+
if (node.tagName === "DAW-TRACK") {
|
|
8191
|
+
removedTracks.set(node.trackId, node);
|
|
8192
|
+
} else if (node.tagName === "DAW-CLIP") {
|
|
8193
|
+
removedClips.add(node);
|
|
6810
8194
|
}
|
|
8195
|
+
node.querySelectorAll?.("daw-track").forEach((t) => {
|
|
8196
|
+
removedTracks.set(t.trackId, t);
|
|
8197
|
+
});
|
|
8198
|
+
node.querySelectorAll?.("daw-clip").forEach((c) => {
|
|
8199
|
+
removedClips.add(c);
|
|
8200
|
+
});
|
|
6811
8201
|
}
|
|
6812
8202
|
}
|
|
8203
|
+
let orderMayHaveChanged = addedTrackIds.size > 0;
|
|
8204
|
+
for (const [trackId] of removedTracks) {
|
|
8205
|
+
if (addedTrackIds.has(trackId)) {
|
|
8206
|
+
orderMayHaveChanged = true;
|
|
8207
|
+
continue;
|
|
8208
|
+
}
|
|
8209
|
+
this._onTrackRemoved(trackId);
|
|
8210
|
+
}
|
|
8211
|
+
for (const clip of removedClips) {
|
|
8212
|
+
if (clip.isConnected) continue;
|
|
8213
|
+
this._onClipRemovedFromDom(clip);
|
|
8214
|
+
}
|
|
8215
|
+
if (orderMayHaveChanged) this._syncEngineOrderToDom();
|
|
6813
8216
|
});
|
|
6814
8217
|
this._childObserver.observe(this, { childList: true, subtree: true });
|
|
6815
8218
|
}
|
|
@@ -6823,6 +8226,14 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6823
8226
|
this.removeEventListener("daw-track-remove", this._onTrackRemoveRequest);
|
|
6824
8227
|
this.removeEventListener("daw-clip-connected", this._onClipConnected);
|
|
6825
8228
|
this.removeEventListener("daw-clip-update", this._onClipUpdate);
|
|
8229
|
+
this.removeEventListener(
|
|
8230
|
+
"daw-annotation-track-connected",
|
|
8231
|
+
this._onAnnotationTrackConnected
|
|
8232
|
+
);
|
|
8233
|
+
this.removeEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
8234
|
+
this.removeEventListener("daw-track-reorder", this._onTrackReorder);
|
|
8235
|
+
this.removeEventListener("daw-track-reorder-grab", this._onTrackReorderGrab);
|
|
8236
|
+
this._trackReorderDrag.cancel();
|
|
6826
8237
|
this._childObserver?.disconnect();
|
|
6827
8238
|
this._childObserver = null;
|
|
6828
8239
|
this._trackElements.clear();
|
|
@@ -7097,7 +8508,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7097
8508
|
let clip;
|
|
7098
8509
|
if (waveformData) {
|
|
7099
8510
|
const wdRate = waveformData.sample_rate;
|
|
7100
|
-
clip = (0,
|
|
8511
|
+
clip = (0, import_core12.createClip)({
|
|
7101
8512
|
audioBuffer,
|
|
7102
8513
|
waveformData,
|
|
7103
8514
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
@@ -7110,7 +8521,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7110
8521
|
});
|
|
7111
8522
|
this._peakPipeline.cacheWaveformData(audioBuffer, waveformData);
|
|
7112
8523
|
} else {
|
|
7113
|
-
clip = (0,
|
|
8524
|
+
clip = (0, import_core12.createClipFromSeconds)({
|
|
7114
8525
|
audioBuffer,
|
|
7115
8526
|
startTime: clipDesc.start,
|
|
7116
8527
|
duration: clipDesc.duration || audioBuffer.duration,
|
|
@@ -7189,7 +8600,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7189
8600
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
7190
8601
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipDesc.duration, 1) * sr);
|
|
7191
8602
|
const requestedDurationSamples = clipDesc.duration > 0 ? Math.round(clipDesc.duration * sr) : sourceDurationSamples;
|
|
7192
|
-
const clip = (0,
|
|
8603
|
+
const clip = (0, import_core12.createClip)({
|
|
7193
8604
|
startSample: Math.round(clipDesc.start * sr),
|
|
7194
8605
|
durationSamples: requestedDurationSamples,
|
|
7195
8606
|
offsetSamples: Math.round(clipDesc.offset * sr),
|
|
@@ -7225,7 +8636,8 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7225
8636
|
_commitTrackChange(trackId, updatedTrack) {
|
|
7226
8637
|
this._recomputeDuration();
|
|
7227
8638
|
if (this._engine?.updateTrack) this._engine.updateTrack(trackId, updatedTrack);
|
|
7228
|
-
else if (this._engine)
|
|
8639
|
+
else if (this._engine)
|
|
8640
|
+
this._engine.setTracks(this._getOrderedTracks().map(([, track]) => track));
|
|
7229
8641
|
}
|
|
7230
8642
|
_applyClipUpdate(trackId, clipId, clipEl) {
|
|
7231
8643
|
const t = this._engineTracks.get(trackId);
|
|
@@ -7400,7 +8812,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7400
8812
|
const waveformData = await waveformDataPromise;
|
|
7401
8813
|
if (waveformData) {
|
|
7402
8814
|
const wdRate = waveformData.sample_rate;
|
|
7403
|
-
const clip2 = (0,
|
|
8815
|
+
const clip2 = (0, import_core12.createClip)({
|
|
7404
8816
|
waveformData,
|
|
7405
8817
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
7406
8818
|
durationSamples: Math.round((clipDesc.duration || waveformData.duration) * wdRate),
|
|
@@ -7426,7 +8838,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7426
8838
|
this._peaksData = new Map(this._peaksData).set(clip2.id, peakData);
|
|
7427
8839
|
this._raiseZoomFloor(waveformData.scale);
|
|
7428
8840
|
if (this._tracks.has(trackId)) {
|
|
7429
|
-
const previewTrack = (0,
|
|
8841
|
+
const previewTrack = (0, import_core12.createTrack)({
|
|
7430
8842
|
name: descriptor.name,
|
|
7431
8843
|
clips: [clip2],
|
|
7432
8844
|
volume: descriptor.volume,
|
|
@@ -7503,7 +8915,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7503
8915
|
trackWasRemoved ? "removed" : "disconnected"
|
|
7504
8916
|
);
|
|
7505
8917
|
}
|
|
7506
|
-
const track = (0,
|
|
8918
|
+
const track = (0, import_core12.createTrack)({
|
|
7507
8919
|
name: descriptor.name,
|
|
7508
8920
|
clips,
|
|
7509
8921
|
volume: descriptor.volume,
|
|
@@ -7524,7 +8936,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7524
8936
|
this._maybeRegisterSpectrogramClipAudio(trackId, c);
|
|
7525
8937
|
}
|
|
7526
8938
|
const engine = await this._ensureEngine();
|
|
7527
|
-
engine.setTracks(
|
|
8939
|
+
engine.setTracks(this._getOrderedTracks().map(([, track2]) => track2));
|
|
7528
8940
|
this.dispatchEvent(
|
|
7529
8941
|
new CustomEvent("daw-track-ready", {
|
|
7530
8942
|
bubbles: true,
|
|
@@ -7652,6 +9064,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7652
9064
|
this._reconcileDescriptorsWithEngineTracks(engineState.tracks);
|
|
7653
9065
|
}
|
|
7654
9066
|
if (structuralChange) {
|
|
9067
|
+
if (!this._inOrderSync) {
|
|
9068
|
+
this._syncDomToEngineOrder(engineState.tracks);
|
|
9069
|
+
}
|
|
7655
9070
|
this._effectsManager?.rewireTrackChains();
|
|
7656
9071
|
const audioTracks = engineState.tracks.filter((t) => {
|
|
7657
9072
|
const desc = this._tracks.get(t.id);
|
|
@@ -7659,6 +9074,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7659
9074
|
});
|
|
7660
9075
|
syncPeaksForChangedClips(this, audioTracks);
|
|
7661
9076
|
}
|
|
9077
|
+
if (engineState.bpm !== this._lastAnnotationBpm) {
|
|
9078
|
+
this._lastAnnotationBpm = engineState.bpm;
|
|
9079
|
+
this._annotations.deriveSecondsCaches();
|
|
9080
|
+
}
|
|
7662
9081
|
});
|
|
7663
9082
|
engine.on("pause", () => {
|
|
7664
9083
|
this._currentTime = engine.getCurrentTime();
|
|
@@ -7666,6 +9085,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7666
9085
|
engine.on("stop", () => {
|
|
7667
9086
|
this._currentTime = engine.getCurrentTime();
|
|
7668
9087
|
this._stopPlayhead();
|
|
9088
|
+
this._activePlayEndTime = null;
|
|
9089
|
+
if (!this._inConsumerStop && !this._inSeekTransition && this.isConnected) {
|
|
9090
|
+
this.dispatchEvent(new CustomEvent("daw-stop", { bubbles: true, composed: true }));
|
|
9091
|
+
}
|
|
7669
9092
|
});
|
|
7670
9093
|
this._engine = engine;
|
|
7671
9094
|
return engine;
|
|
@@ -7784,6 +9207,34 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7784
9207
|
console.warn('[dawcore] removeTrack: no track found for id "' + trackId + '"');
|
|
7785
9208
|
}
|
|
7786
9209
|
}
|
|
9210
|
+
/**
|
|
9211
|
+
* Move a track to a new position in the vertical order (0-based index among
|
|
9212
|
+
* `<daw-track>` elements). Element-backed tracks move their DOM element —
|
|
9213
|
+
* the MutationObserver syncs the engine (single write path). Element-less
|
|
9214
|
+
* tracks (undo-resurrected) reorder the engine directly.
|
|
9215
|
+
*/
|
|
9216
|
+
reorderTrack(trackId, toIndex) {
|
|
9217
|
+
if (!Number.isFinite(toIndex)) {
|
|
9218
|
+
console.warn("[dawcore] reorderTrack: invalid toIndex " + String(toIndex));
|
|
9219
|
+
return;
|
|
9220
|
+
}
|
|
9221
|
+
const el = this._trackElements.get(trackId);
|
|
9222
|
+
if (el) {
|
|
9223
|
+
const els = [...this.querySelectorAll("daw-track")];
|
|
9224
|
+
const from = els.indexOf(el);
|
|
9225
|
+
if (from === -1) return;
|
|
9226
|
+
const clamped = Math.max(0, Math.min(toIndex, els.length - 1));
|
|
9227
|
+
if (from === clamped) return;
|
|
9228
|
+
const anchor = els[clamped];
|
|
9229
|
+
if (clamped > from) anchor.after(el);
|
|
9230
|
+
else anchor.before(el);
|
|
9231
|
+
} else if (this._engineTracks.has(trackId)) {
|
|
9232
|
+
this._engine.reorderTrack(trackId, toIndex);
|
|
9233
|
+
this.requestUpdate();
|
|
9234
|
+
} else {
|
|
9235
|
+
console.warn('[dawcore] reorderTrack: no track found for id "' + trackId + '"');
|
|
9236
|
+
}
|
|
9237
|
+
}
|
|
7787
9238
|
/**
|
|
7788
9239
|
* Update reflected attributes on a track. For DOM-element tracks the changes
|
|
7789
9240
|
* are written to the `<daw-track>` element (which fires `daw-track-update`);
|
|
@@ -7966,14 +9417,21 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7966
9417
|
return clipEl;
|
|
7967
9418
|
}
|
|
7968
9419
|
// --- Playback ---
|
|
7969
|
-
|
|
9420
|
+
/**
|
|
9421
|
+
* Start playback, optionally seeking to `startTime` first. When `endTime`
|
|
9422
|
+
* is provided, playback stops at that time (selection/annotation playback).
|
|
9423
|
+
*/
|
|
9424
|
+
async play(startTime, endTime) {
|
|
7970
9425
|
try {
|
|
7971
9426
|
const engine = await this._ensureEngine();
|
|
7972
9427
|
await engine.init();
|
|
7973
|
-
|
|
9428
|
+
this._activePlayEndTime = endTime ?? null;
|
|
7974
9429
|
this._startPlayhead();
|
|
9430
|
+
engine.play(startTime, endTime);
|
|
7975
9431
|
this.dispatchEvent(new CustomEvent("daw-play", { bubbles: true, composed: true }));
|
|
7976
9432
|
} catch (err) {
|
|
9433
|
+
this._stopPlayhead();
|
|
9434
|
+
this._activePlayEndTime = null;
|
|
7977
9435
|
console.warn("[dawcore] Playback failed: " + String(err));
|
|
7978
9436
|
this.dispatchEvent(
|
|
7979
9437
|
new CustomEvent("daw-error", {
|
|
@@ -7992,7 +9450,13 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7992
9450
|
}
|
|
7993
9451
|
stop() {
|
|
7994
9452
|
if (!this._engine) return;
|
|
7995
|
-
this.
|
|
9453
|
+
this._activePlayEndTime = null;
|
|
9454
|
+
this._inConsumerStop = true;
|
|
9455
|
+
try {
|
|
9456
|
+
this._engine.stop();
|
|
9457
|
+
} finally {
|
|
9458
|
+
this._inConsumerStop = false;
|
|
9459
|
+
}
|
|
7996
9460
|
this._stopPlayhead();
|
|
7997
9461
|
this.dispatchEvent(new CustomEvent("daw-stop", { bubbles: true, composed: true }));
|
|
7998
9462
|
}
|
|
@@ -8046,6 +9510,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8046
9510
|
);
|
|
8047
9511
|
return;
|
|
8048
9512
|
}
|
|
9513
|
+
this._activePlayEndTime = null;
|
|
8049
9514
|
this._currentTime = target;
|
|
8050
9515
|
this._startPlayhead();
|
|
8051
9516
|
} else {
|
|
@@ -8213,16 +9678,16 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8213
9678
|
const { left, width: w } = this._previewPosition(rs.startSample, audibleSamples);
|
|
8214
9679
|
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
8215
9680
|
const height = hdrH + chH * rs.peaks.length;
|
|
8216
|
-
return
|
|
9681
|
+
return import_lit19.html`<div
|
|
8217
9682
|
class="clip-container recording-preview"
|
|
8218
9683
|
style="left:${left}px;top:0;width:${w}px;height:${height}px;"
|
|
8219
9684
|
>
|
|
8220
|
-
${hdrH > 0 ?
|
|
9685
|
+
${hdrH > 0 ? import_lit19.html`<div class="clip-header" data-track-id=${trackId}>
|
|
8221
9686
|
<span>${rs.clipName ?? "Recording\u2026"}</span>
|
|
8222
9687
|
</div>` : ""}
|
|
8223
9688
|
${rs.peaks.map((chPeaks, ch) => {
|
|
8224
9689
|
const slicedPeaks = latencyPixels > 0 ? chPeaks.slice(latencyPixels * 2) : chPeaks;
|
|
8225
|
-
return
|
|
9690
|
+
return import_lit19.html`
|
|
8226
9691
|
<daw-waveform
|
|
8227
9692
|
data-recording-track=${trackId}
|
|
8228
9693
|
data-recording-channel=${ch}
|
|
@@ -8245,6 +9710,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8245
9710
|
if (!this._engine) return;
|
|
8246
9711
|
const engine = this._engine;
|
|
8247
9712
|
this._playbackAnimation.start(() => {
|
|
9713
|
+
if (this._activePlayEndTime !== null && !this.isRecording && engine.getCurrentTime() >= this._activePlayEndTime) {
|
|
9714
|
+
this.stop();
|
|
9715
|
+
const t = this._currentTime;
|
|
9716
|
+
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
9717
|
+
}
|
|
8248
9718
|
if (!this.indefinitePlayback && !this.isRecording && engine.getCurrentTime() >= this._duration) {
|
|
8249
9719
|
this.stop();
|
|
8250
9720
|
const t = this._currentTime;
|
|
@@ -8269,6 +9739,64 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8269
9739
|
get _showRuler() {
|
|
8270
9740
|
return (this._getOrderedTracks().length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport) && this.timescale;
|
|
8271
9741
|
}
|
|
9742
|
+
/**
|
|
9743
|
+
* DOM → engine: make the engine's track order match the light-DOM
|
|
9744
|
+
* `<daw-track>` order. Single write path for reorders — editor-initiated
|
|
9745
|
+
* (buttons/drag move the element) and consumer-initiated (insertBefore)
|
|
9746
|
+
* mutations both land here via the MutationObserver. Element-less tracks
|
|
9747
|
+
* (undo-resurrected) keep their engine positions (stable sort).
|
|
9748
|
+
* Write-only-on-change: a no-op when orders already match, so the
|
|
9749
|
+
* engine→DOM direction (statechange handler) converges in one pass.
|
|
9750
|
+
*/
|
|
9751
|
+
_syncEngineOrderToDom() {
|
|
9752
|
+
const engine = this._engine;
|
|
9753
|
+
if (!engine) return;
|
|
9754
|
+
const domOrder = [...this.querySelectorAll("daw-track")].map(
|
|
9755
|
+
(el) => el.trackId
|
|
9756
|
+
);
|
|
9757
|
+
const engineIds = engine.getState().tracks.map((t) => t.id);
|
|
9758
|
+
const target = [...engineIds].sort((a, b) => {
|
|
9759
|
+
const ai = domOrder.indexOf(a);
|
|
9760
|
+
const bi = domOrder.indexOf(b);
|
|
9761
|
+
if (ai === -1 || bi === -1) return 0;
|
|
9762
|
+
return ai - bi;
|
|
9763
|
+
});
|
|
9764
|
+
if (target.every((id, i) => id === engineIds[i])) return;
|
|
9765
|
+
this._inOrderSync = true;
|
|
9766
|
+
try {
|
|
9767
|
+
engine.beginTransaction();
|
|
9768
|
+
const current = [...engineIds];
|
|
9769
|
+
for (let i = 0; i < target.length; i++) {
|
|
9770
|
+
if (current[i] === target[i]) continue;
|
|
9771
|
+
engine.reorderTrack(target[i], i);
|
|
9772
|
+
const from = current.indexOf(target[i]);
|
|
9773
|
+
current.splice(from, 1);
|
|
9774
|
+
current.splice(i, 0, target[i]);
|
|
9775
|
+
}
|
|
9776
|
+
engine.commitTransaction();
|
|
9777
|
+
} finally {
|
|
9778
|
+
this._inOrderSync = false;
|
|
9779
|
+
}
|
|
9780
|
+
this.requestUpdate();
|
|
9781
|
+
}
|
|
9782
|
+
/**
|
|
9783
|
+
* Engine → DOM: after an engine-initiated order change (undo/redo), move
|
|
9784
|
+
* `<daw-track>` elements to match engine order. The resulting mutations fire
|
|
9785
|
+
* the observer's _syncEngineOrderToDom, which finds the orders equal and
|
|
9786
|
+
* no-ops — converges in one pass (write-only-on-change).
|
|
9787
|
+
*/
|
|
9788
|
+
_syncDomToEngineOrder(tracks) {
|
|
9789
|
+
const els = [...this.querySelectorAll("daw-track")];
|
|
9790
|
+
if (els.length < 2) return;
|
|
9791
|
+
const byId = new Map(els.map((el) => [el.trackId, el]));
|
|
9792
|
+
const desired = tracks.map((t) => byId.get(t.id)).filter((el) => el != null);
|
|
9793
|
+
if (desired.length === 0) return;
|
|
9794
|
+
if (desired.every((el, i) => el === els[i])) return;
|
|
9795
|
+
if (els[0] !== desired[0]) els[0].before(desired[0]);
|
|
9796
|
+
for (let i = 1; i < desired.length; i++) {
|
|
9797
|
+
if (desired[i - 1].nextElementSibling !== desired[i]) desired[i - 1].after(desired[i]);
|
|
9798
|
+
}
|
|
9799
|
+
}
|
|
8272
9800
|
_getOrderedTracks() {
|
|
8273
9801
|
const domOrder = [...this.querySelectorAll("daw-track")].map(
|
|
8274
9802
|
(el) => el.trackId
|
|
@@ -8312,9 +9840,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8312
9840
|
});
|
|
8313
9841
|
const showControls = this._showControls;
|
|
8314
9842
|
const showRuler = this._showRuler;
|
|
8315
|
-
return
|
|
8316
|
-
${showRuler ?
|
|
8317
|
-
${showControls ?
|
|
9843
|
+
return import_lit19.html`
|
|
9844
|
+
${showRuler ? import_lit19.html`<div class="header-row" style="height: ${RULER_HEIGHT}px;">
|
|
9845
|
+
${showControls ? import_lit19.html`<div class="ruler-gap"></div>` : ""}
|
|
8318
9846
|
<div class="ruler-viewport" @pointerdown=${this._pointer.onPointerDown}>
|
|
8319
9847
|
<div
|
|
8320
9848
|
class="ruler-content"
|
|
@@ -8335,10 +9863,18 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8335
9863
|
</div>
|
|
8336
9864
|
</div>` : ""}
|
|
8337
9865
|
<div class="body">
|
|
8338
|
-
${showControls ?
|
|
9866
|
+
${showControls ? import_lit19.html`<div class="controls-viewport">
|
|
8339
9867
|
<div class="controls-column">
|
|
9868
|
+
${this._annotations.tracks.map(
|
|
9869
|
+
(track) => import_lit19.html`<div
|
|
9870
|
+
class="annotation-lane-spacer"
|
|
9871
|
+
style="height: ${ANNOTATION_LANE_HEIGHT}px;"
|
|
9872
|
+
>
|
|
9873
|
+
<span class="annotation-lane-name">${track.name}</span>
|
|
9874
|
+
</div>`
|
|
9875
|
+
)}
|
|
8340
9876
|
${orderedTracks.map(
|
|
8341
|
-
(t) =>
|
|
9877
|
+
(t, i) => import_lit19.html`
|
|
8342
9878
|
<daw-track-controls
|
|
8343
9879
|
style="height: ${t.trackHeight}px;"
|
|
8344
9880
|
.trackId=${t.trackId}
|
|
@@ -8347,6 +9883,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8347
9883
|
.pan=${t.descriptor?.pan ?? 0}
|
|
8348
9884
|
.muted=${t.descriptor?.muted ?? false}
|
|
8349
9885
|
.soloed=${t.descriptor?.soloed ?? false}
|
|
9886
|
+
.reorderable=${this.trackReordering}
|
|
9887
|
+
.trackIndex=${i}
|
|
9888
|
+
.trackCount=${orderedTracks.length}
|
|
8350
9889
|
></daw-track-controls>
|
|
8351
9890
|
`
|
|
8352
9891
|
)}
|
|
@@ -8362,8 +9901,14 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8362
9901
|
@dragleave=${this._onDragLeave}
|
|
8363
9902
|
@drop=${this._onDrop}
|
|
8364
9903
|
>
|
|
8365
|
-
${this.
|
|
8366
|
-
|
|
9904
|
+
${this._annotations.renderLanes(
|
|
9905
|
+
spp,
|
|
9906
|
+
this.effectiveSampleRate,
|
|
9907
|
+
this._annotationDrag.onPointerDown,
|
|
9908
|
+
this.scaleMode === "beats" ? this.ticksPerPixel : null
|
|
9909
|
+
)}
|
|
9910
|
+
${this.scaleMode === "beats" ? import_lit19.html`<daw-grid
|
|
9911
|
+
style="top: ${this._annotations.totalLaneHeight}px;"
|
|
8367
9912
|
.ticksPerPixel=${this.ticksPerPixel}
|
|
8368
9913
|
.meterEntries=${this._meterEntries}
|
|
8369
9914
|
.ppqn=${this.ppqn}
|
|
@@ -8372,11 +9917,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8372
9917
|
.length=${this._totalWidth}
|
|
8373
9918
|
.height=${orderedTracks.length > 0 ? orderedTracks.reduce((sum, t) => sum + t.trackHeight, 0) : this._emptyGridHeight}
|
|
8374
9919
|
></daw-grid>` : ""}
|
|
8375
|
-
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ?
|
|
9920
|
+
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ? import_lit19.html`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
8376
9921
|
<daw-playhead></daw-playhead>` : ""}
|
|
8377
9922
|
${orderedTracks.map((t) => {
|
|
8378
9923
|
const channelHeight = this.waveHeight;
|
|
8379
|
-
return
|
|
9924
|
+
return import_lit19.html`
|
|
8380
9925
|
<div
|
|
8381
9926
|
class="track-row ${t.trackId === this._selectedTrackId ? "selected" : ""}"
|
|
8382
9927
|
style="height: ${t.trackHeight}px;"
|
|
@@ -8395,7 +9940,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8395
9940
|
width = Math.round(endTick / this.ticksPerPixel) - clipLeft;
|
|
8396
9941
|
} else {
|
|
8397
9942
|
clipLeft = Math.floor(clip.startSample / spp);
|
|
8398
|
-
width = (0,
|
|
9943
|
+
width = (0, import_core12.clipPixelWidth)(clip.startSample, clip.durationSamples, spp);
|
|
8399
9944
|
}
|
|
8400
9945
|
let clipSegments;
|
|
8401
9946
|
let segmentChannels;
|
|
@@ -8442,12 +9987,12 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8442
9987
|
const channels = segmentChannels ?? peakData?.data ?? [new Int16Array(0)];
|
|
8443
9988
|
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
8444
9989
|
const chH = this.waveHeight;
|
|
8445
|
-
return
|
|
9990
|
+
return import_lit19.html` <div
|
|
8446
9991
|
class="clip-container"
|
|
8447
9992
|
style="left:${clipLeft}px;top:0;width:${width}px;height:${t.trackHeight}px;"
|
|
8448
9993
|
data-clip-id=${clip.id}
|
|
8449
9994
|
>
|
|
8450
|
-
${hdrH > 0 ?
|
|
9995
|
+
${hdrH > 0 ? import_lit19.html`<div
|
|
8451
9996
|
class="clip-header"
|
|
8452
9997
|
data-clip-id=${clip.id}
|
|
8453
9998
|
data-track-id=${t.trackId}
|
|
@@ -8455,7 +10000,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8455
10000
|
>
|
|
8456
10001
|
<span>${clip.name || t.descriptor?.name || ""}</span>
|
|
8457
10002
|
</div>` : ""}
|
|
8458
|
-
${t.descriptor?.renderMode === "piano-roll" ?
|
|
10003
|
+
${t.descriptor?.renderMode === "piano-roll" ? import_lit19.html`<daw-piano-roll
|
|
8459
10004
|
style="position:absolute;left:0;top:${hdrH}px;"
|
|
8460
10005
|
.midiNotes=${clip.midiNotes ?? []}
|
|
8461
10006
|
.length=${peakData?.length ?? width}
|
|
@@ -8468,7 +10013,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8468
10013
|
.originX=${clipLeft}
|
|
8469
10014
|
?selected=${t.trackId === this._selectedTrackId}
|
|
8470
10015
|
></daw-piano-roll>` : t.descriptor?.renderMode === "spectrogram" ? channels.map(
|
|
8471
|
-
(_chPeaks, chIdx) =>
|
|
10016
|
+
(_chPeaks, chIdx) => import_lit19.html`<daw-spectrogram
|
|
8472
10017
|
style="position:absolute;left:0;top:${hdrH + chIdx * chH}px;height:${chH}px;width:${peakData?.length ?? width}px;"
|
|
8473
10018
|
.clipId=${clip.id}
|
|
8474
10019
|
.trackId=${t.trackId}
|
|
@@ -8483,7 +10028,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8483
10028
|
.originX=${clipLeft}
|
|
8484
10029
|
></daw-spectrogram>`
|
|
8485
10030
|
) : channels.map(
|
|
8486
|
-
(chPeaks, chIdx) =>
|
|
10031
|
+
(chPeaks, chIdx) => import_lit19.html` <daw-waveform
|
|
8487
10032
|
style="position:absolute;left:0;top:${hdrH + chIdx * chH}px;"
|
|
8488
10033
|
.peaks=${chPeaks}
|
|
8489
10034
|
.length=${peakData?.length ?? width}
|
|
@@ -8497,7 +10042,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8497
10042
|
.segments=${clipSegments}
|
|
8498
10043
|
></daw-waveform>`
|
|
8499
10044
|
)}
|
|
8500
|
-
${this.interactiveClips ?
|
|
10045
|
+
${this.interactiveClips ? import_lit19.html` <div
|
|
8501
10046
|
class="clip-boundary"
|
|
8502
10047
|
data-boundary-edge="left"
|
|
8503
10048
|
data-clip-id=${clip.id}
|
|
@@ -8524,7 +10069,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8524
10069
|
};
|
|
8525
10070
|
DawEditorElement.styles = [
|
|
8526
10071
|
hostStyles,
|
|
8527
|
-
|
|
10072
|
+
import_lit19.css`
|
|
8528
10073
|
:host {
|
|
8529
10074
|
display: flex;
|
|
8530
10075
|
flex-direction: column;
|
|
@@ -8582,6 +10127,9 @@ DawEditorElement.styles = [
|
|
|
8582
10127
|
.track-row.selected {
|
|
8583
10128
|
background: rgba(99, 199, 95, 0.08);
|
|
8584
10129
|
}
|
|
10130
|
+
.track-row[data-track-drag-source] {
|
|
10131
|
+
background: rgba(99, 199, 95, 0.08);
|
|
10132
|
+
}
|
|
8585
10133
|
:host([scale-mode='beats']) .track-row {
|
|
8586
10134
|
background: transparent;
|
|
8587
10135
|
}
|
|
@@ -8595,120 +10143,189 @@ DawEditorElement.styles = [
|
|
|
8595
10143
|
outline: 2px dashed var(--daw-selection-color, rgba(99, 199, 95, 0.3));
|
|
8596
10144
|
outline-offset: -2px;
|
|
8597
10145
|
}
|
|
10146
|
+
.annotation-lane {
|
|
10147
|
+
position: relative;
|
|
10148
|
+
box-sizing: border-box;
|
|
10149
|
+
border-bottom: 1px solid var(--daw-annotation-lane-border, rgba(255, 255, 255, 0.08));
|
|
10150
|
+
background: var(--daw-annotation-lane-background, rgba(0, 0, 0, 0.15));
|
|
10151
|
+
user-select: none;
|
|
10152
|
+
-webkit-user-drag: none;
|
|
10153
|
+
}
|
|
10154
|
+
.annotation-lane-spacer {
|
|
10155
|
+
box-sizing: border-box;
|
|
10156
|
+
border-bottom: 1px solid var(--daw-annotation-lane-border, rgba(255, 255, 255, 0.08));
|
|
10157
|
+
display: flex;
|
|
10158
|
+
align-items: center;
|
|
10159
|
+
overflow: hidden;
|
|
10160
|
+
}
|
|
10161
|
+
.annotation-lane-name {
|
|
10162
|
+
padding: 0 10px;
|
|
10163
|
+
font-size: 11px;
|
|
10164
|
+
color: var(--daw-controls-text, #e0d4c8);
|
|
10165
|
+
opacity: 0.8;
|
|
10166
|
+
white-space: nowrap;
|
|
10167
|
+
overflow: hidden;
|
|
10168
|
+
text-overflow: ellipsis;
|
|
10169
|
+
}
|
|
10170
|
+
.annotation-box {
|
|
10171
|
+
position: absolute;
|
|
10172
|
+
top: 3px;
|
|
10173
|
+
bottom: 3px;
|
|
10174
|
+
overflow: hidden;
|
|
10175
|
+
display: flex;
|
|
10176
|
+
align-items: center;
|
|
10177
|
+
border: 1px solid var(--daw-annotation-box-border, #c49a6c);
|
|
10178
|
+
border-radius: 3px;
|
|
10179
|
+
background: var(--daw-annotation-box-background, rgba(196, 154, 108, 0.2));
|
|
10180
|
+
color: var(--daw-annotation-text-color, #e0d4c8);
|
|
10181
|
+
font-size: 11px;
|
|
10182
|
+
cursor: pointer;
|
|
10183
|
+
}
|
|
10184
|
+
.annotation-box.playing {
|
|
10185
|
+
box-shadow: inset 0 0 0 1px var(--daw-annotation-box-border, #c49a6c);
|
|
10186
|
+
background: var(--daw-annotation-playing-background, rgba(196, 154, 108, 0.32));
|
|
10187
|
+
}
|
|
10188
|
+
.annotation-box.active {
|
|
10189
|
+
background: var(--daw-annotation-active-background, rgba(196, 154, 108, 0.45));
|
|
10190
|
+
}
|
|
10191
|
+
.annotation-box-text {
|
|
10192
|
+
padding: 0 6px;
|
|
10193
|
+
white-space: nowrap;
|
|
10194
|
+
overflow: hidden;
|
|
10195
|
+
text-overflow: ellipsis;
|
|
10196
|
+
pointer-events: none;
|
|
10197
|
+
}
|
|
10198
|
+
.annotation-boundary {
|
|
10199
|
+
position: absolute;
|
|
10200
|
+
top: 0;
|
|
10201
|
+
bottom: 0;
|
|
10202
|
+
width: 6px;
|
|
10203
|
+
cursor: ew-resize;
|
|
10204
|
+
flex-shrink: 0;
|
|
10205
|
+
}
|
|
10206
|
+
.annotation-boundary[data-edge='start'] {
|
|
10207
|
+
left: 0;
|
|
10208
|
+
}
|
|
10209
|
+
.annotation-boundary[data-edge='end'] {
|
|
10210
|
+
right: 0;
|
|
10211
|
+
}
|
|
8598
10212
|
`,
|
|
8599
10213
|
clipStyles
|
|
8600
10214
|
];
|
|
8601
10215
|
DawEditorElement._CONTROL_PROPS = /* @__PURE__ */ new Set(["volume", "pan", "muted", "soloed"]);
|
|
8602
10216
|
__decorateClass([
|
|
8603
|
-
(0,
|
|
10217
|
+
(0, import_decorators16.property)({ type: Number, attribute: "samples-per-pixel", noAccessor: true })
|
|
8604
10218
|
], DawEditorElement.prototype, "samplesPerPixel", 1);
|
|
8605
10219
|
__decorateClass([
|
|
8606
|
-
(0,
|
|
10220
|
+
(0, import_decorators16.property)({ attribute: "time-format", reflect: true, noAccessor: true })
|
|
8607
10221
|
], DawEditorElement.prototype, "timeFormat", 1);
|
|
8608
10222
|
__decorateClass([
|
|
8609
|
-
(0,
|
|
10223
|
+
(0, import_decorators16.property)({ type: Number, attribute: "wave-height" })
|
|
8610
10224
|
], DawEditorElement.prototype, "waveHeight", 2);
|
|
8611
10225
|
__decorateClass([
|
|
8612
|
-
(0,
|
|
10226
|
+
(0, import_decorators16.property)({ type: Boolean })
|
|
8613
10227
|
], DawEditorElement.prototype, "timescale", 2);
|
|
8614
10228
|
__decorateClass([
|
|
8615
|
-
(0,
|
|
10229
|
+
(0, import_decorators16.property)({ type: Boolean })
|
|
8616
10230
|
], DawEditorElement.prototype, "mono", 2);
|
|
8617
10231
|
__decorateClass([
|
|
8618
|
-
(0,
|
|
10232
|
+
(0, import_decorators16.property)({ type: Number, attribute: "bar-width" })
|
|
8619
10233
|
], DawEditorElement.prototype, "barWidth", 2);
|
|
8620
10234
|
__decorateClass([
|
|
8621
|
-
(0,
|
|
10235
|
+
(0, import_decorators16.property)({ type: Number, attribute: "bar-gap" })
|
|
8622
10236
|
], DawEditorElement.prototype, "barGap", 2);
|
|
8623
10237
|
__decorateClass([
|
|
8624
|
-
(0,
|
|
10238
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
8625
10239
|
], DawEditorElement.prototype, "roundedBars", 2);
|
|
8626
10240
|
__decorateClass([
|
|
8627
|
-
(0,
|
|
10241
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "file-drop" })
|
|
8628
10242
|
], DawEditorElement.prototype, "fileDrop", 2);
|
|
8629
10243
|
__decorateClass([
|
|
8630
|
-
(0,
|
|
10244
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "clip-headers" })
|
|
8631
10245
|
], DawEditorElement.prototype, "clipHeaders", 2);
|
|
8632
10246
|
__decorateClass([
|
|
8633
|
-
(0,
|
|
10247
|
+
(0, import_decorators16.property)({ type: Number, attribute: "clip-header-height" })
|
|
8634
10248
|
], DawEditorElement.prototype, "clipHeaderHeight", 2);
|
|
8635
10249
|
__decorateClass([
|
|
8636
|
-
(0,
|
|
10250
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "interactive-clips" })
|
|
8637
10251
|
], DawEditorElement.prototype, "interactiveClips", 2);
|
|
8638
10252
|
__decorateClass([
|
|
8639
|
-
(0,
|
|
10253
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "indefinite-playback" })
|
|
8640
10254
|
], DawEditorElement.prototype, "indefinitePlayback", 2);
|
|
8641
10255
|
__decorateClass([
|
|
8642
|
-
(0,
|
|
10256
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "fill-viewport" })
|
|
8643
10257
|
], DawEditorElement.prototype, "fillViewport", 2);
|
|
8644
10258
|
__decorateClass([
|
|
8645
|
-
(0,
|
|
10259
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "track-reordering" })
|
|
10260
|
+
], DawEditorElement.prototype, "trackReordering", 2);
|
|
10261
|
+
__decorateClass([
|
|
10262
|
+
(0, import_decorators16.property)({ attribute: false, noAccessor: true })
|
|
8646
10263
|
], DawEditorElement.prototype, "spectrogramConfig", 1);
|
|
8647
10264
|
__decorateClass([
|
|
8648
|
-
(0,
|
|
10265
|
+
(0, import_decorators16.property)({ attribute: false, noAccessor: true })
|
|
8649
10266
|
], DawEditorElement.prototype, "spectrogramColorMap", 1);
|
|
8650
10267
|
__decorateClass([
|
|
8651
|
-
(0,
|
|
10268
|
+
(0, import_decorators16.property)({ type: String, attribute: "scale-mode" })
|
|
8652
10269
|
], DawEditorElement.prototype, "scaleMode", 2);
|
|
8653
10270
|
__decorateClass([
|
|
8654
|
-
(0,
|
|
10271
|
+
(0, import_decorators16.property)({ type: Number, attribute: "ticks-per-pixel", noAccessor: true })
|
|
8655
10272
|
], DawEditorElement.prototype, "ticksPerPixel", 1);
|
|
8656
10273
|
__decorateClass([
|
|
8657
|
-
(0,
|
|
10274
|
+
(0, import_decorators16.property)({ type: Number, noAccessor: true })
|
|
8658
10275
|
], DawEditorElement.prototype, "bpm", 1);
|
|
8659
10276
|
__decorateClass([
|
|
8660
|
-
(0,
|
|
10277
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8661
10278
|
], DawEditorElement.prototype, "timeSignature", 2);
|
|
8662
10279
|
__decorateClass([
|
|
8663
|
-
(0,
|
|
10280
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8664
10281
|
], DawEditorElement.prototype, "meterEntries", 2);
|
|
8665
10282
|
__decorateClass([
|
|
8666
|
-
(0,
|
|
10283
|
+
(0, import_decorators16.property)({ type: Number, noAccessor: true })
|
|
8667
10284
|
], DawEditorElement.prototype, "ppqn", 1);
|
|
8668
10285
|
__decorateClass([
|
|
8669
|
-
(0,
|
|
10286
|
+
(0, import_decorators16.property)({ type: String, attribute: "snap-to" })
|
|
8670
10287
|
], DawEditorElement.prototype, "snapTo", 2);
|
|
8671
10288
|
__decorateClass([
|
|
8672
|
-
(0,
|
|
10289
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8673
10290
|
], DawEditorElement.prototype, "secondsToTicks", 2);
|
|
8674
10291
|
__decorateClass([
|
|
8675
|
-
(0,
|
|
10292
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8676
10293
|
], DawEditorElement.prototype, "ticksToSeconds", 2);
|
|
8677
10294
|
__decorateClass([
|
|
8678
|
-
(0,
|
|
10295
|
+
(0, import_decorators16.state)()
|
|
8679
10296
|
], DawEditorElement.prototype, "_tracks", 2);
|
|
8680
10297
|
__decorateClass([
|
|
8681
|
-
(0,
|
|
10298
|
+
(0, import_decorators16.state)()
|
|
8682
10299
|
], DawEditorElement.prototype, "_engineTracks", 2);
|
|
8683
10300
|
__decorateClass([
|
|
8684
|
-
(0,
|
|
10301
|
+
(0, import_decorators16.state)()
|
|
8685
10302
|
], DawEditorElement.prototype, "_peaksData", 2);
|
|
8686
10303
|
__decorateClass([
|
|
8687
|
-
(0,
|
|
10304
|
+
(0, import_decorators16.state)()
|
|
8688
10305
|
], DawEditorElement.prototype, "_isPlaying", 2);
|
|
8689
10306
|
__decorateClass([
|
|
8690
|
-
(0,
|
|
10307
|
+
(0, import_decorators16.state)()
|
|
8691
10308
|
], DawEditorElement.prototype, "_duration", 2);
|
|
8692
10309
|
__decorateClass([
|
|
8693
|
-
(0,
|
|
10310
|
+
(0, import_decorators16.state)()
|
|
8694
10311
|
], DawEditorElement.prototype, "_selectedTrackId", 2);
|
|
8695
10312
|
__decorateClass([
|
|
8696
|
-
(0,
|
|
10313
|
+
(0, import_decorators16.state)()
|
|
8697
10314
|
], DawEditorElement.prototype, "_dragOver", 2);
|
|
8698
10315
|
__decorateClass([
|
|
8699
|
-
(0,
|
|
10316
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8700
10317
|
], DawEditorElement.prototype, "adapter", 1);
|
|
8701
10318
|
__decorateClass([
|
|
8702
|
-
(0,
|
|
10319
|
+
(0, import_decorators16.property)({ attribute: "eager-resume" })
|
|
8703
10320
|
], DawEditorElement.prototype, "eagerResume", 2);
|
|
8704
10321
|
DawEditorElement = __decorateClass([
|
|
8705
|
-
(0,
|
|
10322
|
+
(0, import_decorators16.customElement)("daw-editor")
|
|
8706
10323
|
], DawEditorElement);
|
|
8707
10324
|
|
|
8708
10325
|
// src/elements/daw-selection.ts
|
|
8709
|
-
var
|
|
8710
|
-
var
|
|
8711
|
-
var DawSelectionElement = class extends
|
|
10326
|
+
var import_lit20 = require("lit");
|
|
10327
|
+
var import_decorators17 = require("lit/decorators.js");
|
|
10328
|
+
var DawSelectionElement = class extends import_lit20.LitElement {
|
|
8712
10329
|
constructor() {
|
|
8713
10330
|
super(...arguments);
|
|
8714
10331
|
this.startPx = 0;
|
|
@@ -8717,11 +10334,11 @@ var DawSelectionElement = class extends import_lit16.LitElement {
|
|
|
8717
10334
|
render() {
|
|
8718
10335
|
const left = Math.min(this.startPx, this.endPx);
|
|
8719
10336
|
const width = Math.abs(this.endPx - this.startPx);
|
|
8720
|
-
if (width === 0) return
|
|
8721
|
-
return
|
|
10337
|
+
if (width === 0) return import_lit20.html``;
|
|
10338
|
+
return import_lit20.html`<div style="left: ${left}px; width: ${width}px;"></div>`;
|
|
8722
10339
|
}
|
|
8723
10340
|
};
|
|
8724
|
-
DawSelectionElement.styles =
|
|
10341
|
+
DawSelectionElement.styles = import_lit20.css`
|
|
8725
10342
|
:host {
|
|
8726
10343
|
position: absolute;
|
|
8727
10344
|
top: 0;
|
|
@@ -8738,18 +10355,18 @@ DawSelectionElement.styles = import_lit16.css`
|
|
|
8738
10355
|
}
|
|
8739
10356
|
`;
|
|
8740
10357
|
__decorateClass([
|
|
8741
|
-
(0,
|
|
10358
|
+
(0, import_decorators17.property)({ type: Number, attribute: false })
|
|
8742
10359
|
], DawSelectionElement.prototype, "startPx", 2);
|
|
8743
10360
|
__decorateClass([
|
|
8744
|
-
(0,
|
|
10361
|
+
(0, import_decorators17.property)({ type: Number, attribute: false })
|
|
8745
10362
|
], DawSelectionElement.prototype, "endPx", 2);
|
|
8746
10363
|
DawSelectionElement = __decorateClass([
|
|
8747
|
-
(0,
|
|
10364
|
+
(0, import_decorators17.customElement)("daw-selection")
|
|
8748
10365
|
], DawSelectionElement);
|
|
8749
10366
|
|
|
8750
10367
|
// src/elements/daw-record-button.ts
|
|
8751
|
-
var
|
|
8752
|
-
var
|
|
10368
|
+
var import_lit21 = require("lit");
|
|
10369
|
+
var import_decorators18 = require("lit/decorators.js");
|
|
8753
10370
|
var DawRecordButtonElement = class extends DawTransportButton {
|
|
8754
10371
|
constructor() {
|
|
8755
10372
|
super(...arguments);
|
|
@@ -8798,7 +10415,7 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8798
10415
|
}
|
|
8799
10416
|
}
|
|
8800
10417
|
render() {
|
|
8801
|
-
return
|
|
10418
|
+
return import_lit21.html`
|
|
8802
10419
|
<button
|
|
8803
10420
|
part="button"
|
|
8804
10421
|
?disabled=${!this.targetSupported}
|
|
@@ -8826,7 +10443,7 @@ DawRecordButtonElement.requiredTargetMethods = [
|
|
|
8826
10443
|
];
|
|
8827
10444
|
DawRecordButtonElement.styles = [
|
|
8828
10445
|
DawTransportButton.styles,
|
|
8829
|
-
|
|
10446
|
+
import_lit21.css`
|
|
8830
10447
|
button[data-recording] {
|
|
8831
10448
|
color: #d08070;
|
|
8832
10449
|
border-color: #d08070;
|
|
@@ -8835,17 +10452,17 @@ DawRecordButtonElement.styles = [
|
|
|
8835
10452
|
`
|
|
8836
10453
|
];
|
|
8837
10454
|
__decorateClass([
|
|
8838
|
-
(0,
|
|
10455
|
+
(0, import_decorators18.state)()
|
|
8839
10456
|
], DawRecordButtonElement.prototype, "_isRecording", 2);
|
|
8840
10457
|
DawRecordButtonElement = __decorateClass([
|
|
8841
|
-
(0,
|
|
10458
|
+
(0, import_decorators18.customElement)("daw-record-button")
|
|
8842
10459
|
], DawRecordButtonElement);
|
|
8843
10460
|
|
|
8844
10461
|
// src/elements/daw-keyboard-shortcuts.ts
|
|
8845
|
-
var
|
|
8846
|
-
var
|
|
8847
|
-
var
|
|
8848
|
-
var DawKeyboardShortcutsElement = class extends
|
|
10462
|
+
var import_lit22 = require("lit");
|
|
10463
|
+
var import_decorators19 = require("lit/decorators.js");
|
|
10464
|
+
var import_core13 = require("@waveform-playlist/core");
|
|
10465
|
+
var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
8849
10466
|
constructor() {
|
|
8850
10467
|
super(...arguments);
|
|
8851
10468
|
this.playback = false;
|
|
@@ -8869,7 +10486,7 @@ var DawKeyboardShortcutsElement = class extends import_lit18.LitElement {
|
|
|
8869
10486
|
const shortcuts = this.shortcuts;
|
|
8870
10487
|
if (shortcuts.length === 0) return;
|
|
8871
10488
|
try {
|
|
8872
|
-
(0,
|
|
10489
|
+
(0, import_core13.handleKeyboardEvent)(e, shortcuts, true);
|
|
8873
10490
|
} catch (err) {
|
|
8874
10491
|
console.warn("[dawcore] Keyboard shortcut failed (key=" + e.key + "): " + String(err));
|
|
8875
10492
|
const target = this._editor ?? this;
|
|
@@ -9044,23 +10661,23 @@ var DawKeyboardShortcutsElement = class extends import_lit18.LitElement {
|
|
|
9044
10661
|
}
|
|
9045
10662
|
};
|
|
9046
10663
|
__decorateClass([
|
|
9047
|
-
(0,
|
|
10664
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9048
10665
|
], DawKeyboardShortcutsElement.prototype, "playback", 2);
|
|
9049
10666
|
__decorateClass([
|
|
9050
|
-
(0,
|
|
10667
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9051
10668
|
], DawKeyboardShortcutsElement.prototype, "splitting", 2);
|
|
9052
10669
|
__decorateClass([
|
|
9053
|
-
(0,
|
|
10670
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9054
10671
|
], DawKeyboardShortcutsElement.prototype, "undo", 2);
|
|
9055
10672
|
DawKeyboardShortcutsElement = __decorateClass([
|
|
9056
|
-
(0,
|
|
10673
|
+
(0, import_decorators19.customElement)("daw-keyboard-shortcuts")
|
|
9057
10674
|
], DawKeyboardShortcutsElement);
|
|
9058
10675
|
|
|
9059
10676
|
// src/elements/daw-spectrogram.ts
|
|
9060
|
-
var
|
|
9061
|
-
var
|
|
9062
|
-
var
|
|
9063
|
-
var DawSpectrogramElement = class extends
|
|
10677
|
+
var import_lit23 = require("lit");
|
|
10678
|
+
var import_decorators20 = require("lit/decorators.js");
|
|
10679
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
10680
|
+
var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
9064
10681
|
constructor() {
|
|
9065
10682
|
super(...arguments);
|
|
9066
10683
|
this.clipId = "";
|
|
@@ -9124,11 +10741,11 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9124
10741
|
this._unregisterAllCanvases();
|
|
9125
10742
|
this._canvases = [];
|
|
9126
10743
|
if (this.length <= 0) return;
|
|
9127
|
-
const chunkCount = Math.ceil(this.length /
|
|
10744
|
+
const chunkCount = Math.ceil(this.length / import_core14.MAX_CANVAS_WIDTH);
|
|
9128
10745
|
for (let i = 0; i < chunkCount; i++) {
|
|
9129
|
-
const widthPx = Math.min(
|
|
10746
|
+
const widthPx = Math.min(import_core14.MAX_CANVAS_WIDTH, this.length - i * import_core14.MAX_CANVAS_WIDTH);
|
|
9130
10747
|
const canvas = document.createElement("canvas");
|
|
9131
|
-
canvas.style.left = i *
|
|
10748
|
+
canvas.style.left = i * import_core14.MAX_CANVAS_WIDTH + "px";
|
|
9132
10749
|
canvas.style.width = widthPx + "px";
|
|
9133
10750
|
const dpr = window.devicePixelRatio || 1;
|
|
9134
10751
|
canvas.width = widthPx * dpr;
|
|
@@ -9154,7 +10771,7 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9154
10771
|
}
|
|
9155
10772
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
9156
10773
|
const canvas = this._canvases[i];
|
|
9157
|
-
const canvasId = (0,
|
|
10774
|
+
const canvasId = (0, import_core14.buildSpectrogramCanvasId)({
|
|
9158
10775
|
clipId: this.clipId,
|
|
9159
10776
|
channelIndex: this.channelIndex,
|
|
9160
10777
|
chunkIndex: i
|
|
@@ -9175,7 +10792,7 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9175
10792
|
trackId: this.trackId,
|
|
9176
10793
|
channelIndex: this.channelIndex,
|
|
9177
10794
|
chunkIndex: i,
|
|
9178
|
-
globalPixelOffset: this.originX + i *
|
|
10795
|
+
globalPixelOffset: this.originX + i * import_core14.MAX_CANVAS_WIDTH,
|
|
9179
10796
|
widthPx: parseFloat(canvas.style.width),
|
|
9180
10797
|
heightPx: this.waveHeight
|
|
9181
10798
|
});
|
|
@@ -9196,10 +10813,10 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9196
10813
|
this._unregisterAllCanvases();
|
|
9197
10814
|
}
|
|
9198
10815
|
render() {
|
|
9199
|
-
return
|
|
10816
|
+
return import_lit23.html`${this._canvases.map((c) => c)}`;
|
|
9200
10817
|
}
|
|
9201
10818
|
};
|
|
9202
|
-
DawSpectrogramElement.styles =
|
|
10819
|
+
DawSpectrogramElement.styles = import_lit23.css`
|
|
9203
10820
|
:host {
|
|
9204
10821
|
display: block;
|
|
9205
10822
|
position: relative;
|
|
@@ -9214,46 +10831,46 @@ DawSpectrogramElement.styles = import_lit19.css`
|
|
|
9214
10831
|
}
|
|
9215
10832
|
`;
|
|
9216
10833
|
__decorateClass([
|
|
9217
|
-
(0,
|
|
10834
|
+
(0, import_decorators20.property)({ attribute: false })
|
|
9218
10835
|
], DawSpectrogramElement.prototype, "clipId", 2);
|
|
9219
10836
|
__decorateClass([
|
|
9220
|
-
(0,
|
|
10837
|
+
(0, import_decorators20.property)({ attribute: false })
|
|
9221
10838
|
], DawSpectrogramElement.prototype, "trackId", 2);
|
|
9222
10839
|
__decorateClass([
|
|
9223
|
-
(0,
|
|
10840
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9224
10841
|
], DawSpectrogramElement.prototype, "channelIndex", 2);
|
|
9225
10842
|
__decorateClass([
|
|
9226
|
-
(0,
|
|
10843
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9227
10844
|
], DawSpectrogramElement.prototype, "length", 2);
|
|
9228
10845
|
__decorateClass([
|
|
9229
|
-
(0,
|
|
10846
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9230
10847
|
], DawSpectrogramElement.prototype, "waveHeight", 2);
|
|
9231
10848
|
__decorateClass([
|
|
9232
|
-
(0,
|
|
10849
|
+
(0, import_decorators20.property)({ type: Number, attribute: false, noAccessor: true })
|
|
9233
10850
|
], DawSpectrogramElement.prototype, "samplesPerPixel", 1);
|
|
9234
10851
|
__decorateClass([
|
|
9235
|
-
(0,
|
|
10852
|
+
(0, import_decorators20.property)({ type: Number, attribute: false, noAccessor: true })
|
|
9236
10853
|
], DawSpectrogramElement.prototype, "sampleRate", 1);
|
|
9237
10854
|
__decorateClass([
|
|
9238
|
-
(0,
|
|
10855
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9239
10856
|
], DawSpectrogramElement.prototype, "clipOffsetSeconds", 2);
|
|
9240
10857
|
__decorateClass([
|
|
9241
|
-
(0,
|
|
10858
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9242
10859
|
], DawSpectrogramElement.prototype, "visibleStart", 2);
|
|
9243
10860
|
__decorateClass([
|
|
9244
|
-
(0,
|
|
10861
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9245
10862
|
], DawSpectrogramElement.prototype, "visibleEnd", 2);
|
|
9246
10863
|
__decorateClass([
|
|
9247
|
-
(0,
|
|
10864
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9248
10865
|
], DawSpectrogramElement.prototype, "originX", 2);
|
|
9249
10866
|
DawSpectrogramElement = __decorateClass([
|
|
9250
|
-
(0,
|
|
10867
|
+
(0, import_decorators20.customElement)("daw-spectrogram")
|
|
9251
10868
|
], DawSpectrogramElement);
|
|
9252
10869
|
|
|
9253
10870
|
// src/elements/daw-time-display.ts
|
|
9254
|
-
var
|
|
9255
|
-
var
|
|
9256
|
-
var DawTimeDisplayElement = class extends
|
|
10871
|
+
var import_lit24 = require("lit");
|
|
10872
|
+
var import_decorators21 = require("lit/decorators.js");
|
|
10873
|
+
var DawTimeDisplayElement = class extends import_lit24.LitElement {
|
|
9257
10874
|
constructor() {
|
|
9258
10875
|
super(...arguments);
|
|
9259
10876
|
this._time = null;
|
|
@@ -9306,10 +10923,10 @@ var DawTimeDisplayElement = class extends import_lit20.LitElement {
|
|
|
9306
10923
|
}
|
|
9307
10924
|
render() {
|
|
9308
10925
|
const text = this._time === null ? "--:--:--" : formatDisplayTime(this._time, this._format);
|
|
9309
|
-
return
|
|
10926
|
+
return import_lit24.html`<span role="status" aria-label="Playback time" aria-live="off">${text}</span>`;
|
|
9310
10927
|
}
|
|
9311
10928
|
};
|
|
9312
|
-
DawTimeDisplayElement.styles =
|
|
10929
|
+
DawTimeDisplayElement.styles = import_lit24.css`
|
|
9313
10930
|
span {
|
|
9314
10931
|
display: inline-block;
|
|
9315
10932
|
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
@@ -9321,19 +10938,19 @@ DawTimeDisplayElement.styles = import_lit20.css`
|
|
|
9321
10938
|
}
|
|
9322
10939
|
`;
|
|
9323
10940
|
__decorateClass([
|
|
9324
|
-
(0,
|
|
10941
|
+
(0, import_decorators21.state)()
|
|
9325
10942
|
], DawTimeDisplayElement.prototype, "_time", 2);
|
|
9326
10943
|
__decorateClass([
|
|
9327
|
-
(0,
|
|
10944
|
+
(0, import_decorators21.state)()
|
|
9328
10945
|
], DawTimeDisplayElement.prototype, "_format", 2);
|
|
9329
10946
|
DawTimeDisplayElement = __decorateClass([
|
|
9330
|
-
(0,
|
|
10947
|
+
(0, import_decorators21.customElement)("daw-time-display")
|
|
9331
10948
|
], DawTimeDisplayElement);
|
|
9332
10949
|
|
|
9333
10950
|
// src/elements/daw-time-format.ts
|
|
9334
|
-
var
|
|
9335
|
-
var
|
|
9336
|
-
var DawTimeFormatElement = class extends
|
|
10951
|
+
var import_lit25 = require("lit");
|
|
10952
|
+
var import_decorators22 = require("lit/decorators.js");
|
|
10953
|
+
var DawTimeFormatElement = class extends import_lit25.LitElement {
|
|
9337
10954
|
constructor() {
|
|
9338
10955
|
super(...arguments);
|
|
9339
10956
|
this._format = "hh:mm:ss.sss";
|
|
@@ -9408,20 +11025,20 @@ var DawTimeFormatElement = class extends import_lit21.LitElement {
|
|
|
9408
11025
|
target.setTimeFormat?.(value);
|
|
9409
11026
|
}
|
|
9410
11027
|
render() {
|
|
9411
|
-
return
|
|
11028
|
+
return import_lit25.html`
|
|
9412
11029
|
<select
|
|
9413
11030
|
aria-label="Time format"
|
|
9414
11031
|
?disabled=${!this._targetSupported}
|
|
9415
11032
|
@change=${this._onSelectChange}
|
|
9416
11033
|
>
|
|
9417
11034
|
${TIME_DISPLAY_FORMATS.map(
|
|
9418
|
-
(f) =>
|
|
11035
|
+
(f) => import_lit25.html`<option value=${f} ?selected=${f === this._format}>${f}</option>`
|
|
9419
11036
|
)}
|
|
9420
11037
|
</select>
|
|
9421
11038
|
`;
|
|
9422
11039
|
}
|
|
9423
11040
|
};
|
|
9424
|
-
DawTimeFormatElement.styles =
|
|
11041
|
+
DawTimeFormatElement.styles = import_lit25.css`
|
|
9425
11042
|
select {
|
|
9426
11043
|
cursor: pointer;
|
|
9427
11044
|
background: var(--daw-controls-background, #1a1a2e);
|
|
@@ -9436,20 +11053,20 @@ DawTimeFormatElement.styles = import_lit21.css`
|
|
|
9436
11053
|
}
|
|
9437
11054
|
`;
|
|
9438
11055
|
__decorateClass([
|
|
9439
|
-
(0,
|
|
11056
|
+
(0, import_decorators22.state)()
|
|
9440
11057
|
], DawTimeFormatElement.prototype, "_format", 2);
|
|
9441
11058
|
DawTimeFormatElement = __decorateClass([
|
|
9442
|
-
(0,
|
|
11059
|
+
(0, import_decorators22.customElement)("daw-time-format")
|
|
9443
11060
|
], DawTimeFormatElement);
|
|
9444
11061
|
|
|
9445
11062
|
// src/elements/daw-player.ts
|
|
9446
|
-
var
|
|
9447
|
-
var
|
|
11063
|
+
var import_lit26 = require("lit");
|
|
11064
|
+
var import_decorators23 = require("lit/decorators.js");
|
|
9448
11065
|
var import_repeat = require("lit/directives/repeat.js");
|
|
9449
11066
|
var import_media_element_playout = require("@waveform-playlist/media-element-playout");
|
|
9450
11067
|
var MIN_RATE = 0.25;
|
|
9451
11068
|
var MAX_RATE = 4;
|
|
9452
|
-
var DawPlayerElement = class extends
|
|
11069
|
+
var DawPlayerElement = class extends import_lit26.LitElement {
|
|
9453
11070
|
constructor() {
|
|
9454
11071
|
super(...arguments);
|
|
9455
11072
|
this.src = "";
|
|
@@ -9557,8 +11174,8 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9557
11174
|
const width = this._timelineWidth;
|
|
9558
11175
|
const channels = this._channelPeaks.length;
|
|
9559
11176
|
const channelHeight = channels > 0 ? this.waveHeight / channels : this.waveHeight;
|
|
9560
|
-
return
|
|
9561
|
-
${this.timescale ?
|
|
11177
|
+
return import_lit26.html`
|
|
11178
|
+
${this.timescale ? import_lit26.html`<daw-ruler
|
|
9562
11179
|
.samplesPerPixel=${this._channelSpp(width)}
|
|
9563
11180
|
.sampleRate=${this._sampleRate}
|
|
9564
11181
|
.duration=${this._engine.duration}
|
|
@@ -9572,7 +11189,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9572
11189
|
${(0, import_repeat.repeat)(
|
|
9573
11190
|
this._channelPeaks,
|
|
9574
11191
|
(_p, i) => i,
|
|
9575
|
-
(peaks) =>
|
|
11192
|
+
(peaks) => import_lit26.html`<daw-waveform
|
|
9576
11193
|
.peaks=${peaks}
|
|
9577
11194
|
.length=${width}
|
|
9578
11195
|
.waveHeight=${channelHeight}
|
|
@@ -9735,7 +11352,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9735
11352
|
return this.shadowRoot?.querySelector(".waveform-area")?.clientWidth ?? 0;
|
|
9736
11353
|
}
|
|
9737
11354
|
};
|
|
9738
|
-
DawPlayerElement.styles =
|
|
11355
|
+
DawPlayerElement.styles = import_lit26.css`
|
|
9739
11356
|
:host {
|
|
9740
11357
|
display: block;
|
|
9741
11358
|
position: relative;
|
|
@@ -9748,42 +11365,46 @@ DawPlayerElement.styles = import_lit22.css`
|
|
|
9748
11365
|
}
|
|
9749
11366
|
`;
|
|
9750
11367
|
__decorateClass([
|
|
9751
|
-
(0,
|
|
11368
|
+
(0, import_decorators23.property)({ type: String })
|
|
9752
11369
|
], DawPlayerElement.prototype, "src", 2);
|
|
9753
11370
|
__decorateClass([
|
|
9754
|
-
(0,
|
|
11371
|
+
(0, import_decorators23.property)({ type: String, attribute: "peaks-src" })
|
|
9755
11372
|
], DawPlayerElement.prototype, "peaksSrc", 2);
|
|
9756
11373
|
__decorateClass([
|
|
9757
|
-
(0,
|
|
11374
|
+
(0, import_decorators23.property)({ type: Number, attribute: "wave-height" })
|
|
9758
11375
|
], DawPlayerElement.prototype, "waveHeight", 2);
|
|
9759
11376
|
__decorateClass([
|
|
9760
|
-
(0,
|
|
11377
|
+
(0, import_decorators23.property)({ type: Boolean })
|
|
9761
11378
|
], DawPlayerElement.prototype, "timescale", 2);
|
|
9762
11379
|
__decorateClass([
|
|
9763
|
-
(0,
|
|
11380
|
+
(0, import_decorators23.property)({ type: Boolean })
|
|
9764
11381
|
], DawPlayerElement.prototype, "mono", 2);
|
|
9765
11382
|
__decorateClass([
|
|
9766
|
-
(0,
|
|
11383
|
+
(0, import_decorators23.property)({ type: Number, attribute: "bar-width" })
|
|
9767
11384
|
], DawPlayerElement.prototype, "barWidth", 2);
|
|
9768
11385
|
__decorateClass([
|
|
9769
|
-
(0,
|
|
11386
|
+
(0, import_decorators23.property)({ type: Number, attribute: "bar-gap" })
|
|
9770
11387
|
], DawPlayerElement.prototype, "barGap", 2);
|
|
9771
11388
|
__decorateClass([
|
|
9772
|
-
(0,
|
|
11389
|
+
(0, import_decorators23.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
9773
11390
|
], DawPlayerElement.prototype, "roundedBars", 2);
|
|
9774
11391
|
__decorateClass([
|
|
9775
|
-
(0,
|
|
11392
|
+
(0, import_decorators23.property)({ type: Number, attribute: "playback-rate", noAccessor: true })
|
|
9776
11393
|
], DawPlayerElement.prototype, "playbackRate", 1);
|
|
9777
11394
|
__decorateClass([
|
|
9778
|
-
(0,
|
|
11395
|
+
(0, import_decorators23.state)()
|
|
9779
11396
|
], DawPlayerElement.prototype, "_channelPeaks", 2);
|
|
9780
11397
|
DawPlayerElement = __decorateClass([
|
|
9781
|
-
(0,
|
|
11398
|
+
(0, import_decorators23.customElement)("daw-player")
|
|
9782
11399
|
], DawPlayerElement);
|
|
9783
11400
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9784
11401
|
0 && (module.exports = {
|
|
11402
|
+
ANNOTATION_LANE_HEIGHT,
|
|
9785
11403
|
AudioResumeController,
|
|
9786
11404
|
ClipPointerHandler,
|
|
11405
|
+
DawAnnotationElement,
|
|
11406
|
+
DawAnnotationListElement,
|
|
11407
|
+
DawAnnotationTrackElement,
|
|
9787
11408
|
DawClipElement,
|
|
9788
11409
|
DawEditorElement,
|
|
9789
11410
|
DawGridElement,
|