@onjmin/dtm 2.1.3 → 2.1.4
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.js +19 -13
- package/dist/index.mjs +19 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17794,8 +17794,10 @@ var createRenderer = (mountTarget, width = 800, height = 450, config) => {
|
|
|
17794
17794
|
const getXY = (e) => {
|
|
17795
17795
|
const { clientX, clientY } = e;
|
|
17796
17796
|
const rect = g_grid_canvas.getBoundingClientRect();
|
|
17797
|
-
const
|
|
17798
|
-
const
|
|
17797
|
+
const scaleX = rect.width > 0 ? g_grid_canvas.width / rect.width : 1;
|
|
17798
|
+
const scaleY = rect.height > 0 ? g_grid_canvas.height / rect.height : 1;
|
|
17799
|
+
const x2 = Math.floor((clientX - rect.left) * scaleX);
|
|
17800
|
+
const y = Math.floor((clientY - rect.top) * scaleY);
|
|
17799
17801
|
return [x2, y, e.buttons];
|
|
17800
17802
|
};
|
|
17801
17803
|
const getGridPosition = (e) => {
|
|
@@ -17829,7 +17831,7 @@ var createRenderer = (mountTarget, width = 800, height = 450, config) => {
|
|
|
17829
17831
|
const absoluteY = y + g_draw_offset_y;
|
|
17830
17832
|
const yIndex = Math.floor(absoluteY / keyHeight);
|
|
17831
17833
|
const pitch = units(pitchRangeStart + (keyCount - 1 - yIndex) * upr);
|
|
17832
|
-
if (pitch >= pitchRangeStart && pitch < pitchRangeStart + keyCount) {
|
|
17834
|
+
if (pitch >= pitchRangeStart && pitch < pitchRangeStart + keyCount * upr) {
|
|
17833
17835
|
requestAnimationFrame(() => callback(step, pitch));
|
|
17834
17836
|
}
|
|
17835
17837
|
},
|
|
@@ -19285,7 +19287,9 @@ var mountDAW = (target, options = {}) => {
|
|
|
19285
19287
|
unitsPerRow: upr = UNITS_PER_SEMITONE
|
|
19286
19288
|
} = renderConfig;
|
|
19287
19289
|
const offset = renderer.getDrawOffset();
|
|
19288
|
-
|
|
19290
|
+
const notes = active.core.getNotes();
|
|
19291
|
+
for (let i2 = notes.length - 1; i2 >= 0; i2--) {
|
|
19292
|
+
const note = notes[i2];
|
|
19289
19293
|
const logicalX = note.startStep * stepWidth;
|
|
19290
19294
|
const yIndex = keyCount - 1 - (note.pitchUnits - pitchRangeStart) / upr;
|
|
19291
19295
|
const logicalY = yIndex * keyHeight;
|
|
@@ -19361,14 +19365,18 @@ var mountDAW = (target, options = {}) => {
|
|
|
19361
19365
|
return;
|
|
19362
19366
|
}
|
|
19363
19367
|
hasDragged = false;
|
|
19364
|
-
const
|
|
19368
|
+
const hitMargin = event.pointerType === "mouse" ? 0 : Math.min(
|
|
19369
|
+
TOUCH_HIT_MARGIN,
|
|
19370
|
+
Math.max(0, Math.floor(renderConfig.keyHeight * 0.25))
|
|
19371
|
+
);
|
|
19372
|
+
const existing = findActiveNoteAt(x2, y, hitMargin);
|
|
19365
19373
|
if (existing) {
|
|
19366
19374
|
playPreview(existing.pitchUnits);
|
|
19367
19375
|
const { stepWidth } = renderConfig;
|
|
19368
19376
|
const offset = renderer.getDrawOffset();
|
|
19369
19377
|
const renderX = existing.startStep * stepWidth - offset.x;
|
|
19370
19378
|
const w = existing.durationSteps * stepWidth;
|
|
19371
|
-
if (x2 >= renderX + w - resizeHandleWidth && x2 <= renderX + w) {
|
|
19379
|
+
if (x2 >= renderX + w - resizeHandleWidth && x2 <= renderX + w + hitMargin) {
|
|
19372
19380
|
dragState = {
|
|
19373
19381
|
noteId: existing.id,
|
|
19374
19382
|
mode: "resize",
|
|
@@ -19383,7 +19391,7 @@ var mountDAW = (target, options = {}) => {
|
|
|
19383
19391
|
noteId: existing.id,
|
|
19384
19392
|
mode: "move",
|
|
19385
19393
|
dragOffsetStep: step - existing.startStep,
|
|
19386
|
-
dragOffsetPitch:
|
|
19394
|
+
dragOffsetPitch: 0,
|
|
19387
19395
|
startStep: existing.startStep,
|
|
19388
19396
|
durationSteps: existing.durationSteps,
|
|
19389
19397
|
lastPreviewPitch: existing.pitchUnits
|
|
@@ -19498,7 +19506,7 @@ var mountDAW = (target, options = {}) => {
|
|
|
19498
19506
|
const orig = selectedOriginal.find((o) => o.id === grab.id);
|
|
19499
19507
|
if (orig) {
|
|
19500
19508
|
const newGrab = units(orig.pitch + deltaPitch);
|
|
19501
|
-
if (newGrab !== lastMultiPreviewPitch && newGrab >=
|
|
19509
|
+
if (newGrab !== lastMultiPreviewPitch && newGrab >= PITCH_RANGE_START && newGrab <= PITCH_RANGE_END) {
|
|
19502
19510
|
lastMultiPreviewPitch = newGrab;
|
|
19503
19511
|
playPreview(newGrab);
|
|
19504
19512
|
}
|
|
@@ -19647,11 +19655,9 @@ var mountDAW = (target, options = {}) => {
|
|
|
19647
19655
|
gridCanvas.addEventListener("dblclick", (event) => {
|
|
19648
19656
|
event.preventDefault();
|
|
19649
19657
|
if (isActiveLocked()) return;
|
|
19650
|
-
const {
|
|
19658
|
+
const { x: x2, y } = renderer.getGridPosition(event);
|
|
19651
19659
|
const active = getActive();
|
|
19652
|
-
const note =
|
|
19653
|
-
(n) => n.pitchUnits === pitch && step >= n.startStep && step < n.startStep + n.durationSteps
|
|
19654
|
-
);
|
|
19660
|
+
const note = findActiveNoteAt(x2, y);
|
|
19655
19661
|
if (note) active.core.deleteNoteById(note.id);
|
|
19656
19662
|
});
|
|
19657
19663
|
gridCanvas.addEventListener(
|
|
@@ -23549,7 +23555,7 @@ var createPianoRoll = (options, handlers) => {
|
|
|
23549
23555
|
const h = keyHeight;
|
|
23550
23556
|
const renderX = logicalX - offset.x;
|
|
23551
23557
|
const renderY = logicalY - offset.y;
|
|
23552
|
-
if (x2 >= renderX && x2
|
|
23558
|
+
if (x2 >= renderX && x2 < renderX + w && y >= renderY && y < renderY + h) {
|
|
23553
23559
|
return note;
|
|
23554
23560
|
}
|
|
23555
23561
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -17612,8 +17612,10 @@ var createRenderer = (mountTarget, width = 800, height = 450, config) => {
|
|
|
17612
17612
|
const getXY = (e) => {
|
|
17613
17613
|
const { clientX, clientY } = e;
|
|
17614
17614
|
const rect = g_grid_canvas.getBoundingClientRect();
|
|
17615
|
-
const
|
|
17616
|
-
const
|
|
17615
|
+
const scaleX = rect.width > 0 ? g_grid_canvas.width / rect.width : 1;
|
|
17616
|
+
const scaleY = rect.height > 0 ? g_grid_canvas.height / rect.height : 1;
|
|
17617
|
+
const x2 = Math.floor((clientX - rect.left) * scaleX);
|
|
17618
|
+
const y = Math.floor((clientY - rect.top) * scaleY);
|
|
17617
17619
|
return [x2, y, e.buttons];
|
|
17618
17620
|
};
|
|
17619
17621
|
const getGridPosition = (e) => {
|
|
@@ -17647,7 +17649,7 @@ var createRenderer = (mountTarget, width = 800, height = 450, config) => {
|
|
|
17647
17649
|
const absoluteY = y + g_draw_offset_y;
|
|
17648
17650
|
const yIndex = Math.floor(absoluteY / keyHeight);
|
|
17649
17651
|
const pitch = units(pitchRangeStart + (keyCount - 1 - yIndex) * upr);
|
|
17650
|
-
if (pitch >= pitchRangeStart && pitch < pitchRangeStart + keyCount) {
|
|
17652
|
+
if (pitch >= pitchRangeStart && pitch < pitchRangeStart + keyCount * upr) {
|
|
17651
17653
|
requestAnimationFrame(() => callback(step, pitch));
|
|
17652
17654
|
}
|
|
17653
17655
|
},
|
|
@@ -19103,7 +19105,9 @@ var mountDAW = (target, options = {}) => {
|
|
|
19103
19105
|
unitsPerRow: upr = UNITS_PER_SEMITONE
|
|
19104
19106
|
} = renderConfig;
|
|
19105
19107
|
const offset = renderer.getDrawOffset();
|
|
19106
|
-
|
|
19108
|
+
const notes = active.core.getNotes();
|
|
19109
|
+
for (let i2 = notes.length - 1; i2 >= 0; i2--) {
|
|
19110
|
+
const note = notes[i2];
|
|
19107
19111
|
const logicalX = note.startStep * stepWidth;
|
|
19108
19112
|
const yIndex = keyCount - 1 - (note.pitchUnits - pitchRangeStart) / upr;
|
|
19109
19113
|
const logicalY = yIndex * keyHeight;
|
|
@@ -19179,14 +19183,18 @@ var mountDAW = (target, options = {}) => {
|
|
|
19179
19183
|
return;
|
|
19180
19184
|
}
|
|
19181
19185
|
hasDragged = false;
|
|
19182
|
-
const
|
|
19186
|
+
const hitMargin = event.pointerType === "mouse" ? 0 : Math.min(
|
|
19187
|
+
TOUCH_HIT_MARGIN,
|
|
19188
|
+
Math.max(0, Math.floor(renderConfig.keyHeight * 0.25))
|
|
19189
|
+
);
|
|
19190
|
+
const existing = findActiveNoteAt(x2, y, hitMargin);
|
|
19183
19191
|
if (existing) {
|
|
19184
19192
|
playPreview(existing.pitchUnits);
|
|
19185
19193
|
const { stepWidth } = renderConfig;
|
|
19186
19194
|
const offset = renderer.getDrawOffset();
|
|
19187
19195
|
const renderX = existing.startStep * stepWidth - offset.x;
|
|
19188
19196
|
const w = existing.durationSteps * stepWidth;
|
|
19189
|
-
if (x2 >= renderX + w - resizeHandleWidth && x2 <= renderX + w) {
|
|
19197
|
+
if (x2 >= renderX + w - resizeHandleWidth && x2 <= renderX + w + hitMargin) {
|
|
19190
19198
|
dragState = {
|
|
19191
19199
|
noteId: existing.id,
|
|
19192
19200
|
mode: "resize",
|
|
@@ -19201,7 +19209,7 @@ var mountDAW = (target, options = {}) => {
|
|
|
19201
19209
|
noteId: existing.id,
|
|
19202
19210
|
mode: "move",
|
|
19203
19211
|
dragOffsetStep: step - existing.startStep,
|
|
19204
|
-
dragOffsetPitch:
|
|
19212
|
+
dragOffsetPitch: 0,
|
|
19205
19213
|
startStep: existing.startStep,
|
|
19206
19214
|
durationSteps: existing.durationSteps,
|
|
19207
19215
|
lastPreviewPitch: existing.pitchUnits
|
|
@@ -19316,7 +19324,7 @@ var mountDAW = (target, options = {}) => {
|
|
|
19316
19324
|
const orig = selectedOriginal.find((o) => o.id === grab.id);
|
|
19317
19325
|
if (orig) {
|
|
19318
19326
|
const newGrab = units(orig.pitch + deltaPitch);
|
|
19319
|
-
if (newGrab !== lastMultiPreviewPitch && newGrab >=
|
|
19327
|
+
if (newGrab !== lastMultiPreviewPitch && newGrab >= PITCH_RANGE_START && newGrab <= PITCH_RANGE_END) {
|
|
19320
19328
|
lastMultiPreviewPitch = newGrab;
|
|
19321
19329
|
playPreview(newGrab);
|
|
19322
19330
|
}
|
|
@@ -19465,11 +19473,9 @@ var mountDAW = (target, options = {}) => {
|
|
|
19465
19473
|
gridCanvas.addEventListener("dblclick", (event) => {
|
|
19466
19474
|
event.preventDefault();
|
|
19467
19475
|
if (isActiveLocked()) return;
|
|
19468
|
-
const {
|
|
19476
|
+
const { x: x2, y } = renderer.getGridPosition(event);
|
|
19469
19477
|
const active = getActive();
|
|
19470
|
-
const note =
|
|
19471
|
-
(n) => n.pitchUnits === pitch && step >= n.startStep && step < n.startStep + n.durationSteps
|
|
19472
|
-
);
|
|
19478
|
+
const note = findActiveNoteAt(x2, y);
|
|
19473
19479
|
if (note) active.core.deleteNoteById(note.id);
|
|
19474
19480
|
});
|
|
19475
19481
|
gridCanvas.addEventListener(
|
|
@@ -23367,7 +23373,7 @@ var createPianoRoll = (options, handlers) => {
|
|
|
23367
23373
|
const h = keyHeight;
|
|
23368
23374
|
const renderX = logicalX - offset.x;
|
|
23369
23375
|
const renderY = logicalY - offset.y;
|
|
23370
|
-
if (x2 >= renderX && x2
|
|
23376
|
+
if (x2 >= renderX && x2 < renderX + w && y >= renderY && y < renderY + h) {
|
|
23371
23377
|
return note;
|
|
23372
23378
|
}
|
|
23373
23379
|
}
|
package/package.json
CHANGED