@dawcore/components 0.0.34 → 0.0.35
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 +228 -5
- package/dist/index.d.ts +228 -5
- package/dist/index.js +1617 -324
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1583 -285
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
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_core13 = 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;
|
|
@@ -2227,7 +3038,7 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2227
3038
|
const volPercent = Math.round(this.volume * 100);
|
|
2228
3039
|
const panPercent = Math.round(Math.abs(this.pan) * 100);
|
|
2229
3040
|
const panDisplay = this.pan === 0 ? "C" : (this.pan > 0 ? "R" : "L") + panPercent;
|
|
2230
|
-
return
|
|
3041
|
+
return import_lit15.html`
|
|
2231
3042
|
<div class="header">
|
|
2232
3043
|
<span class="name" title=${this.trackName}>${this.trackName || "Untitled"}</span>
|
|
2233
3044
|
<button class="remove-btn" @click=${this._onRemoveClick} title="Remove track">
|
|
@@ -2277,7 +3088,7 @@ var DawTrackControlsElement = class extends import_lit12.LitElement {
|
|
|
2277
3088
|
`;
|
|
2278
3089
|
}
|
|
2279
3090
|
};
|
|
2280
|
-
DawTrackControlsElement.styles =
|
|
3091
|
+
DawTrackControlsElement.styles = import_lit15.css`
|
|
2281
3092
|
:host {
|
|
2282
3093
|
display: flex;
|
|
2283
3094
|
flex-direction: column;
|
|
@@ -2429,33 +3240,33 @@ DawTrackControlsElement.styles = import_lit12.css`
|
|
|
2429
3240
|
}
|
|
2430
3241
|
`;
|
|
2431
3242
|
__decorateClass([
|
|
2432
|
-
(0,
|
|
3243
|
+
(0, import_decorators14.property)({ attribute: false })
|
|
2433
3244
|
], DawTrackControlsElement.prototype, "trackId", 2);
|
|
2434
3245
|
__decorateClass([
|
|
2435
|
-
(0,
|
|
3246
|
+
(0, import_decorators14.property)({ attribute: false })
|
|
2436
3247
|
], DawTrackControlsElement.prototype, "trackName", 2);
|
|
2437
3248
|
__decorateClass([
|
|
2438
|
-
(0,
|
|
3249
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
2439
3250
|
], DawTrackControlsElement.prototype, "volume", 2);
|
|
2440
3251
|
__decorateClass([
|
|
2441
|
-
(0,
|
|
3252
|
+
(0, import_decorators14.property)({ type: Number, attribute: false })
|
|
2442
3253
|
], DawTrackControlsElement.prototype, "pan", 2);
|
|
2443
3254
|
__decorateClass([
|
|
2444
|
-
(0,
|
|
3255
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
2445
3256
|
], DawTrackControlsElement.prototype, "muted", 2);
|
|
2446
3257
|
__decorateClass([
|
|
2447
|
-
(0,
|
|
3258
|
+
(0, import_decorators14.property)({ type: Boolean, attribute: false })
|
|
2448
3259
|
], DawTrackControlsElement.prototype, "soloed", 2);
|
|
2449
3260
|
DawTrackControlsElement = __decorateClass([
|
|
2450
|
-
(0,
|
|
3261
|
+
(0, import_decorators14.customElement)("daw-track-controls")
|
|
2451
3262
|
], DawTrackControlsElement);
|
|
2452
3263
|
|
|
2453
3264
|
// src/elements/daw-grid.ts
|
|
2454
|
-
var
|
|
2455
|
-
var
|
|
2456
|
-
var
|
|
3265
|
+
var import_lit16 = require("lit");
|
|
3266
|
+
var import_decorators15 = require("lit/decorators.js");
|
|
3267
|
+
var import_core4 = require("@waveform-playlist/core");
|
|
2457
3268
|
var MAX_CANVAS_WIDTH4 = 1e3;
|
|
2458
|
-
var DawGridElement = class extends
|
|
3269
|
+
var DawGridElement = class extends import_lit16.LitElement {
|
|
2459
3270
|
constructor() {
|
|
2460
3271
|
super(...arguments);
|
|
2461
3272
|
this.ticksPerPixel = 24;
|
|
@@ -2483,7 +3294,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2483
3294
|
}
|
|
2484
3295
|
}
|
|
2485
3296
|
render() {
|
|
2486
|
-
if (!this._tickData) return
|
|
3297
|
+
if (!this._tickData) return import_lit16.html``;
|
|
2487
3298
|
const totalWidth = this.length;
|
|
2488
3299
|
const dpr = typeof devicePixelRatio !== "undefined" ? devicePixelRatio : 1;
|
|
2489
3300
|
const indices = getVisibleChunkIndices(
|
|
@@ -2492,11 +3303,11 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2492
3303
|
this.visibleStart,
|
|
2493
3304
|
this.visibleEnd
|
|
2494
3305
|
);
|
|
2495
|
-
return
|
|
3306
|
+
return import_lit16.html`
|
|
2496
3307
|
<div class="container" style="width: ${totalWidth}px; height: ${this.height}px;">
|
|
2497
3308
|
${indices.map((i) => {
|
|
2498
3309
|
const width = Math.min(MAX_CANVAS_WIDTH4, totalWidth - i * MAX_CANVAS_WIDTH4);
|
|
2499
|
-
return
|
|
3310
|
+
return import_lit16.html`
|
|
2500
3311
|
<canvas
|
|
2501
3312
|
data-index=${i}
|
|
2502
3313
|
width=${width * dpr}
|
|
@@ -2530,7 +3341,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2530
3341
|
ctx.resetTransform();
|
|
2531
3342
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2532
3343
|
ctx.scale(dpr, dpr);
|
|
2533
|
-
if (pixelsPerQuarterNote * 4 >=
|
|
3344
|
+
if (pixelsPerQuarterNote * 4 >= import_core4.MIN_PIXELS_PER_UNIT) {
|
|
2534
3345
|
ctx.fillStyle = barHighlight;
|
|
2535
3346
|
const majorTicks = ticks.filter((t) => t.type === "major");
|
|
2536
3347
|
for (let i = 0; i < majorTicks.length; i++) {
|
|
@@ -2557,7 +3368,7 @@ var DawGridElement = class extends import_lit13.LitElement {
|
|
|
2557
3368
|
}
|
|
2558
3369
|
}
|
|
2559
3370
|
};
|
|
2560
|
-
DawGridElement.styles =
|
|
3371
|
+
DawGridElement.styles = import_lit16.css`
|
|
2561
3372
|
:host {
|
|
2562
3373
|
display: block;
|
|
2563
3374
|
position: absolute;
|
|
@@ -2575,33 +3386,33 @@ DawGridElement.styles = import_lit13.css`
|
|
|
2575
3386
|
}
|
|
2576
3387
|
`;
|
|
2577
3388
|
__decorateClass([
|
|
2578
|
-
(0,
|
|
3389
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2579
3390
|
], DawGridElement.prototype, "ticksPerPixel", 2);
|
|
2580
3391
|
__decorateClass([
|
|
2581
|
-
(0,
|
|
3392
|
+
(0, import_decorators15.property)({ attribute: false })
|
|
2582
3393
|
], DawGridElement.prototype, "meterEntries", 2);
|
|
2583
3394
|
__decorateClass([
|
|
2584
|
-
(0,
|
|
3395
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2585
3396
|
], DawGridElement.prototype, "ppqn", 2);
|
|
2586
3397
|
__decorateClass([
|
|
2587
|
-
(0,
|
|
3398
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2588
3399
|
], DawGridElement.prototype, "visibleStart", 2);
|
|
2589
3400
|
__decorateClass([
|
|
2590
|
-
(0,
|
|
3401
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2591
3402
|
], DawGridElement.prototype, "visibleEnd", 2);
|
|
2592
3403
|
__decorateClass([
|
|
2593
|
-
(0,
|
|
3404
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2594
3405
|
], DawGridElement.prototype, "length", 2);
|
|
2595
3406
|
__decorateClass([
|
|
2596
|
-
(0,
|
|
3407
|
+
(0, import_decorators15.property)({ type: Number, attribute: false })
|
|
2597
3408
|
], DawGridElement.prototype, "height", 2);
|
|
2598
3409
|
DawGridElement = __decorateClass([
|
|
2599
|
-
(0,
|
|
3410
|
+
(0, import_decorators15.customElement)("daw-grid")
|
|
2600
3411
|
], DawGridElement);
|
|
2601
3412
|
|
|
2602
3413
|
// src/styles/theme.ts
|
|
2603
|
-
var
|
|
2604
|
-
var hostStyles =
|
|
3414
|
+
var import_lit17 = require("lit");
|
|
3415
|
+
var hostStyles = import_lit17.css`
|
|
2605
3416
|
:host {
|
|
2606
3417
|
--daw-wave-color: #c49a6c;
|
|
2607
3418
|
--daw-progress-color: #63c75f;
|
|
@@ -2617,7 +3428,7 @@ var hostStyles = import_lit14.css`
|
|
|
2617
3428
|
--daw-clip-header-text: #e0d4c8;
|
|
2618
3429
|
}
|
|
2619
3430
|
`;
|
|
2620
|
-
var clipStyles =
|
|
3431
|
+
var clipStyles = import_lit17.css`
|
|
2621
3432
|
.clip-container {
|
|
2622
3433
|
position: absolute;
|
|
2623
3434
|
overflow: hidden;
|
|
@@ -2857,7 +3668,7 @@ var AudioResumeController = class {
|
|
|
2857
3668
|
};
|
|
2858
3669
|
|
|
2859
3670
|
// src/controllers/recording-controller.ts
|
|
2860
|
-
var
|
|
3671
|
+
var import_core5 = require("@waveform-playlist/core");
|
|
2861
3672
|
var RecordingController = class {
|
|
2862
3673
|
constructor(host) {
|
|
2863
3674
|
this._sessions = /* @__PURE__ */ new Map();
|
|
@@ -2951,7 +3762,7 @@ var RecordingController = class {
|
|
|
2951
3762
|
}
|
|
2952
3763
|
const channelCount = detectedChannelCount ?? options.channelCount ?? 1;
|
|
2953
3764
|
const startSample = options.startSample ?? Math.floor(this._host.currentTime * this._host.effectiveSampleRate);
|
|
2954
|
-
const latencySamples = (0,
|
|
3765
|
+
const latencySamples = (0, import_core5.resolveRecordingOffsetSamples)({
|
|
2955
3766
|
overrideSeconds: options.latencyOffset,
|
|
2956
3767
|
outputLatency: rawCtx.outputLatency ?? 0,
|
|
2957
3768
|
lookAhead: 0,
|
|
@@ -3125,8 +3936,8 @@ var RecordingController = class {
|
|
|
3125
3936
|
return;
|
|
3126
3937
|
}
|
|
3127
3938
|
const stopCtx = this._host.audioContext;
|
|
3128
|
-
const channelData = session.chunks.map((chunkArr) => (0,
|
|
3129
|
-
const audioBuffer = (0,
|
|
3939
|
+
const channelData = session.chunks.map((chunkArr) => (0, import_core5.concatenateAudioData)(chunkArr));
|
|
3940
|
+
const audioBuffer = (0, import_core5.createAudioBuffer)(
|
|
3130
3941
|
stopCtx,
|
|
3131
3942
|
channelData,
|
|
3132
3943
|
session.captureSampleRate,
|
|
@@ -3220,7 +4031,7 @@ var RecordingController = class {
|
|
|
3220
4031
|
for (let ch = 0; ch < session.channelCount; ch++) {
|
|
3221
4032
|
if (!channels[ch]) continue;
|
|
3222
4033
|
const oldPeakCount = Math.floor(session.peaks[ch].length / 2);
|
|
3223
|
-
session.peaks[ch] = (0,
|
|
4034
|
+
session.peaks[ch] = (0, import_core5.appendPeaks)(
|
|
3224
4035
|
session.peaks[ch],
|
|
3225
4036
|
channels[ch],
|
|
3226
4037
|
// Render-space scale — in beats mode this differs from
|
|
@@ -3331,9 +4142,191 @@ var RecordingController = class {
|
|
|
3331
4142
|
}
|
|
3332
4143
|
};
|
|
3333
4144
|
|
|
4145
|
+
// src/controllers/annotation-controller.ts
|
|
4146
|
+
var import_lit18 = require("lit");
|
|
4147
|
+
var ANNOTATION_LANE_HEIGHT = 32;
|
|
4148
|
+
var AnnotationController = class {
|
|
4149
|
+
constructor(host) {
|
|
4150
|
+
this._tracks = [];
|
|
4151
|
+
this._removalObserver = null;
|
|
4152
|
+
/** Playback-following highlight per track, separate from each track's
|
|
4153
|
+
* `activeAnnotationId` (selection) so playback never disturbs selection.
|
|
4154
|
+
* Driven by daw-timeupdate, cleared on daw-stop, retained on pause.
|
|
4155
|
+
* Replaced immutably (a fresh Map) on every change. */
|
|
4156
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4157
|
+
this._onDataChange = () => {
|
|
4158
|
+
this.deriveSecondsCaches();
|
|
4159
|
+
this._host.requestUpdate();
|
|
4160
|
+
};
|
|
4161
|
+
/**
|
|
4162
|
+
* Update only on annotation-boundary crossings, not per animation frame.
|
|
4163
|
+
*/
|
|
4164
|
+
this._onTimeUpdate = (e) => {
|
|
4165
|
+
const time = e.detail.time;
|
|
4166
|
+
let changed = false;
|
|
4167
|
+
const next = new Map(this._playingIds);
|
|
4168
|
+
for (const track of this._tracks) {
|
|
4169
|
+
const playingId = computePlayingAnnotationId(track.annotations, time);
|
|
4170
|
+
if (playingId !== (this._playingIds.get(track) ?? null)) {
|
|
4171
|
+
next.set(track, playingId);
|
|
4172
|
+
changed = true;
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
if (!changed) return;
|
|
4176
|
+
this._playingIds = next;
|
|
4177
|
+
this._host.requestUpdate();
|
|
4178
|
+
};
|
|
4179
|
+
this._onStop = () => {
|
|
4180
|
+
if (this._playingIds.size === 0) return;
|
|
4181
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4182
|
+
this._host.requestUpdate();
|
|
4183
|
+
};
|
|
4184
|
+
this._host = host;
|
|
4185
|
+
host.addController(this);
|
|
4186
|
+
}
|
|
4187
|
+
get tracks() {
|
|
4188
|
+
return this._tracks;
|
|
4189
|
+
}
|
|
4190
|
+
/** Current playback-following highlight id for a track, or `null` when the
|
|
4191
|
+
* playhead isn't inside any of the track's annotations. */
|
|
4192
|
+
getPlayingAnnotationId(track) {
|
|
4193
|
+
return this._playingIds.get(track) ?? null;
|
|
4194
|
+
}
|
|
4195
|
+
get totalLaneHeight() {
|
|
4196
|
+
return this._tracks.length * ANNOTATION_LANE_HEIGHT;
|
|
4197
|
+
}
|
|
4198
|
+
/** Max annotation end (seconds) across registered tracks — 0 when none.
|
|
4199
|
+
* Lets the editor extend the timeline so annotations past the audio stay
|
|
4200
|
+
* reachable/scrollable. */
|
|
4201
|
+
get maxAnnotationEndSeconds() {
|
|
4202
|
+
return this._tracks.reduce(
|
|
4203
|
+
(max, track) => track.annotations.reduce((m, a) => Math.max(m, a.end), max),
|
|
4204
|
+
0
|
|
4205
|
+
);
|
|
4206
|
+
}
|
|
4207
|
+
hostConnected() {
|
|
4208
|
+
this._host.addEventListener("daw-annotation-update", this._onDataChange);
|
|
4209
|
+
this._host.addEventListener("daw-annotation-select", this._onDataChange);
|
|
4210
|
+
this._host.addEventListener("daw-annotation-connected", this._onDataChange);
|
|
4211
|
+
this._host.addEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
4212
|
+
this._host.addEventListener("daw-stop", this._onStop);
|
|
4213
|
+
this._removalObserver = new MutationObserver((mutations) => {
|
|
4214
|
+
let changed = false;
|
|
4215
|
+
for (const m of mutations) {
|
|
4216
|
+
for (const node of Array.from(m.removedNodes)) {
|
|
4217
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
4218
|
+
if (node.tagName === "DAW-ANNOTATION-TRACK") {
|
|
4219
|
+
this._tracks = this._tracks.filter((t) => t !== node);
|
|
4220
|
+
changed = true;
|
|
4221
|
+
} else if (node.tagName === "DAW-ANNOTATION") {
|
|
4222
|
+
changed = true;
|
|
4223
|
+
}
|
|
4224
|
+
const nestedTracks = node.querySelectorAll?.("daw-annotation-track");
|
|
4225
|
+
if (nestedTracks) {
|
|
4226
|
+
for (const nested of nestedTracks) {
|
|
4227
|
+
this._tracks = this._tracks.filter((t) => t !== nested);
|
|
4228
|
+
changed = true;
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
const nestedAnnotations = node.querySelectorAll?.("daw-annotation");
|
|
4232
|
+
if (nestedAnnotations && nestedAnnotations.length > 0) {
|
|
4233
|
+
changed = true;
|
|
4234
|
+
}
|
|
4235
|
+
}
|
|
4236
|
+
}
|
|
4237
|
+
if (changed) this._host.requestUpdate();
|
|
4238
|
+
});
|
|
4239
|
+
this._removalObserver.observe(this._host, { childList: true, subtree: true });
|
|
4240
|
+
}
|
|
4241
|
+
hostDisconnected() {
|
|
4242
|
+
this._host.removeEventListener("daw-annotation-update", this._onDataChange);
|
|
4243
|
+
this._host.removeEventListener("daw-annotation-select", this._onDataChange);
|
|
4244
|
+
this._host.removeEventListener("daw-annotation-connected", this._onDataChange);
|
|
4245
|
+
this._host.removeEventListener("daw-timeupdate", this._onTimeUpdate);
|
|
4246
|
+
this._host.removeEventListener("daw-stop", this._onStop);
|
|
4247
|
+
this._removalObserver?.disconnect();
|
|
4248
|
+
this._removalObserver = null;
|
|
4249
|
+
this._tracks = [];
|
|
4250
|
+
this._playingIds = /* @__PURE__ */ new Map();
|
|
4251
|
+
}
|
|
4252
|
+
handleTrackConnected(el) {
|
|
4253
|
+
if (this._tracks.includes(el)) return;
|
|
4254
|
+
this._tracks = [...this._tracks, el];
|
|
4255
|
+
this._host.requestUpdate();
|
|
4256
|
+
this.deriveSecondsCaches();
|
|
4257
|
+
}
|
|
4258
|
+
/**
|
|
4259
|
+
* Keep the seconds attributes (derived cache) of tick-based annotations in
|
|
4260
|
+
* sync with the host's tempo. Write-only-on-change: a write fires
|
|
4261
|
+
* daw-annotation-update → _onDataChange → this sweep again → values equal →
|
|
4262
|
+
* no write → the loop settles (idempotent).
|
|
4263
|
+
*/
|
|
4264
|
+
deriveSecondsCaches() {
|
|
4265
|
+
for (const track of this._tracks) {
|
|
4266
|
+
for (const el of track.annotationElements) {
|
|
4267
|
+
if (!el.isTickBased) continue;
|
|
4268
|
+
const startSeconds = this._host._ticksToSeconds(el.startTick);
|
|
4269
|
+
const endSeconds = this._host._ticksToSeconds(el.endTick);
|
|
4270
|
+
if (el.start !== startSeconds) el.start = startSeconds;
|
|
4271
|
+
if (el.end !== endSeconds) el.end = endSeconds;
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
/** Pixel geometry for one annotation box. Tick-based annotations in beats
|
|
4276
|
+
* mode use CLIP-IDENTICAL tick math (round(tick / ticksPerPixel)) so they
|
|
4277
|
+
* align pixel-exactly with <daw-grid>; everything else uses the floor-based
|
|
4278
|
+
* seconds math (temporal mode reads the always-fresh seconds cache). */
|
|
4279
|
+
boxGeometry(a, spp, sampleRate, ticksPerPixel = null) {
|
|
4280
|
+
if (ticksPerPixel !== null && ticksPerPixel > 0 && a.startTick !== void 0 && a.endTick !== void 0) {
|
|
4281
|
+
const left2 = Math.round(a.startTick / ticksPerPixel);
|
|
4282
|
+
const width2 = Math.round(a.endTick / ticksPerPixel) - left2;
|
|
4283
|
+
return { left: left2, width: width2 };
|
|
4284
|
+
}
|
|
4285
|
+
const left = Math.floor(a.start * sampleRate / spp);
|
|
4286
|
+
const width = Math.floor(a.end * sampleRate / spp) - left;
|
|
4287
|
+
return { left, width };
|
|
4288
|
+
}
|
|
4289
|
+
/**
|
|
4290
|
+
* Lane templates for the editor's .timeline. onPointerDown is supplied by
|
|
4291
|
+
* the editor and dispatches into the drag interaction (Task 9).
|
|
4292
|
+
*/
|
|
4293
|
+
renderLanes(spp, sampleRate, onPointerDown = () => {
|
|
4294
|
+
}, ticksPerPixel = null) {
|
|
4295
|
+
return this._tracks.map((track) => {
|
|
4296
|
+
const activeId = track.activeAnnotationId;
|
|
4297
|
+
const playingId = this._playingIds.get(track) ?? null;
|
|
4298
|
+
const elements = track.annotationElements;
|
|
4299
|
+
return import_lit18.html`
|
|
4300
|
+
<div
|
|
4301
|
+
class="annotation-lane"
|
|
4302
|
+
style="height: ${ANNOTATION_LANE_HEIGHT}px;"
|
|
4303
|
+
@pointerdown=${(e) => onPointerDown(e, track)}
|
|
4304
|
+
>
|
|
4305
|
+
${elements.map((el, i) => {
|
|
4306
|
+
const a = el.toAnnotationData();
|
|
4307
|
+
const geo = this.boxGeometry(a, spp, sampleRate, ticksPerPixel);
|
|
4308
|
+
const label = track.boxLabel === "none" ? "" : track.boxLabel === "id" ? el.id || String(i + 1) : a.lines.join(" ");
|
|
4309
|
+
return import_lit18.html`
|
|
4310
|
+
<div
|
|
4311
|
+
class="annotation-box ${a.id === activeId ? "active" : ""} ${a.id === playingId ? "playing" : ""}"
|
|
4312
|
+
data-annotation-id=${a.id}
|
|
4313
|
+
style="left: ${geo.left}px; width: ${geo.width}px;"
|
|
4314
|
+
>
|
|
4315
|
+
${track.editable ? import_lit18.html`<div class="annotation-boundary" data-edge="start"></div>` : ""}
|
|
4316
|
+
<span class="annotation-box-text">${label}</span>
|
|
4317
|
+
${track.editable ? import_lit18.html`<div class="annotation-boundary" data-edge="end"></div>` : ""}
|
|
4318
|
+
</div>
|
|
4319
|
+
`;
|
|
4320
|
+
})}
|
|
4321
|
+
</div>
|
|
4322
|
+
`;
|
|
4323
|
+
});
|
|
4324
|
+
}
|
|
4325
|
+
};
|
|
4326
|
+
|
|
3334
4327
|
// src/controllers/spectrogram-controller.ts
|
|
3335
4328
|
var import_spectrogram = require("@dawcore/spectrogram");
|
|
3336
|
-
var
|
|
4329
|
+
var import_core6 = require("@waveform-playlist/core");
|
|
3337
4330
|
var SpectrogramController = class {
|
|
3338
4331
|
constructor(host, workerFactory) {
|
|
3339
4332
|
this.orchestrator = null;
|
|
@@ -3386,8 +4379,8 @@ var SpectrogramController = class {
|
|
|
3386
4379
|
unregisterCanvas(canvasId) {
|
|
3387
4380
|
this.orchestrator?.unregisterCanvas(canvasId);
|
|
3388
4381
|
}
|
|
3389
|
-
setViewport(
|
|
3390
|
-
this.orchestrator?.setViewport(
|
|
4382
|
+
setViewport(state9) {
|
|
4383
|
+
this.orchestrator?.setViewport(state9);
|
|
3391
4384
|
}
|
|
3392
4385
|
dispose() {
|
|
3393
4386
|
if (this.orchestrator) {
|
|
@@ -3442,18 +4435,18 @@ var SpectrogramController = class {
|
|
|
3442
4435
|
track = c;
|
|
3443
4436
|
break;
|
|
3444
4437
|
}
|
|
3445
|
-
return { ...
|
|
4438
|
+
return { ...import_core6.SPECTROGRAM_DEFAULTS, ...this.editorConfig ?? {}, ...track ?? {} };
|
|
3446
4439
|
}
|
|
3447
4440
|
mergedColorMap() {
|
|
3448
4441
|
for (const c of this.trackColorMaps.values()) {
|
|
3449
|
-
return c ??
|
|
4442
|
+
return c ?? import_core6.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
3450
4443
|
}
|
|
3451
|
-
return this.editorColorMap ??
|
|
4444
|
+
return this.editorColorMap ?? import_core6.DEFAULT_SPECTROGRAM_COLOR_MAP;
|
|
3452
4445
|
}
|
|
3453
4446
|
};
|
|
3454
4447
|
|
|
3455
4448
|
// src/interactions/pointer-handler.ts
|
|
3456
|
-
var
|
|
4449
|
+
var import_core7 = require("@waveform-playlist/core");
|
|
3457
4450
|
|
|
3458
4451
|
// src/interactions/constants.ts
|
|
3459
4452
|
var DRAG_THRESHOLD = 3;
|
|
@@ -3610,10 +4603,10 @@ var PointerHandler = class {
|
|
|
3610
4603
|
const h = this._host;
|
|
3611
4604
|
if (h.scaleMode === "beats") {
|
|
3612
4605
|
let tick = px * h.ticksPerPixel;
|
|
3613
|
-
tick = (0,
|
|
4606
|
+
tick = (0, import_core7.snapTickToGrid)(tick, h.snapTo, h._meterEntries, h.ppqn);
|
|
3614
4607
|
return h._ticksToSeconds(tick);
|
|
3615
4608
|
}
|
|
3616
|
-
return (0,
|
|
4609
|
+
return (0, import_core7.pixelsToSeconds)(px, h.samplesPerPixel, h.effectiveSampleRate);
|
|
3617
4610
|
}
|
|
3618
4611
|
_timeToPx(time) {
|
|
3619
4612
|
const h = this._host;
|
|
@@ -3732,7 +4725,7 @@ var PointerHandler = class {
|
|
|
3732
4725
|
};
|
|
3733
4726
|
|
|
3734
4727
|
// src/interactions/clip-pointer-handler.ts
|
|
3735
|
-
var
|
|
4728
|
+
var import_core8 = require("@waveform-playlist/core");
|
|
3736
4729
|
var ClipPointerHandler = class {
|
|
3737
4730
|
constructor(host) {
|
|
3738
4731
|
this._mode = null;
|
|
@@ -3766,7 +4759,7 @@ var ClipPointerHandler = class {
|
|
|
3766
4759
|
const anchorTick = h._secondsToTicks(anchorSeconds);
|
|
3767
4760
|
const deltaTicks = totalDeltaPx * h.ticksPerPixel;
|
|
3768
4761
|
const targetTick = anchorTick + deltaTicks;
|
|
3769
|
-
const snappedTick = h.snapTo !== "off" ? (0,
|
|
4762
|
+
const snappedTick = h.snapTo !== "off" ? (0, import_core8.snapTickToGrid)(targetTick, h.snapTo, h._meterEntries, h.ppqn) : targetTick;
|
|
3770
4763
|
const snappedSeconds = h._ticksToSeconds(snappedTick);
|
|
3771
4764
|
const snappedSample = Math.round(snappedSeconds * h.effectiveSampleRate);
|
|
3772
4765
|
return snappedSample - anchorSample;
|
|
@@ -4050,6 +5043,145 @@ var ClipPointerHandler = class {
|
|
|
4050
5043
|
}
|
|
4051
5044
|
};
|
|
4052
5045
|
|
|
5046
|
+
// src/interactions/annotation-drag.ts
|
|
5047
|
+
var import_core9 = require("@waveform-playlist/core");
|
|
5048
|
+
var import_core10 = require("@waveform-playlist/core");
|
|
5049
|
+
var AnnotationDragHandler = class {
|
|
5050
|
+
constructor(host) {
|
|
5051
|
+
this._drag = null;
|
|
5052
|
+
this.onPointerDown = (e, track) => {
|
|
5053
|
+
const target = e.target;
|
|
5054
|
+
const boundary = target.closest(".annotation-boundary");
|
|
5055
|
+
const box = target.closest(".annotation-box");
|
|
5056
|
+
if (!box) return;
|
|
5057
|
+
const annotationId = box.getAttribute("data-annotation-id") ?? "";
|
|
5058
|
+
const isBoundary = boundary !== null && track.editable;
|
|
5059
|
+
if (boundary !== null && !track.editable) {
|
|
5060
|
+
return;
|
|
5061
|
+
}
|
|
5062
|
+
e.stopPropagation();
|
|
5063
|
+
e.preventDefault();
|
|
5064
|
+
const elements = track.annotationElements;
|
|
5065
|
+
const el = elements.find((x) => x.annotationId === annotationId);
|
|
5066
|
+
if (!el) return;
|
|
5067
|
+
const mode = el.isTickBased ? "ticks" : "seconds";
|
|
5068
|
+
const snapshot = mode === "ticks" ? elements.map((x) => tickSpaceData(x, this._host)) : track.annotations;
|
|
5069
|
+
const index = snapshot.findIndex((a) => a.id === annotationId);
|
|
5070
|
+
if (index === -1) return;
|
|
5071
|
+
const edge = isBoundary ? boundary.getAttribute("data-edge") : null;
|
|
5072
|
+
const captureEl = isBoundary ? boundary : box;
|
|
5073
|
+
this._drag = {
|
|
5074
|
+
track,
|
|
5075
|
+
captureEl,
|
|
5076
|
+
pointerId: e.pointerId,
|
|
5077
|
+
startClientX: e.clientX,
|
|
5078
|
+
moved: false,
|
|
5079
|
+
edge,
|
|
5080
|
+
annotationId,
|
|
5081
|
+
mode,
|
|
5082
|
+
snapshot,
|
|
5083
|
+
// edgeTime holds ticks in 'ticks' mode, seconds in 'seconds' mode.
|
|
5084
|
+
edgeTime: edge === "start" ? snapshot[index].start : snapshot[index].end
|
|
5085
|
+
};
|
|
5086
|
+
try {
|
|
5087
|
+
captureEl.setPointerCapture(e.pointerId);
|
|
5088
|
+
} catch {
|
|
5089
|
+
}
|
|
5090
|
+
captureEl.addEventListener("pointermove", this._onPointerMove);
|
|
5091
|
+
captureEl.addEventListener("pointerup", this._onPointerUp);
|
|
5092
|
+
captureEl.addEventListener("pointercancel", this._onPointerCancel);
|
|
5093
|
+
};
|
|
5094
|
+
/** Non-private (underscore convention) so tests can drive moves directly. */
|
|
5095
|
+
this._onPointerMove = (e) => {
|
|
5096
|
+
const drag = this._drag;
|
|
5097
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5098
|
+
const deltaPx = e.clientX - drag.startClientX;
|
|
5099
|
+
if (Math.abs(deltaPx) >= DRAG_THRESHOLD) drag.moved = true;
|
|
5100
|
+
if (drag.edge === null || !drag.moved) return;
|
|
5101
|
+
const elements = drag.track.annotationElements;
|
|
5102
|
+
const index = drag.snapshot.findIndex((a) => a.id === drag.annotationId);
|
|
5103
|
+
if (index === -1) return;
|
|
5104
|
+
if (drag.mode === "ticks") {
|
|
5105
|
+
const deltaTicks = this._host.scaleMode === "beats" ? deltaPx * this._host.ticksPerPixel : this._host._secondsToTicks(
|
|
5106
|
+
this._host._ticksToSeconds(drag.edgeTime) + deltaPx * this._host._renderSpp / this._host.effectiveSampleRate
|
|
5107
|
+
) - drag.edgeTime;
|
|
5108
|
+
let newTick = drag.edgeTime + deltaTicks;
|
|
5109
|
+
if (this._host.scaleMode === "beats" && this._host.snapTo !== "off") {
|
|
5110
|
+
newTick = (0, import_core9.snapTickToGrid)(
|
|
5111
|
+
newTick,
|
|
5112
|
+
this._host.snapTo,
|
|
5113
|
+
this._host._meterEntries,
|
|
5114
|
+
this._host.ppqn
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5117
|
+
const clamp = this._host._annotationClampDuration;
|
|
5118
|
+
const updated2 = (0, import_core9.updateAnnotationBoundaries)(
|
|
5119
|
+
{
|
|
5120
|
+
annotationIndex: index,
|
|
5121
|
+
newTime: newTick,
|
|
5122
|
+
isDraggingStart: drag.edge === "start",
|
|
5123
|
+
annotations: drag.snapshot,
|
|
5124
|
+
duration: clamp === Infinity ? Infinity : this._host._secondsToTicks(clamp),
|
|
5125
|
+
linkEndpoints: drag.track.linkEndpoints
|
|
5126
|
+
},
|
|
5127
|
+
{
|
|
5128
|
+
linkThreshold: import_core10.ANNOTATION_LINK_THRESHOLD_TICKS,
|
|
5129
|
+
minDuration: (0, import_core10.annotationMinDurationTicks)(this._host.ppqn)
|
|
5130
|
+
}
|
|
5131
|
+
);
|
|
5132
|
+
applyTickBoundaryResults(elements, updated2, (t) => this._host._ticksToSeconds(t));
|
|
5133
|
+
return;
|
|
5134
|
+
}
|
|
5135
|
+
const deltaSeconds = deltaPx * this._host._renderSpp / this._host.effectiveSampleRate;
|
|
5136
|
+
const updated = (0, import_core9.updateAnnotationBoundaries)({
|
|
5137
|
+
annotationIndex: index,
|
|
5138
|
+
newTime: drag.edgeTime + deltaSeconds,
|
|
5139
|
+
isDraggingStart: drag.edge === "start",
|
|
5140
|
+
annotations: drag.snapshot,
|
|
5141
|
+
duration: this._host._annotationClampDuration,
|
|
5142
|
+
linkEndpoints: drag.track.linkEndpoints
|
|
5143
|
+
});
|
|
5144
|
+
applyBoundaryResults(elements, updated);
|
|
5145
|
+
};
|
|
5146
|
+
this._onPointerUp = (e) => {
|
|
5147
|
+
const drag = this._drag;
|
|
5148
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5149
|
+
if (!drag.moved && drag.edge === null) {
|
|
5150
|
+
const data = drag.track.annotations.find((a) => a.id === drag.annotationId);
|
|
5151
|
+
if (data) {
|
|
5152
|
+
drag.track.activeAnnotationId = drag.annotationId;
|
|
5153
|
+
this._host.seekTo(data.start);
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
this._teardown();
|
|
5157
|
+
};
|
|
5158
|
+
this._onPointerCancel = (e) => {
|
|
5159
|
+
const drag = this._drag;
|
|
5160
|
+
if (!drag || e.pointerId !== drag.pointerId) return;
|
|
5161
|
+
const elements = drag.track.annotationElements;
|
|
5162
|
+
if (drag.mode === "ticks") {
|
|
5163
|
+
applyTickBoundaryResults(elements, drag.snapshot, (t) => this._host._ticksToSeconds(t));
|
|
5164
|
+
} else {
|
|
5165
|
+
applyBoundaryResults(elements, drag.snapshot);
|
|
5166
|
+
}
|
|
5167
|
+
this._teardown();
|
|
5168
|
+
};
|
|
5169
|
+
this._host = host;
|
|
5170
|
+
}
|
|
5171
|
+
_teardown() {
|
|
5172
|
+
const drag = this._drag;
|
|
5173
|
+
if (!drag) return;
|
|
5174
|
+
try {
|
|
5175
|
+
drag.captureEl.releasePointerCapture(drag.pointerId);
|
|
5176
|
+
} catch {
|
|
5177
|
+
}
|
|
5178
|
+
drag.captureEl.removeEventListener("pointermove", this._onPointerMove);
|
|
5179
|
+
drag.captureEl.removeEventListener("pointerup", this._onPointerUp);
|
|
5180
|
+
drag.captureEl.removeEventListener("pointercancel", this._onPointerCancel);
|
|
5181
|
+
this._drag = null;
|
|
5182
|
+
}
|
|
5183
|
+
};
|
|
5184
|
+
|
|
4053
5185
|
// src/utils/time-display-format.ts
|
|
4054
5186
|
var TIME_DISPLAY_FORMATS = [
|
|
4055
5187
|
"hh:mm:ss.sss",
|
|
@@ -4102,7 +5234,7 @@ function parseDisplayTime(value, format) {
|
|
|
4102
5234
|
}
|
|
4103
5235
|
|
|
4104
5236
|
// src/interactions/file-loader.ts
|
|
4105
|
-
var
|
|
5237
|
+
var import_core11 = require("@waveform-playlist/core");
|
|
4106
5238
|
async function loadFiles(host, files) {
|
|
4107
5239
|
if (!files) {
|
|
4108
5240
|
console.warn("[dawcore] loadFiles called with null/undefined");
|
|
@@ -4134,7 +5266,7 @@ async function loadFiles(host, files) {
|
|
|
4134
5266
|
host._audioCache.delete(blobUrl);
|
|
4135
5267
|
host._resolvedSampleRate = audioBuffer.sampleRate;
|
|
4136
5268
|
const name = file.name.replace(/\.\w+$/, "");
|
|
4137
|
-
const clip = (0,
|
|
5269
|
+
const clip = (0, import_core11.createClip)({
|
|
4138
5270
|
audioBuffer,
|
|
4139
5271
|
startSample: 0,
|
|
4140
5272
|
durationSamples: audioBuffer.length,
|
|
@@ -4158,7 +5290,7 @@ async function loadFiles(host, files) {
|
|
|
4158
5290
|
);
|
|
4159
5291
|
host._peaksData = new Map(host._peaksData).set(clip.id, peakData);
|
|
4160
5292
|
const trackId = crypto.randomUUID();
|
|
4161
|
-
const track = (0,
|
|
5293
|
+
const track = (0, import_core11.createTrack)({ name, clips: [clip] });
|
|
4162
5294
|
track.id = trackId;
|
|
4163
5295
|
host._tracks = new Map(host._tracks).set(trackId, {
|
|
4164
5296
|
name,
|
|
@@ -4320,7 +5452,7 @@ function stringifyReason(reason) {
|
|
|
4320
5452
|
}
|
|
4321
5453
|
|
|
4322
5454
|
// src/interactions/recording-clip.ts
|
|
4323
|
-
var
|
|
5455
|
+
var import_core12 = require("@waveform-playlist/core");
|
|
4324
5456
|
function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamples = 0, clipName) {
|
|
4325
5457
|
let trimmedBuf = buf;
|
|
4326
5458
|
if (offsetSamples > 0 && offsetSamples < buf.length) {
|
|
@@ -4335,7 +5467,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4335
5467
|
}
|
|
4336
5468
|
trimmedBuf = trimmed;
|
|
4337
5469
|
}
|
|
4338
|
-
const clip = (0,
|
|
5470
|
+
const clip = (0, import_core12.createClip)({
|
|
4339
5471
|
audioBuffer: trimmedBuf,
|
|
4340
5472
|
startSample,
|
|
4341
5473
|
durationSamples: durSamples,
|
|
@@ -4362,7 +5494,7 @@ function addRecordedClip(host, trackId, buf, startSample, durSamples, offsetSamp
|
|
|
4362
5494
|
// Punch-in replace (#579): the recorded clip owns [startSample,
|
|
4363
5495
|
// startSample + durSamples) — carve overlapped content out of the
|
|
4364
5496
|
// existing clips before inserting (parity with the React provider).
|
|
4365
|
-
clips: [...(0,
|
|
5497
|
+
clips: [...(0, import_core12.carveClipRange)(t.clips, startSample, startSample + durSamples), clip]
|
|
4366
5498
|
});
|
|
4367
5499
|
const desc = host._tracks.get(trackId);
|
|
4368
5500
|
if (desc) {
|
|
@@ -4436,9 +5568,9 @@ function splitAtPlayhead(host) {
|
|
|
4436
5568
|
function canSplitAtTime(host, time) {
|
|
4437
5569
|
const { engine } = host;
|
|
4438
5570
|
if (!engine) return false;
|
|
4439
|
-
const
|
|
4440
|
-
if (!
|
|
4441
|
-
const track =
|
|
5571
|
+
const state9 = engine.getState();
|
|
5572
|
+
if (!state9.selectedTrackId) return false;
|
|
5573
|
+
const track = state9.tracks.find((t) => t.id === state9.selectedTrackId);
|
|
4442
5574
|
if (!track) return false;
|
|
4443
5575
|
const atSample = Math.round(time * host.effectiveSampleRate);
|
|
4444
5576
|
const clip = findClipAtSample(track.clips, atSample);
|
|
@@ -4631,9 +5763,9 @@ var EffectsChainController = class {
|
|
|
4631
5763
|
placeholder: true
|
|
4632
5764
|
};
|
|
4633
5765
|
}
|
|
4634
|
-
let
|
|
5766
|
+
let state9;
|
|
4635
5767
|
try {
|
|
4636
|
-
|
|
5768
|
+
state9 = await entry.instance.getState?.();
|
|
4637
5769
|
} catch (err) {
|
|
4638
5770
|
console.warn(
|
|
4639
5771
|
'[waveform-playlist] serialize: plugin "' + (entry.url ?? entry.label ?? entry.type) + '" getState failed: ' + String(err)
|
|
@@ -4643,7 +5775,7 @@ var EffectsChainController = class {
|
|
|
4643
5775
|
kind: "wam",
|
|
4644
5776
|
...sourceFields,
|
|
4645
5777
|
bypassed: entry.bypassed,
|
|
4646
|
-
...
|
|
5778
|
+
...state9 !== void 0 ? { state: state9 } : {}
|
|
4647
5779
|
};
|
|
4648
5780
|
}
|
|
4649
5781
|
if (entry.placeholder) {
|
|
@@ -5943,6 +7075,7 @@ var PlaybackAnimationController = class {
|
|
|
5943
7075
|
this._running = true;
|
|
5944
7076
|
this._animation.start(() => {
|
|
5945
7077
|
const time = getTime();
|
|
7078
|
+
if (!this._running) return;
|
|
5946
7079
|
this._options.getPlayhead()?.setPosition(this._options.timeToPixels(time));
|
|
5947
7080
|
this._dispatchTimeUpdate(time);
|
|
5948
7081
|
});
|
|
@@ -5980,7 +7113,7 @@ var TrackLoadCancelledError = class extends Error {
|
|
|
5980
7113
|
this.name = "TrackLoadCancelledError";
|
|
5981
7114
|
}
|
|
5982
7115
|
};
|
|
5983
|
-
var DawEditorElement = class extends
|
|
7116
|
+
var DawEditorElement = class extends import_lit19.LitElement {
|
|
5984
7117
|
constructor() {
|
|
5985
7118
|
super(...arguments);
|
|
5986
7119
|
this._samplesPerPixel = 1024;
|
|
@@ -6018,6 +7151,13 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6018
7151
|
this._selectionStartTime = 0;
|
|
6019
7152
|
this._selectionEndTime = 0;
|
|
6020
7153
|
this._currentTime = 0;
|
|
7154
|
+
// Bounded-playback watermark for the current play(start, end) call
|
|
7155
|
+
// (selection/annotation playback). The adapter's own auto-stop at
|
|
7156
|
+
// endTime (e.g. native Transport's internal timer) tears down audio but
|
|
7157
|
+
// never notifies isPlaying/daw-stop back up — the _startPlayhead rAF
|
|
7158
|
+
// loop below is the sole place that detects reaching it, same pattern
|
|
7159
|
+
// as the whole-track _duration check.
|
|
7160
|
+
this._activePlayEndTime = null;
|
|
6021
7161
|
this._externalAdapter = null;
|
|
6022
7162
|
/** True after a disconnect disposed the consumer's adapter via the engine
|
|
6023
7163
|
* — rebuild attempts fail loudly until a fresh adapter is set. */
|
|
@@ -6044,6 +7184,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6044
7184
|
this._childObserver = null;
|
|
6045
7185
|
this._audioResume = new AudioResumeController(this);
|
|
6046
7186
|
this._recordingController = new RecordingController(this);
|
|
7187
|
+
this._annotations = new AnnotationController(this);
|
|
7188
|
+
/** Last engine BPM seen by the statechange handler — re-derives tick
|
|
7189
|
+
* annotation seconds caches only when it actually changes. */
|
|
7190
|
+
this._lastAnnotationBpm = null;
|
|
6047
7191
|
// Closures (not direct references) — _timeToPixels/_getPlayhead are
|
|
6048
7192
|
// declared later in the class body; class-field init order would read
|
|
6049
7193
|
// `undefined` for a direct reference here.
|
|
@@ -6058,8 +7202,17 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6058
7202
|
* play-start position). Non-private: pointer-handler's seek path sets it.
|
|
6059
7203
|
*/
|
|
6060
7204
|
this._inSeekTransition = false;
|
|
7205
|
+
/**
|
|
7206
|
+
* True while `stop()` (the public API) is actively calling `this._engine.stop()`.
|
|
7207
|
+
* Suppresses the engine 'stop' handler's own `daw-stop` dispatch — `stop()`
|
|
7208
|
+
* dispatches its own, and without this guard a consumer-initiated stop would
|
|
7209
|
+
* fire `daw-stop` twice. See the engine 'stop' handler for the counterpart
|
|
7210
|
+
* engine-initiated case this flag does NOT suppress.
|
|
7211
|
+
*/
|
|
7212
|
+
this._inConsumerStop = false;
|
|
6061
7213
|
this._spectrogramController = null;
|
|
6062
7214
|
this._clipPointer = new ClipPointerHandler(this);
|
|
7215
|
+
this._annotationDrag = new AnnotationDragHandler(this);
|
|
6063
7216
|
this._pointer = new PointerHandler(this);
|
|
6064
7217
|
this._viewport = (() => {
|
|
6065
7218
|
const v = new ViewportController(this);
|
|
@@ -6083,6 +7236,18 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6083
7236
|
* update for properties unrelated to the viewport.
|
|
6084
7237
|
*/
|
|
6085
7238
|
this._lastSpectrogramViewport = null;
|
|
7239
|
+
// --- Annotation Events ---
|
|
7240
|
+
this._onAnnotationTrackConnected = (e) => {
|
|
7241
|
+
this._annotations.handleTrackConnected(e.detail.element);
|
|
7242
|
+
};
|
|
7243
|
+
this._onAnnotationSelect = (e) => {
|
|
7244
|
+
const annotation = e.detail.annotation;
|
|
7245
|
+
if (!annotation) return;
|
|
7246
|
+
const scrollArea = this.shadowRoot?.querySelector(".scroll-area");
|
|
7247
|
+
if (!scrollArea) return;
|
|
7248
|
+
const px = Math.floor(annotation.start * this.effectiveSampleRate / this._renderSpp);
|
|
7249
|
+
scrollArea.scrollLeft = Math.max(0, px - scrollArea.clientWidth / 2);
|
|
7250
|
+
};
|
|
6086
7251
|
// --- Track Events ---
|
|
6087
7252
|
this._onTrackConnected = (e) => {
|
|
6088
7253
|
const trackId = e.detail?.trackId;
|
|
@@ -6726,6 +7891,12 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6726
7891
|
}
|
|
6727
7892
|
return ticks * 60 / (this.bpm * this.ppqn);
|
|
6728
7893
|
}
|
|
7894
|
+
/** Clamp limit for annotation boundary edits. indefinite-playback removes the
|
|
7895
|
+
* end-of-timeline bound — annotations may extend past the audio (DAW-style
|
|
7896
|
+
* unbounded timeline); the shared boundary math treats Infinity as "no end cap". */
|
|
7897
|
+
get _annotationClampDuration() {
|
|
7898
|
+
return this.indefinitePlayback ? Infinity : this._duration;
|
|
7899
|
+
}
|
|
6729
7900
|
get _totalWidth() {
|
|
6730
7901
|
if (this.scaleMode === "beats") {
|
|
6731
7902
|
const contentTicks = this._secondsToTicks(this._duration);
|
|
@@ -6733,8 +7904,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6733
7904
|
const minTicks = 32 * num * this.ppqn;
|
|
6734
7905
|
return Math.ceil(Math.max(contentTicks, minTicks) / this.ticksPerPixel);
|
|
6735
7906
|
}
|
|
7907
|
+
const naturalDuration = Math.max(this._duration, this._annotations.maxAnnotationEndSeconds);
|
|
6736
7908
|
const naturalWidth = Math.ceil(
|
|
6737
|
-
|
|
7909
|
+
naturalDuration * this.effectiveSampleRate / this.samplesPerPixel
|
|
6738
7910
|
);
|
|
6739
7911
|
if (this.indefinitePlayback || this.fillViewport) {
|
|
6740
7912
|
return Math.max(naturalWidth, this._viewport.containerWidth);
|
|
@@ -6786,6 +7958,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6786
7958
|
this.addEventListener("daw-track-remove", this._onTrackRemoveRequest);
|
|
6787
7959
|
this.addEventListener("daw-clip-connected", this._onClipConnected);
|
|
6788
7960
|
this.addEventListener("daw-clip-update", this._onClipUpdate);
|
|
7961
|
+
this.addEventListener(
|
|
7962
|
+
"daw-annotation-track-connected",
|
|
7963
|
+
this._onAnnotationTrackConnected
|
|
7964
|
+
);
|
|
7965
|
+
this.addEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
6789
7966
|
this._childObserver = new MutationObserver((mutations) => {
|
|
6790
7967
|
for (const mutation of mutations) {
|
|
6791
7968
|
for (const node of mutation.removedNodes) {
|
|
@@ -6823,6 +8000,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
6823
8000
|
this.removeEventListener("daw-track-remove", this._onTrackRemoveRequest);
|
|
6824
8001
|
this.removeEventListener("daw-clip-connected", this._onClipConnected);
|
|
6825
8002
|
this.removeEventListener("daw-clip-update", this._onClipUpdate);
|
|
8003
|
+
this.removeEventListener(
|
|
8004
|
+
"daw-annotation-track-connected",
|
|
8005
|
+
this._onAnnotationTrackConnected
|
|
8006
|
+
);
|
|
8007
|
+
this.removeEventListener("daw-annotation-select", this._onAnnotationSelect);
|
|
6826
8008
|
this._childObserver?.disconnect();
|
|
6827
8009
|
this._childObserver = null;
|
|
6828
8010
|
this._trackElements.clear();
|
|
@@ -7097,7 +8279,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7097
8279
|
let clip;
|
|
7098
8280
|
if (waveformData) {
|
|
7099
8281
|
const wdRate = waveformData.sample_rate;
|
|
7100
|
-
clip = (0,
|
|
8282
|
+
clip = (0, import_core13.createClip)({
|
|
7101
8283
|
audioBuffer,
|
|
7102
8284
|
waveformData,
|
|
7103
8285
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
@@ -7110,7 +8292,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7110
8292
|
});
|
|
7111
8293
|
this._peakPipeline.cacheWaveformData(audioBuffer, waveformData);
|
|
7112
8294
|
} else {
|
|
7113
|
-
clip = (0,
|
|
8295
|
+
clip = (0, import_core13.createClipFromSeconds)({
|
|
7114
8296
|
audioBuffer,
|
|
7115
8297
|
startTime: clipDesc.start,
|
|
7116
8298
|
duration: clipDesc.duration || audioBuffer.duration,
|
|
@@ -7189,7 +8371,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7189
8371
|
const noteSpanSeconds = notes.length ? notes.reduce((max, n) => Math.max(max, n.time + n.duration), 0) : 0;
|
|
7190
8372
|
const sourceDurationSamples = Math.ceil(Math.max(noteSpanSeconds, clipDesc.duration, 1) * sr);
|
|
7191
8373
|
const requestedDurationSamples = clipDesc.duration > 0 ? Math.round(clipDesc.duration * sr) : sourceDurationSamples;
|
|
7192
|
-
const clip = (0,
|
|
8374
|
+
const clip = (0, import_core13.createClip)({
|
|
7193
8375
|
startSample: Math.round(clipDesc.start * sr),
|
|
7194
8376
|
durationSamples: requestedDurationSamples,
|
|
7195
8377
|
offsetSamples: Math.round(clipDesc.offset * sr),
|
|
@@ -7400,7 +8582,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7400
8582
|
const waveformData = await waveformDataPromise;
|
|
7401
8583
|
if (waveformData) {
|
|
7402
8584
|
const wdRate = waveformData.sample_rate;
|
|
7403
|
-
const clip2 = (0,
|
|
8585
|
+
const clip2 = (0, import_core13.createClip)({
|
|
7404
8586
|
waveformData,
|
|
7405
8587
|
startSample: Math.round(clipDesc.start * wdRate),
|
|
7406
8588
|
durationSamples: Math.round((clipDesc.duration || waveformData.duration) * wdRate),
|
|
@@ -7426,7 +8608,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7426
8608
|
this._peaksData = new Map(this._peaksData).set(clip2.id, peakData);
|
|
7427
8609
|
this._raiseZoomFloor(waveformData.scale);
|
|
7428
8610
|
if (this._tracks.has(trackId)) {
|
|
7429
|
-
const previewTrack = (0,
|
|
8611
|
+
const previewTrack = (0, import_core13.createTrack)({
|
|
7430
8612
|
name: descriptor.name,
|
|
7431
8613
|
clips: [clip2],
|
|
7432
8614
|
volume: descriptor.volume,
|
|
@@ -7503,7 +8685,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7503
8685
|
trackWasRemoved ? "removed" : "disconnected"
|
|
7504
8686
|
);
|
|
7505
8687
|
}
|
|
7506
|
-
const track = (0,
|
|
8688
|
+
const track = (0, import_core13.createTrack)({
|
|
7507
8689
|
name: descriptor.name,
|
|
7508
8690
|
clips,
|
|
7509
8691
|
volume: descriptor.volume,
|
|
@@ -7659,6 +8841,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7659
8841
|
});
|
|
7660
8842
|
syncPeaksForChangedClips(this, audioTracks);
|
|
7661
8843
|
}
|
|
8844
|
+
if (engineState.bpm !== this._lastAnnotationBpm) {
|
|
8845
|
+
this._lastAnnotationBpm = engineState.bpm;
|
|
8846
|
+
this._annotations.deriveSecondsCaches();
|
|
8847
|
+
}
|
|
7662
8848
|
});
|
|
7663
8849
|
engine.on("pause", () => {
|
|
7664
8850
|
this._currentTime = engine.getCurrentTime();
|
|
@@ -7666,6 +8852,10 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7666
8852
|
engine.on("stop", () => {
|
|
7667
8853
|
this._currentTime = engine.getCurrentTime();
|
|
7668
8854
|
this._stopPlayhead();
|
|
8855
|
+
this._activePlayEndTime = null;
|
|
8856
|
+
if (!this._inConsumerStop && !this._inSeekTransition && this.isConnected) {
|
|
8857
|
+
this.dispatchEvent(new CustomEvent("daw-stop", { bubbles: true, composed: true }));
|
|
8858
|
+
}
|
|
7669
8859
|
});
|
|
7670
8860
|
this._engine = engine;
|
|
7671
8861
|
return engine;
|
|
@@ -7966,14 +9156,21 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7966
9156
|
return clipEl;
|
|
7967
9157
|
}
|
|
7968
9158
|
// --- Playback ---
|
|
7969
|
-
|
|
9159
|
+
/**
|
|
9160
|
+
* Start playback, optionally seeking to `startTime` first. When `endTime`
|
|
9161
|
+
* is provided, playback stops at that time (selection/annotation playback).
|
|
9162
|
+
*/
|
|
9163
|
+
async play(startTime, endTime) {
|
|
7970
9164
|
try {
|
|
7971
9165
|
const engine = await this._ensureEngine();
|
|
7972
9166
|
await engine.init();
|
|
7973
|
-
|
|
9167
|
+
this._activePlayEndTime = endTime ?? null;
|
|
7974
9168
|
this._startPlayhead();
|
|
9169
|
+
engine.play(startTime, endTime);
|
|
7975
9170
|
this.dispatchEvent(new CustomEvent("daw-play", { bubbles: true, composed: true }));
|
|
7976
9171
|
} catch (err) {
|
|
9172
|
+
this._stopPlayhead();
|
|
9173
|
+
this._activePlayEndTime = null;
|
|
7977
9174
|
console.warn("[dawcore] Playback failed: " + String(err));
|
|
7978
9175
|
this.dispatchEvent(
|
|
7979
9176
|
new CustomEvent("daw-error", {
|
|
@@ -7992,7 +9189,13 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
7992
9189
|
}
|
|
7993
9190
|
stop() {
|
|
7994
9191
|
if (!this._engine) return;
|
|
7995
|
-
this.
|
|
9192
|
+
this._activePlayEndTime = null;
|
|
9193
|
+
this._inConsumerStop = true;
|
|
9194
|
+
try {
|
|
9195
|
+
this._engine.stop();
|
|
9196
|
+
} finally {
|
|
9197
|
+
this._inConsumerStop = false;
|
|
9198
|
+
}
|
|
7996
9199
|
this._stopPlayhead();
|
|
7997
9200
|
this.dispatchEvent(new CustomEvent("daw-stop", { bubbles: true, composed: true }));
|
|
7998
9201
|
}
|
|
@@ -8046,6 +9249,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8046
9249
|
);
|
|
8047
9250
|
return;
|
|
8048
9251
|
}
|
|
9252
|
+
this._activePlayEndTime = null;
|
|
8049
9253
|
this._currentTime = target;
|
|
8050
9254
|
this._startPlayhead();
|
|
8051
9255
|
} else {
|
|
@@ -8213,16 +9417,16 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8213
9417
|
const { left, width: w } = this._previewPosition(rs.startSample, audibleSamples);
|
|
8214
9418
|
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
8215
9419
|
const height = hdrH + chH * rs.peaks.length;
|
|
8216
|
-
return
|
|
9420
|
+
return import_lit19.html`<div
|
|
8217
9421
|
class="clip-container recording-preview"
|
|
8218
9422
|
style="left:${left}px;top:0;width:${w}px;height:${height}px;"
|
|
8219
9423
|
>
|
|
8220
|
-
${hdrH > 0 ?
|
|
9424
|
+
${hdrH > 0 ? import_lit19.html`<div class="clip-header" data-track-id=${trackId}>
|
|
8221
9425
|
<span>${rs.clipName ?? "Recording\u2026"}</span>
|
|
8222
9426
|
</div>` : ""}
|
|
8223
9427
|
${rs.peaks.map((chPeaks, ch) => {
|
|
8224
9428
|
const slicedPeaks = latencyPixels > 0 ? chPeaks.slice(latencyPixels * 2) : chPeaks;
|
|
8225
|
-
return
|
|
9429
|
+
return import_lit19.html`
|
|
8226
9430
|
<daw-waveform
|
|
8227
9431
|
data-recording-track=${trackId}
|
|
8228
9432
|
data-recording-channel=${ch}
|
|
@@ -8245,6 +9449,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8245
9449
|
if (!this._engine) return;
|
|
8246
9450
|
const engine = this._engine;
|
|
8247
9451
|
this._playbackAnimation.start(() => {
|
|
9452
|
+
if (this._activePlayEndTime !== null && !this.isRecording && engine.getCurrentTime() >= this._activePlayEndTime) {
|
|
9453
|
+
this.stop();
|
|
9454
|
+
const t = this._currentTime;
|
|
9455
|
+
return Number.isFinite(t) ? Math.max(0, t) : 0;
|
|
9456
|
+
}
|
|
8248
9457
|
if (!this.indefinitePlayback && !this.isRecording && engine.getCurrentTime() >= this._duration) {
|
|
8249
9458
|
this.stop();
|
|
8250
9459
|
const t = this._currentTime;
|
|
@@ -8312,9 +9521,9 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8312
9521
|
});
|
|
8313
9522
|
const showControls = this._showControls;
|
|
8314
9523
|
const showRuler = this._showRuler;
|
|
8315
|
-
return
|
|
8316
|
-
${showRuler ?
|
|
8317
|
-
${showControls ?
|
|
9524
|
+
return import_lit19.html`
|
|
9525
|
+
${showRuler ? import_lit19.html`<div class="header-row" style="height: ${RULER_HEIGHT}px;">
|
|
9526
|
+
${showControls ? import_lit19.html`<div class="ruler-gap"></div>` : ""}
|
|
8318
9527
|
<div class="ruler-viewport" @pointerdown=${this._pointer.onPointerDown}>
|
|
8319
9528
|
<div
|
|
8320
9529
|
class="ruler-content"
|
|
@@ -8335,10 +9544,18 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8335
9544
|
</div>
|
|
8336
9545
|
</div>` : ""}
|
|
8337
9546
|
<div class="body">
|
|
8338
|
-
${showControls ?
|
|
9547
|
+
${showControls ? import_lit19.html`<div class="controls-viewport">
|
|
8339
9548
|
<div class="controls-column">
|
|
9549
|
+
${this._annotations.tracks.map(
|
|
9550
|
+
(track) => import_lit19.html`<div
|
|
9551
|
+
class="annotation-lane-spacer"
|
|
9552
|
+
style="height: ${ANNOTATION_LANE_HEIGHT}px;"
|
|
9553
|
+
>
|
|
9554
|
+
<span class="annotation-lane-name">${track.name}</span>
|
|
9555
|
+
</div>`
|
|
9556
|
+
)}
|
|
8340
9557
|
${orderedTracks.map(
|
|
8341
|
-
(t) =>
|
|
9558
|
+
(t) => import_lit19.html`
|
|
8342
9559
|
<daw-track-controls
|
|
8343
9560
|
style="height: ${t.trackHeight}px;"
|
|
8344
9561
|
.trackId=${t.trackId}
|
|
@@ -8362,8 +9579,14 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8362
9579
|
@dragleave=${this._onDragLeave}
|
|
8363
9580
|
@drop=${this._onDrop}
|
|
8364
9581
|
>
|
|
8365
|
-
${this.
|
|
8366
|
-
|
|
9582
|
+
${this._annotations.renderLanes(
|
|
9583
|
+
spp,
|
|
9584
|
+
this.effectiveSampleRate,
|
|
9585
|
+
this._annotationDrag.onPointerDown,
|
|
9586
|
+
this.scaleMode === "beats" ? this.ticksPerPixel : null
|
|
9587
|
+
)}
|
|
9588
|
+
${this.scaleMode === "beats" ? import_lit19.html`<daw-grid
|
|
9589
|
+
style="top: ${this._annotations.totalLaneHeight}px;"
|
|
8367
9590
|
.ticksPerPixel=${this.ticksPerPixel}
|
|
8368
9591
|
.meterEntries=${this._meterEntries}
|
|
8369
9592
|
.ppqn=${this.ppqn}
|
|
@@ -8372,11 +9595,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8372
9595
|
.length=${this._totalWidth}
|
|
8373
9596
|
.height=${orderedTracks.length > 0 ? orderedTracks.reduce((sum, t) => sum + t.trackHeight, 0) : this._emptyGridHeight}
|
|
8374
9597
|
></daw-grid>` : ""}
|
|
8375
|
-
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ?
|
|
9598
|
+
${orderedTracks.length > 0 || this.scaleMode === "beats" || this.indefinitePlayback || this.fillViewport ? import_lit19.html`<daw-selection .startPx=${selStartPx} .endPx=${selEndPx}></daw-selection>
|
|
8376
9599
|
<daw-playhead></daw-playhead>` : ""}
|
|
8377
9600
|
${orderedTracks.map((t) => {
|
|
8378
9601
|
const channelHeight = this.waveHeight;
|
|
8379
|
-
return
|
|
9602
|
+
return import_lit19.html`
|
|
8380
9603
|
<div
|
|
8381
9604
|
class="track-row ${t.trackId === this._selectedTrackId ? "selected" : ""}"
|
|
8382
9605
|
style="height: ${t.trackHeight}px;"
|
|
@@ -8395,7 +9618,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8395
9618
|
width = Math.round(endTick / this.ticksPerPixel) - clipLeft;
|
|
8396
9619
|
} else {
|
|
8397
9620
|
clipLeft = Math.floor(clip.startSample / spp);
|
|
8398
|
-
width = (0,
|
|
9621
|
+
width = (0, import_core13.clipPixelWidth)(clip.startSample, clip.durationSamples, spp);
|
|
8399
9622
|
}
|
|
8400
9623
|
let clipSegments;
|
|
8401
9624
|
let segmentChannels;
|
|
@@ -8442,12 +9665,12 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8442
9665
|
const channels = segmentChannels ?? peakData?.data ?? [new Int16Array(0)];
|
|
8443
9666
|
const hdrH = this.clipHeaders ? this.clipHeaderHeight : 0;
|
|
8444
9667
|
const chH = this.waveHeight;
|
|
8445
|
-
return
|
|
9668
|
+
return import_lit19.html` <div
|
|
8446
9669
|
class="clip-container"
|
|
8447
9670
|
style="left:${clipLeft}px;top:0;width:${width}px;height:${t.trackHeight}px;"
|
|
8448
9671
|
data-clip-id=${clip.id}
|
|
8449
9672
|
>
|
|
8450
|
-
${hdrH > 0 ?
|
|
9673
|
+
${hdrH > 0 ? import_lit19.html`<div
|
|
8451
9674
|
class="clip-header"
|
|
8452
9675
|
data-clip-id=${clip.id}
|
|
8453
9676
|
data-track-id=${t.trackId}
|
|
@@ -8455,7 +9678,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8455
9678
|
>
|
|
8456
9679
|
<span>${clip.name || t.descriptor?.name || ""}</span>
|
|
8457
9680
|
</div>` : ""}
|
|
8458
|
-
${t.descriptor?.renderMode === "piano-roll" ?
|
|
9681
|
+
${t.descriptor?.renderMode === "piano-roll" ? import_lit19.html`<daw-piano-roll
|
|
8459
9682
|
style="position:absolute;left:0;top:${hdrH}px;"
|
|
8460
9683
|
.midiNotes=${clip.midiNotes ?? []}
|
|
8461
9684
|
.length=${peakData?.length ?? width}
|
|
@@ -8468,7 +9691,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8468
9691
|
.originX=${clipLeft}
|
|
8469
9692
|
?selected=${t.trackId === this._selectedTrackId}
|
|
8470
9693
|
></daw-piano-roll>` : t.descriptor?.renderMode === "spectrogram" ? channels.map(
|
|
8471
|
-
(_chPeaks, chIdx) =>
|
|
9694
|
+
(_chPeaks, chIdx) => import_lit19.html`<daw-spectrogram
|
|
8472
9695
|
style="position:absolute;left:0;top:${hdrH + chIdx * chH}px;height:${chH}px;width:${peakData?.length ?? width}px;"
|
|
8473
9696
|
.clipId=${clip.id}
|
|
8474
9697
|
.trackId=${t.trackId}
|
|
@@ -8483,7 +9706,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8483
9706
|
.originX=${clipLeft}
|
|
8484
9707
|
></daw-spectrogram>`
|
|
8485
9708
|
) : channels.map(
|
|
8486
|
-
(chPeaks, chIdx) =>
|
|
9709
|
+
(chPeaks, chIdx) => import_lit19.html` <daw-waveform
|
|
8487
9710
|
style="position:absolute;left:0;top:${hdrH + chIdx * chH}px;"
|
|
8488
9711
|
.peaks=${chPeaks}
|
|
8489
9712
|
.length=${peakData?.length ?? width}
|
|
@@ -8497,7 +9720,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8497
9720
|
.segments=${clipSegments}
|
|
8498
9721
|
></daw-waveform>`
|
|
8499
9722
|
)}
|
|
8500
|
-
${this.interactiveClips ?
|
|
9723
|
+
${this.interactiveClips ? import_lit19.html` <div
|
|
8501
9724
|
class="clip-boundary"
|
|
8502
9725
|
data-boundary-edge="left"
|
|
8503
9726
|
data-clip-id=${clip.id}
|
|
@@ -8524,7 +9747,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
|
|
|
8524
9747
|
};
|
|
8525
9748
|
DawEditorElement.styles = [
|
|
8526
9749
|
hostStyles,
|
|
8527
|
-
|
|
9750
|
+
import_lit19.css`
|
|
8528
9751
|
:host {
|
|
8529
9752
|
display: flex;
|
|
8530
9753
|
flex-direction: column;
|
|
@@ -8595,120 +9818,186 @@ DawEditorElement.styles = [
|
|
|
8595
9818
|
outline: 2px dashed var(--daw-selection-color, rgba(99, 199, 95, 0.3));
|
|
8596
9819
|
outline-offset: -2px;
|
|
8597
9820
|
}
|
|
9821
|
+
.annotation-lane {
|
|
9822
|
+
position: relative;
|
|
9823
|
+
box-sizing: border-box;
|
|
9824
|
+
border-bottom: 1px solid var(--daw-annotation-lane-border, rgba(255, 255, 255, 0.08));
|
|
9825
|
+
background: var(--daw-annotation-lane-background, rgba(0, 0, 0, 0.15));
|
|
9826
|
+
user-select: none;
|
|
9827
|
+
-webkit-user-drag: none;
|
|
9828
|
+
}
|
|
9829
|
+
.annotation-lane-spacer {
|
|
9830
|
+
box-sizing: border-box;
|
|
9831
|
+
border-bottom: 1px solid var(--daw-annotation-lane-border, rgba(255, 255, 255, 0.08));
|
|
9832
|
+
display: flex;
|
|
9833
|
+
align-items: center;
|
|
9834
|
+
overflow: hidden;
|
|
9835
|
+
}
|
|
9836
|
+
.annotation-lane-name {
|
|
9837
|
+
padding: 0 10px;
|
|
9838
|
+
font-size: 11px;
|
|
9839
|
+
color: var(--daw-controls-text, #e0d4c8);
|
|
9840
|
+
opacity: 0.8;
|
|
9841
|
+
white-space: nowrap;
|
|
9842
|
+
overflow: hidden;
|
|
9843
|
+
text-overflow: ellipsis;
|
|
9844
|
+
}
|
|
9845
|
+
.annotation-box {
|
|
9846
|
+
position: absolute;
|
|
9847
|
+
top: 3px;
|
|
9848
|
+
bottom: 3px;
|
|
9849
|
+
overflow: hidden;
|
|
9850
|
+
display: flex;
|
|
9851
|
+
align-items: center;
|
|
9852
|
+
border: 1px solid var(--daw-annotation-box-border, #c49a6c);
|
|
9853
|
+
border-radius: 3px;
|
|
9854
|
+
background: var(--daw-annotation-box-background, rgba(196, 154, 108, 0.2));
|
|
9855
|
+
color: var(--daw-annotation-text-color, #e0d4c8);
|
|
9856
|
+
font-size: 11px;
|
|
9857
|
+
cursor: pointer;
|
|
9858
|
+
}
|
|
9859
|
+
.annotation-box.playing {
|
|
9860
|
+
box-shadow: inset 0 0 0 1px var(--daw-annotation-box-border, #c49a6c);
|
|
9861
|
+
background: var(--daw-annotation-playing-background, rgba(196, 154, 108, 0.32));
|
|
9862
|
+
}
|
|
9863
|
+
.annotation-box.active {
|
|
9864
|
+
background: var(--daw-annotation-active-background, rgba(196, 154, 108, 0.45));
|
|
9865
|
+
}
|
|
9866
|
+
.annotation-box-text {
|
|
9867
|
+
padding: 0 6px;
|
|
9868
|
+
white-space: nowrap;
|
|
9869
|
+
overflow: hidden;
|
|
9870
|
+
text-overflow: ellipsis;
|
|
9871
|
+
pointer-events: none;
|
|
9872
|
+
}
|
|
9873
|
+
.annotation-boundary {
|
|
9874
|
+
position: absolute;
|
|
9875
|
+
top: 0;
|
|
9876
|
+
bottom: 0;
|
|
9877
|
+
width: 6px;
|
|
9878
|
+
cursor: ew-resize;
|
|
9879
|
+
flex-shrink: 0;
|
|
9880
|
+
}
|
|
9881
|
+
.annotation-boundary[data-edge='start'] {
|
|
9882
|
+
left: 0;
|
|
9883
|
+
}
|
|
9884
|
+
.annotation-boundary[data-edge='end'] {
|
|
9885
|
+
right: 0;
|
|
9886
|
+
}
|
|
8598
9887
|
`,
|
|
8599
9888
|
clipStyles
|
|
8600
9889
|
];
|
|
8601
9890
|
DawEditorElement._CONTROL_PROPS = /* @__PURE__ */ new Set(["volume", "pan", "muted", "soloed"]);
|
|
8602
9891
|
__decorateClass([
|
|
8603
|
-
(0,
|
|
9892
|
+
(0, import_decorators16.property)({ type: Number, attribute: "samples-per-pixel", noAccessor: true })
|
|
8604
9893
|
], DawEditorElement.prototype, "samplesPerPixel", 1);
|
|
8605
9894
|
__decorateClass([
|
|
8606
|
-
(0,
|
|
9895
|
+
(0, import_decorators16.property)({ attribute: "time-format", reflect: true, noAccessor: true })
|
|
8607
9896
|
], DawEditorElement.prototype, "timeFormat", 1);
|
|
8608
9897
|
__decorateClass([
|
|
8609
|
-
(0,
|
|
9898
|
+
(0, import_decorators16.property)({ type: Number, attribute: "wave-height" })
|
|
8610
9899
|
], DawEditorElement.prototype, "waveHeight", 2);
|
|
8611
9900
|
__decorateClass([
|
|
8612
|
-
(0,
|
|
9901
|
+
(0, import_decorators16.property)({ type: Boolean })
|
|
8613
9902
|
], DawEditorElement.prototype, "timescale", 2);
|
|
8614
9903
|
__decorateClass([
|
|
8615
|
-
(0,
|
|
9904
|
+
(0, import_decorators16.property)({ type: Boolean })
|
|
8616
9905
|
], DawEditorElement.prototype, "mono", 2);
|
|
8617
9906
|
__decorateClass([
|
|
8618
|
-
(0,
|
|
9907
|
+
(0, import_decorators16.property)({ type: Number, attribute: "bar-width" })
|
|
8619
9908
|
], DawEditorElement.prototype, "barWidth", 2);
|
|
8620
9909
|
__decorateClass([
|
|
8621
|
-
(0,
|
|
9910
|
+
(0, import_decorators16.property)({ type: Number, attribute: "bar-gap" })
|
|
8622
9911
|
], DawEditorElement.prototype, "barGap", 2);
|
|
8623
9912
|
__decorateClass([
|
|
8624
|
-
(0,
|
|
9913
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
8625
9914
|
], DawEditorElement.prototype, "roundedBars", 2);
|
|
8626
9915
|
__decorateClass([
|
|
8627
|
-
(0,
|
|
9916
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "file-drop" })
|
|
8628
9917
|
], DawEditorElement.prototype, "fileDrop", 2);
|
|
8629
9918
|
__decorateClass([
|
|
8630
|
-
(0,
|
|
9919
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "clip-headers" })
|
|
8631
9920
|
], DawEditorElement.prototype, "clipHeaders", 2);
|
|
8632
9921
|
__decorateClass([
|
|
8633
|
-
(0,
|
|
9922
|
+
(0, import_decorators16.property)({ type: Number, attribute: "clip-header-height" })
|
|
8634
9923
|
], DawEditorElement.prototype, "clipHeaderHeight", 2);
|
|
8635
9924
|
__decorateClass([
|
|
8636
|
-
(0,
|
|
9925
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "interactive-clips" })
|
|
8637
9926
|
], DawEditorElement.prototype, "interactiveClips", 2);
|
|
8638
9927
|
__decorateClass([
|
|
8639
|
-
(0,
|
|
9928
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "indefinite-playback" })
|
|
8640
9929
|
], DawEditorElement.prototype, "indefinitePlayback", 2);
|
|
8641
9930
|
__decorateClass([
|
|
8642
|
-
(0,
|
|
9931
|
+
(0, import_decorators16.property)({ type: Boolean, attribute: "fill-viewport" })
|
|
8643
9932
|
], DawEditorElement.prototype, "fillViewport", 2);
|
|
8644
9933
|
__decorateClass([
|
|
8645
|
-
(0,
|
|
9934
|
+
(0, import_decorators16.property)({ attribute: false, noAccessor: true })
|
|
8646
9935
|
], DawEditorElement.prototype, "spectrogramConfig", 1);
|
|
8647
9936
|
__decorateClass([
|
|
8648
|
-
(0,
|
|
9937
|
+
(0, import_decorators16.property)({ attribute: false, noAccessor: true })
|
|
8649
9938
|
], DawEditorElement.prototype, "spectrogramColorMap", 1);
|
|
8650
9939
|
__decorateClass([
|
|
8651
|
-
(0,
|
|
9940
|
+
(0, import_decorators16.property)({ type: String, attribute: "scale-mode" })
|
|
8652
9941
|
], DawEditorElement.prototype, "scaleMode", 2);
|
|
8653
9942
|
__decorateClass([
|
|
8654
|
-
(0,
|
|
9943
|
+
(0, import_decorators16.property)({ type: Number, attribute: "ticks-per-pixel", noAccessor: true })
|
|
8655
9944
|
], DawEditorElement.prototype, "ticksPerPixel", 1);
|
|
8656
9945
|
__decorateClass([
|
|
8657
|
-
(0,
|
|
9946
|
+
(0, import_decorators16.property)({ type: Number, noAccessor: true })
|
|
8658
9947
|
], DawEditorElement.prototype, "bpm", 1);
|
|
8659
9948
|
__decorateClass([
|
|
8660
|
-
(0,
|
|
9949
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8661
9950
|
], DawEditorElement.prototype, "timeSignature", 2);
|
|
8662
9951
|
__decorateClass([
|
|
8663
|
-
(0,
|
|
9952
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8664
9953
|
], DawEditorElement.prototype, "meterEntries", 2);
|
|
8665
9954
|
__decorateClass([
|
|
8666
|
-
(0,
|
|
9955
|
+
(0, import_decorators16.property)({ type: Number, noAccessor: true })
|
|
8667
9956
|
], DawEditorElement.prototype, "ppqn", 1);
|
|
8668
9957
|
__decorateClass([
|
|
8669
|
-
(0,
|
|
9958
|
+
(0, import_decorators16.property)({ type: String, attribute: "snap-to" })
|
|
8670
9959
|
], DawEditorElement.prototype, "snapTo", 2);
|
|
8671
9960
|
__decorateClass([
|
|
8672
|
-
(0,
|
|
9961
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8673
9962
|
], DawEditorElement.prototype, "secondsToTicks", 2);
|
|
8674
9963
|
__decorateClass([
|
|
8675
|
-
(0,
|
|
9964
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8676
9965
|
], DawEditorElement.prototype, "ticksToSeconds", 2);
|
|
8677
9966
|
__decorateClass([
|
|
8678
|
-
(0,
|
|
9967
|
+
(0, import_decorators16.state)()
|
|
8679
9968
|
], DawEditorElement.prototype, "_tracks", 2);
|
|
8680
9969
|
__decorateClass([
|
|
8681
|
-
(0,
|
|
9970
|
+
(0, import_decorators16.state)()
|
|
8682
9971
|
], DawEditorElement.prototype, "_engineTracks", 2);
|
|
8683
9972
|
__decorateClass([
|
|
8684
|
-
(0,
|
|
9973
|
+
(0, import_decorators16.state)()
|
|
8685
9974
|
], DawEditorElement.prototype, "_peaksData", 2);
|
|
8686
9975
|
__decorateClass([
|
|
8687
|
-
(0,
|
|
9976
|
+
(0, import_decorators16.state)()
|
|
8688
9977
|
], DawEditorElement.prototype, "_isPlaying", 2);
|
|
8689
9978
|
__decorateClass([
|
|
8690
|
-
(0,
|
|
9979
|
+
(0, import_decorators16.state)()
|
|
8691
9980
|
], DawEditorElement.prototype, "_duration", 2);
|
|
8692
9981
|
__decorateClass([
|
|
8693
|
-
(0,
|
|
9982
|
+
(0, import_decorators16.state)()
|
|
8694
9983
|
], DawEditorElement.prototype, "_selectedTrackId", 2);
|
|
8695
9984
|
__decorateClass([
|
|
8696
|
-
(0,
|
|
9985
|
+
(0, import_decorators16.state)()
|
|
8697
9986
|
], DawEditorElement.prototype, "_dragOver", 2);
|
|
8698
9987
|
__decorateClass([
|
|
8699
|
-
(0,
|
|
9988
|
+
(0, import_decorators16.property)({ attribute: false })
|
|
8700
9989
|
], DawEditorElement.prototype, "adapter", 1);
|
|
8701
9990
|
__decorateClass([
|
|
8702
|
-
(0,
|
|
9991
|
+
(0, import_decorators16.property)({ attribute: "eager-resume" })
|
|
8703
9992
|
], DawEditorElement.prototype, "eagerResume", 2);
|
|
8704
9993
|
DawEditorElement = __decorateClass([
|
|
8705
|
-
(0,
|
|
9994
|
+
(0, import_decorators16.customElement)("daw-editor")
|
|
8706
9995
|
], DawEditorElement);
|
|
8707
9996
|
|
|
8708
9997
|
// src/elements/daw-selection.ts
|
|
8709
|
-
var
|
|
8710
|
-
var
|
|
8711
|
-
var DawSelectionElement = class extends
|
|
9998
|
+
var import_lit20 = require("lit");
|
|
9999
|
+
var import_decorators17 = require("lit/decorators.js");
|
|
10000
|
+
var DawSelectionElement = class extends import_lit20.LitElement {
|
|
8712
10001
|
constructor() {
|
|
8713
10002
|
super(...arguments);
|
|
8714
10003
|
this.startPx = 0;
|
|
@@ -8717,11 +10006,11 @@ var DawSelectionElement = class extends import_lit16.LitElement {
|
|
|
8717
10006
|
render() {
|
|
8718
10007
|
const left = Math.min(this.startPx, this.endPx);
|
|
8719
10008
|
const width = Math.abs(this.endPx - this.startPx);
|
|
8720
|
-
if (width === 0) return
|
|
8721
|
-
return
|
|
10009
|
+
if (width === 0) return import_lit20.html``;
|
|
10010
|
+
return import_lit20.html`<div style="left: ${left}px; width: ${width}px;"></div>`;
|
|
8722
10011
|
}
|
|
8723
10012
|
};
|
|
8724
|
-
DawSelectionElement.styles =
|
|
10013
|
+
DawSelectionElement.styles = import_lit20.css`
|
|
8725
10014
|
:host {
|
|
8726
10015
|
position: absolute;
|
|
8727
10016
|
top: 0;
|
|
@@ -8738,18 +10027,18 @@ DawSelectionElement.styles = import_lit16.css`
|
|
|
8738
10027
|
}
|
|
8739
10028
|
`;
|
|
8740
10029
|
__decorateClass([
|
|
8741
|
-
(0,
|
|
10030
|
+
(0, import_decorators17.property)({ type: Number, attribute: false })
|
|
8742
10031
|
], DawSelectionElement.prototype, "startPx", 2);
|
|
8743
10032
|
__decorateClass([
|
|
8744
|
-
(0,
|
|
10033
|
+
(0, import_decorators17.property)({ type: Number, attribute: false })
|
|
8745
10034
|
], DawSelectionElement.prototype, "endPx", 2);
|
|
8746
10035
|
DawSelectionElement = __decorateClass([
|
|
8747
|
-
(0,
|
|
10036
|
+
(0, import_decorators17.customElement)("daw-selection")
|
|
8748
10037
|
], DawSelectionElement);
|
|
8749
10038
|
|
|
8750
10039
|
// src/elements/daw-record-button.ts
|
|
8751
|
-
var
|
|
8752
|
-
var
|
|
10040
|
+
var import_lit21 = require("lit");
|
|
10041
|
+
var import_decorators18 = require("lit/decorators.js");
|
|
8753
10042
|
var DawRecordButtonElement = class extends DawTransportButton {
|
|
8754
10043
|
constructor() {
|
|
8755
10044
|
super(...arguments);
|
|
@@ -8798,7 +10087,7 @@ var DawRecordButtonElement = class extends DawTransportButton {
|
|
|
8798
10087
|
}
|
|
8799
10088
|
}
|
|
8800
10089
|
render() {
|
|
8801
|
-
return
|
|
10090
|
+
return import_lit21.html`
|
|
8802
10091
|
<button
|
|
8803
10092
|
part="button"
|
|
8804
10093
|
?disabled=${!this.targetSupported}
|
|
@@ -8826,7 +10115,7 @@ DawRecordButtonElement.requiredTargetMethods = [
|
|
|
8826
10115
|
];
|
|
8827
10116
|
DawRecordButtonElement.styles = [
|
|
8828
10117
|
DawTransportButton.styles,
|
|
8829
|
-
|
|
10118
|
+
import_lit21.css`
|
|
8830
10119
|
button[data-recording] {
|
|
8831
10120
|
color: #d08070;
|
|
8832
10121
|
border-color: #d08070;
|
|
@@ -8835,17 +10124,17 @@ DawRecordButtonElement.styles = [
|
|
|
8835
10124
|
`
|
|
8836
10125
|
];
|
|
8837
10126
|
__decorateClass([
|
|
8838
|
-
(0,
|
|
10127
|
+
(0, import_decorators18.state)()
|
|
8839
10128
|
], DawRecordButtonElement.prototype, "_isRecording", 2);
|
|
8840
10129
|
DawRecordButtonElement = __decorateClass([
|
|
8841
|
-
(0,
|
|
10130
|
+
(0, import_decorators18.customElement)("daw-record-button")
|
|
8842
10131
|
], DawRecordButtonElement);
|
|
8843
10132
|
|
|
8844
10133
|
// src/elements/daw-keyboard-shortcuts.ts
|
|
8845
|
-
var
|
|
8846
|
-
var
|
|
8847
|
-
var
|
|
8848
|
-
var DawKeyboardShortcutsElement = class extends
|
|
10134
|
+
var import_lit22 = require("lit");
|
|
10135
|
+
var import_decorators19 = require("lit/decorators.js");
|
|
10136
|
+
var import_core14 = require("@waveform-playlist/core");
|
|
10137
|
+
var DawKeyboardShortcutsElement = class extends import_lit22.LitElement {
|
|
8849
10138
|
constructor() {
|
|
8850
10139
|
super(...arguments);
|
|
8851
10140
|
this.playback = false;
|
|
@@ -8869,7 +10158,7 @@ var DawKeyboardShortcutsElement = class extends import_lit18.LitElement {
|
|
|
8869
10158
|
const shortcuts = this.shortcuts;
|
|
8870
10159
|
if (shortcuts.length === 0) return;
|
|
8871
10160
|
try {
|
|
8872
|
-
(0,
|
|
10161
|
+
(0, import_core14.handleKeyboardEvent)(e, shortcuts, true);
|
|
8873
10162
|
} catch (err) {
|
|
8874
10163
|
console.warn("[dawcore] Keyboard shortcut failed (key=" + e.key + "): " + String(err));
|
|
8875
10164
|
const target = this._editor ?? this;
|
|
@@ -9044,23 +10333,23 @@ var DawKeyboardShortcutsElement = class extends import_lit18.LitElement {
|
|
|
9044
10333
|
}
|
|
9045
10334
|
};
|
|
9046
10335
|
__decorateClass([
|
|
9047
|
-
(0,
|
|
10336
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9048
10337
|
], DawKeyboardShortcutsElement.prototype, "playback", 2);
|
|
9049
10338
|
__decorateClass([
|
|
9050
|
-
(0,
|
|
10339
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9051
10340
|
], DawKeyboardShortcutsElement.prototype, "splitting", 2);
|
|
9052
10341
|
__decorateClass([
|
|
9053
|
-
(0,
|
|
10342
|
+
(0, import_decorators19.property)({ type: Boolean })
|
|
9054
10343
|
], DawKeyboardShortcutsElement.prototype, "undo", 2);
|
|
9055
10344
|
DawKeyboardShortcutsElement = __decorateClass([
|
|
9056
|
-
(0,
|
|
10345
|
+
(0, import_decorators19.customElement)("daw-keyboard-shortcuts")
|
|
9057
10346
|
], DawKeyboardShortcutsElement);
|
|
9058
10347
|
|
|
9059
10348
|
// src/elements/daw-spectrogram.ts
|
|
9060
|
-
var
|
|
9061
|
-
var
|
|
9062
|
-
var
|
|
9063
|
-
var DawSpectrogramElement = class extends
|
|
10349
|
+
var import_lit23 = require("lit");
|
|
10350
|
+
var import_decorators20 = require("lit/decorators.js");
|
|
10351
|
+
var import_core15 = require("@waveform-playlist/core");
|
|
10352
|
+
var DawSpectrogramElement = class extends import_lit23.LitElement {
|
|
9064
10353
|
constructor() {
|
|
9065
10354
|
super(...arguments);
|
|
9066
10355
|
this.clipId = "";
|
|
@@ -9124,11 +10413,11 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9124
10413
|
this._unregisterAllCanvases();
|
|
9125
10414
|
this._canvases = [];
|
|
9126
10415
|
if (this.length <= 0) return;
|
|
9127
|
-
const chunkCount = Math.ceil(this.length /
|
|
10416
|
+
const chunkCount = Math.ceil(this.length / import_core15.MAX_CANVAS_WIDTH);
|
|
9128
10417
|
for (let i = 0; i < chunkCount; i++) {
|
|
9129
|
-
const widthPx = Math.min(
|
|
10418
|
+
const widthPx = Math.min(import_core15.MAX_CANVAS_WIDTH, this.length - i * import_core15.MAX_CANVAS_WIDTH);
|
|
9130
10419
|
const canvas = document.createElement("canvas");
|
|
9131
|
-
canvas.style.left = i *
|
|
10420
|
+
canvas.style.left = i * import_core15.MAX_CANVAS_WIDTH + "px";
|
|
9132
10421
|
canvas.style.width = widthPx + "px";
|
|
9133
10422
|
const dpr = window.devicePixelRatio || 1;
|
|
9134
10423
|
canvas.width = widthPx * dpr;
|
|
@@ -9154,7 +10443,7 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9154
10443
|
}
|
|
9155
10444
|
for (let i = 0; i < this._canvases.length; i++) {
|
|
9156
10445
|
const canvas = this._canvases[i];
|
|
9157
|
-
const canvasId = (0,
|
|
10446
|
+
const canvasId = (0, import_core15.buildSpectrogramCanvasId)({
|
|
9158
10447
|
clipId: this.clipId,
|
|
9159
10448
|
channelIndex: this.channelIndex,
|
|
9160
10449
|
chunkIndex: i
|
|
@@ -9175,7 +10464,7 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9175
10464
|
trackId: this.trackId,
|
|
9176
10465
|
channelIndex: this.channelIndex,
|
|
9177
10466
|
chunkIndex: i,
|
|
9178
|
-
globalPixelOffset: this.originX + i *
|
|
10467
|
+
globalPixelOffset: this.originX + i * import_core15.MAX_CANVAS_WIDTH,
|
|
9179
10468
|
widthPx: parseFloat(canvas.style.width),
|
|
9180
10469
|
heightPx: this.waveHeight
|
|
9181
10470
|
});
|
|
@@ -9196,10 +10485,10 @@ var DawSpectrogramElement = class extends import_lit19.LitElement {
|
|
|
9196
10485
|
this._unregisterAllCanvases();
|
|
9197
10486
|
}
|
|
9198
10487
|
render() {
|
|
9199
|
-
return
|
|
10488
|
+
return import_lit23.html`${this._canvases.map((c) => c)}`;
|
|
9200
10489
|
}
|
|
9201
10490
|
};
|
|
9202
|
-
DawSpectrogramElement.styles =
|
|
10491
|
+
DawSpectrogramElement.styles = import_lit23.css`
|
|
9203
10492
|
:host {
|
|
9204
10493
|
display: block;
|
|
9205
10494
|
position: relative;
|
|
@@ -9214,46 +10503,46 @@ DawSpectrogramElement.styles = import_lit19.css`
|
|
|
9214
10503
|
}
|
|
9215
10504
|
`;
|
|
9216
10505
|
__decorateClass([
|
|
9217
|
-
(0,
|
|
10506
|
+
(0, import_decorators20.property)({ attribute: false })
|
|
9218
10507
|
], DawSpectrogramElement.prototype, "clipId", 2);
|
|
9219
10508
|
__decorateClass([
|
|
9220
|
-
(0,
|
|
10509
|
+
(0, import_decorators20.property)({ attribute: false })
|
|
9221
10510
|
], DawSpectrogramElement.prototype, "trackId", 2);
|
|
9222
10511
|
__decorateClass([
|
|
9223
|
-
(0,
|
|
10512
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9224
10513
|
], DawSpectrogramElement.prototype, "channelIndex", 2);
|
|
9225
10514
|
__decorateClass([
|
|
9226
|
-
(0,
|
|
10515
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9227
10516
|
], DawSpectrogramElement.prototype, "length", 2);
|
|
9228
10517
|
__decorateClass([
|
|
9229
|
-
(0,
|
|
10518
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9230
10519
|
], DawSpectrogramElement.prototype, "waveHeight", 2);
|
|
9231
10520
|
__decorateClass([
|
|
9232
|
-
(0,
|
|
10521
|
+
(0, import_decorators20.property)({ type: Number, attribute: false, noAccessor: true })
|
|
9233
10522
|
], DawSpectrogramElement.prototype, "samplesPerPixel", 1);
|
|
9234
10523
|
__decorateClass([
|
|
9235
|
-
(0,
|
|
10524
|
+
(0, import_decorators20.property)({ type: Number, attribute: false, noAccessor: true })
|
|
9236
10525
|
], DawSpectrogramElement.prototype, "sampleRate", 1);
|
|
9237
10526
|
__decorateClass([
|
|
9238
|
-
(0,
|
|
10527
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9239
10528
|
], DawSpectrogramElement.prototype, "clipOffsetSeconds", 2);
|
|
9240
10529
|
__decorateClass([
|
|
9241
|
-
(0,
|
|
10530
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9242
10531
|
], DawSpectrogramElement.prototype, "visibleStart", 2);
|
|
9243
10532
|
__decorateClass([
|
|
9244
|
-
(0,
|
|
10533
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9245
10534
|
], DawSpectrogramElement.prototype, "visibleEnd", 2);
|
|
9246
10535
|
__decorateClass([
|
|
9247
|
-
(0,
|
|
10536
|
+
(0, import_decorators20.property)({ type: Number, attribute: false })
|
|
9248
10537
|
], DawSpectrogramElement.prototype, "originX", 2);
|
|
9249
10538
|
DawSpectrogramElement = __decorateClass([
|
|
9250
|
-
(0,
|
|
10539
|
+
(0, import_decorators20.customElement)("daw-spectrogram")
|
|
9251
10540
|
], DawSpectrogramElement);
|
|
9252
10541
|
|
|
9253
10542
|
// src/elements/daw-time-display.ts
|
|
9254
|
-
var
|
|
9255
|
-
var
|
|
9256
|
-
var DawTimeDisplayElement = class extends
|
|
10543
|
+
var import_lit24 = require("lit");
|
|
10544
|
+
var import_decorators21 = require("lit/decorators.js");
|
|
10545
|
+
var DawTimeDisplayElement = class extends import_lit24.LitElement {
|
|
9257
10546
|
constructor() {
|
|
9258
10547
|
super(...arguments);
|
|
9259
10548
|
this._time = null;
|
|
@@ -9306,10 +10595,10 @@ var DawTimeDisplayElement = class extends import_lit20.LitElement {
|
|
|
9306
10595
|
}
|
|
9307
10596
|
render() {
|
|
9308
10597
|
const text = this._time === null ? "--:--:--" : formatDisplayTime(this._time, this._format);
|
|
9309
|
-
return
|
|
10598
|
+
return import_lit24.html`<span role="status" aria-label="Playback time" aria-live="off">${text}</span>`;
|
|
9310
10599
|
}
|
|
9311
10600
|
};
|
|
9312
|
-
DawTimeDisplayElement.styles =
|
|
10601
|
+
DawTimeDisplayElement.styles = import_lit24.css`
|
|
9313
10602
|
span {
|
|
9314
10603
|
display: inline-block;
|
|
9315
10604
|
font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
|
@@ -9321,19 +10610,19 @@ DawTimeDisplayElement.styles = import_lit20.css`
|
|
|
9321
10610
|
}
|
|
9322
10611
|
`;
|
|
9323
10612
|
__decorateClass([
|
|
9324
|
-
(0,
|
|
10613
|
+
(0, import_decorators21.state)()
|
|
9325
10614
|
], DawTimeDisplayElement.prototype, "_time", 2);
|
|
9326
10615
|
__decorateClass([
|
|
9327
|
-
(0,
|
|
10616
|
+
(0, import_decorators21.state)()
|
|
9328
10617
|
], DawTimeDisplayElement.prototype, "_format", 2);
|
|
9329
10618
|
DawTimeDisplayElement = __decorateClass([
|
|
9330
|
-
(0,
|
|
10619
|
+
(0, import_decorators21.customElement)("daw-time-display")
|
|
9331
10620
|
], DawTimeDisplayElement);
|
|
9332
10621
|
|
|
9333
10622
|
// src/elements/daw-time-format.ts
|
|
9334
|
-
var
|
|
9335
|
-
var
|
|
9336
|
-
var DawTimeFormatElement = class extends
|
|
10623
|
+
var import_lit25 = require("lit");
|
|
10624
|
+
var import_decorators22 = require("lit/decorators.js");
|
|
10625
|
+
var DawTimeFormatElement = class extends import_lit25.LitElement {
|
|
9337
10626
|
constructor() {
|
|
9338
10627
|
super(...arguments);
|
|
9339
10628
|
this._format = "hh:mm:ss.sss";
|
|
@@ -9408,20 +10697,20 @@ var DawTimeFormatElement = class extends import_lit21.LitElement {
|
|
|
9408
10697
|
target.setTimeFormat?.(value);
|
|
9409
10698
|
}
|
|
9410
10699
|
render() {
|
|
9411
|
-
return
|
|
10700
|
+
return import_lit25.html`
|
|
9412
10701
|
<select
|
|
9413
10702
|
aria-label="Time format"
|
|
9414
10703
|
?disabled=${!this._targetSupported}
|
|
9415
10704
|
@change=${this._onSelectChange}
|
|
9416
10705
|
>
|
|
9417
10706
|
${TIME_DISPLAY_FORMATS.map(
|
|
9418
|
-
(f) =>
|
|
10707
|
+
(f) => import_lit25.html`<option value=${f} ?selected=${f === this._format}>${f}</option>`
|
|
9419
10708
|
)}
|
|
9420
10709
|
</select>
|
|
9421
10710
|
`;
|
|
9422
10711
|
}
|
|
9423
10712
|
};
|
|
9424
|
-
DawTimeFormatElement.styles =
|
|
10713
|
+
DawTimeFormatElement.styles = import_lit25.css`
|
|
9425
10714
|
select {
|
|
9426
10715
|
cursor: pointer;
|
|
9427
10716
|
background: var(--daw-controls-background, #1a1a2e);
|
|
@@ -9436,20 +10725,20 @@ DawTimeFormatElement.styles = import_lit21.css`
|
|
|
9436
10725
|
}
|
|
9437
10726
|
`;
|
|
9438
10727
|
__decorateClass([
|
|
9439
|
-
(0,
|
|
10728
|
+
(0, import_decorators22.state)()
|
|
9440
10729
|
], DawTimeFormatElement.prototype, "_format", 2);
|
|
9441
10730
|
DawTimeFormatElement = __decorateClass([
|
|
9442
|
-
(0,
|
|
10731
|
+
(0, import_decorators22.customElement)("daw-time-format")
|
|
9443
10732
|
], DawTimeFormatElement);
|
|
9444
10733
|
|
|
9445
10734
|
// src/elements/daw-player.ts
|
|
9446
|
-
var
|
|
9447
|
-
var
|
|
10735
|
+
var import_lit26 = require("lit");
|
|
10736
|
+
var import_decorators23 = require("lit/decorators.js");
|
|
9448
10737
|
var import_repeat = require("lit/directives/repeat.js");
|
|
9449
10738
|
var import_media_element_playout = require("@waveform-playlist/media-element-playout");
|
|
9450
10739
|
var MIN_RATE = 0.25;
|
|
9451
10740
|
var MAX_RATE = 4;
|
|
9452
|
-
var DawPlayerElement = class extends
|
|
10741
|
+
var DawPlayerElement = class extends import_lit26.LitElement {
|
|
9453
10742
|
constructor() {
|
|
9454
10743
|
super(...arguments);
|
|
9455
10744
|
this.src = "";
|
|
@@ -9557,8 +10846,8 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9557
10846
|
const width = this._timelineWidth;
|
|
9558
10847
|
const channels = this._channelPeaks.length;
|
|
9559
10848
|
const channelHeight = channels > 0 ? this.waveHeight / channels : this.waveHeight;
|
|
9560
|
-
return
|
|
9561
|
-
${this.timescale ?
|
|
10849
|
+
return import_lit26.html`
|
|
10850
|
+
${this.timescale ? import_lit26.html`<daw-ruler
|
|
9562
10851
|
.samplesPerPixel=${this._channelSpp(width)}
|
|
9563
10852
|
.sampleRate=${this._sampleRate}
|
|
9564
10853
|
.duration=${this._engine.duration}
|
|
@@ -9572,7 +10861,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9572
10861
|
${(0, import_repeat.repeat)(
|
|
9573
10862
|
this._channelPeaks,
|
|
9574
10863
|
(_p, i) => i,
|
|
9575
|
-
(peaks) =>
|
|
10864
|
+
(peaks) => import_lit26.html`<daw-waveform
|
|
9576
10865
|
.peaks=${peaks}
|
|
9577
10866
|
.length=${width}
|
|
9578
10867
|
.waveHeight=${channelHeight}
|
|
@@ -9735,7 +11024,7 @@ var DawPlayerElement = class extends import_lit22.LitElement {
|
|
|
9735
11024
|
return this.shadowRoot?.querySelector(".waveform-area")?.clientWidth ?? 0;
|
|
9736
11025
|
}
|
|
9737
11026
|
};
|
|
9738
|
-
DawPlayerElement.styles =
|
|
11027
|
+
DawPlayerElement.styles = import_lit26.css`
|
|
9739
11028
|
:host {
|
|
9740
11029
|
display: block;
|
|
9741
11030
|
position: relative;
|
|
@@ -9748,42 +11037,46 @@ DawPlayerElement.styles = import_lit22.css`
|
|
|
9748
11037
|
}
|
|
9749
11038
|
`;
|
|
9750
11039
|
__decorateClass([
|
|
9751
|
-
(0,
|
|
11040
|
+
(0, import_decorators23.property)({ type: String })
|
|
9752
11041
|
], DawPlayerElement.prototype, "src", 2);
|
|
9753
11042
|
__decorateClass([
|
|
9754
|
-
(0,
|
|
11043
|
+
(0, import_decorators23.property)({ type: String, attribute: "peaks-src" })
|
|
9755
11044
|
], DawPlayerElement.prototype, "peaksSrc", 2);
|
|
9756
11045
|
__decorateClass([
|
|
9757
|
-
(0,
|
|
11046
|
+
(0, import_decorators23.property)({ type: Number, attribute: "wave-height" })
|
|
9758
11047
|
], DawPlayerElement.prototype, "waveHeight", 2);
|
|
9759
11048
|
__decorateClass([
|
|
9760
|
-
(0,
|
|
11049
|
+
(0, import_decorators23.property)({ type: Boolean })
|
|
9761
11050
|
], DawPlayerElement.prototype, "timescale", 2);
|
|
9762
11051
|
__decorateClass([
|
|
9763
|
-
(0,
|
|
11052
|
+
(0, import_decorators23.property)({ type: Boolean })
|
|
9764
11053
|
], DawPlayerElement.prototype, "mono", 2);
|
|
9765
11054
|
__decorateClass([
|
|
9766
|
-
(0,
|
|
11055
|
+
(0, import_decorators23.property)({ type: Number, attribute: "bar-width" })
|
|
9767
11056
|
], DawPlayerElement.prototype, "barWidth", 2);
|
|
9768
11057
|
__decorateClass([
|
|
9769
|
-
(0,
|
|
11058
|
+
(0, import_decorators23.property)({ type: Number, attribute: "bar-gap" })
|
|
9770
11059
|
], DawPlayerElement.prototype, "barGap", 2);
|
|
9771
11060
|
__decorateClass([
|
|
9772
|
-
(0,
|
|
11061
|
+
(0, import_decorators23.property)({ type: Boolean, attribute: "rounded-bars" })
|
|
9773
11062
|
], DawPlayerElement.prototype, "roundedBars", 2);
|
|
9774
11063
|
__decorateClass([
|
|
9775
|
-
(0,
|
|
11064
|
+
(0, import_decorators23.property)({ type: Number, attribute: "playback-rate", noAccessor: true })
|
|
9776
11065
|
], DawPlayerElement.prototype, "playbackRate", 1);
|
|
9777
11066
|
__decorateClass([
|
|
9778
|
-
(0,
|
|
11067
|
+
(0, import_decorators23.state)()
|
|
9779
11068
|
], DawPlayerElement.prototype, "_channelPeaks", 2);
|
|
9780
11069
|
DawPlayerElement = __decorateClass([
|
|
9781
|
-
(0,
|
|
11070
|
+
(0, import_decorators23.customElement)("daw-player")
|
|
9782
11071
|
], DawPlayerElement);
|
|
9783
11072
|
// Annotate the CommonJS export names for ESM import in node:
|
|
9784
11073
|
0 && (module.exports = {
|
|
11074
|
+
ANNOTATION_LANE_HEIGHT,
|
|
9785
11075
|
AudioResumeController,
|
|
9786
11076
|
ClipPointerHandler,
|
|
11077
|
+
DawAnnotationElement,
|
|
11078
|
+
DawAnnotationListElement,
|
|
11079
|
+
DawAnnotationTrackElement,
|
|
9787
11080
|
DawClipElement,
|
|
9788
11081
|
DawEditorElement,
|
|
9789
11082
|
DawGridElement,
|