@onjmin/dtm 0.1.41 → 0.1.43

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 CHANGED
@@ -7765,7 +7765,10 @@ var mountDAW = (target, options = {}) => {
7765
7765
  const currByKey = new Map(
7766
7766
  notes.map((n) => [`${n.startStep}_${n.pitch}`, n])
7767
7767
  );
7768
- const added = notes.filter((n) => !prevByKey.has(`${n.startStep}_${n.pitch}`)).map((n) => ({
7768
+ const added = notes.filter((n) => {
7769
+ const prev = prevByKey.get(`${n.startStep}_${n.pitch}`);
7770
+ return !prev || prev.durationSteps !== n.durationSteps || prev.velocity !== n.velocity;
7771
+ }).map((n) => ({
7769
7772
  startStep: n.startStep,
7770
7773
  pitch: n.pitch,
7771
7774
  durationSteps: n.durationSteps,
@@ -7776,7 +7779,7 @@ var mountDAW = (target, options = {}) => {
7776
7779
  options.onNotesPatch(config.id, added, removed);
7777
7780
  }
7778
7781
  }
7779
- prevNotes = [...notes];
7782
+ prevNotes = notes.map((n) => ({ ...n }));
7780
7783
  redrawAll();
7781
7784
  updateUndoRedo();
7782
7785
  }
@@ -7883,6 +7886,7 @@ var mountDAW = (target, options = {}) => {
7883
7886
  drawGrid(gridLineSteps);
7884
7887
  for (const t of trackStates) {
7885
7888
  if (hiddenTracks.has(t.config.id)) continue;
7889
+ if (isSolo && t.config.id !== activeTrackId) continue;
7886
7890
  const [r, g, b] = t.config.color;
7887
7891
  const a = t.config.id === activeTrackId ? 1 : 0.3;
7888
7892
  drawNotes(t.core.getNotes(), [r, g, b, a]);
@@ -9217,6 +9221,7 @@ var mountDAW = (target, options = {}) => {
9217
9221
  });
9218
9222
  refs.soloCheckbox.addEventListener("change", () => {
9219
9223
  isSolo = refs.soloCheckbox.checked;
9224
+ redrawAll();
9220
9225
  });
9221
9226
  refs.toolPen.addEventListener("click", () => setToolMode("pen"));
9222
9227
  refs.toolSelect.addEventListener("click", () => setToolMode("select"));
@@ -9688,6 +9693,8 @@ var mountDAW = (target, options = {}) => {
9688
9693
  suppressPatch = true;
9689
9694
  track.core.beginBatch();
9690
9695
  for (const n of added) {
9696
+ const existing = track.core.getNotes().find((e) => e.startStep === n.startStep && e.pitch === n.pitch);
9697
+ if (existing) track.core.deleteNoteById(existing.id);
9691
9698
  track.core.addNote(n.startStep, n.pitch, {
9692
9699
  noteLengthSteps: n.durationSteps,
9693
9700
  velocity: n.velocity
package/dist/index.mjs CHANGED
@@ -7654,7 +7654,10 @@ var mountDAW = (target, options = {}) => {
7654
7654
  const currByKey = new Map(
7655
7655
  notes.map((n) => [`${n.startStep}_${n.pitch}`, n])
7656
7656
  );
7657
- const added = notes.filter((n) => !prevByKey.has(`${n.startStep}_${n.pitch}`)).map((n) => ({
7657
+ const added = notes.filter((n) => {
7658
+ const prev = prevByKey.get(`${n.startStep}_${n.pitch}`);
7659
+ return !prev || prev.durationSteps !== n.durationSteps || prev.velocity !== n.velocity;
7660
+ }).map((n) => ({
7658
7661
  startStep: n.startStep,
7659
7662
  pitch: n.pitch,
7660
7663
  durationSteps: n.durationSteps,
@@ -7665,7 +7668,7 @@ var mountDAW = (target, options = {}) => {
7665
7668
  options.onNotesPatch(config.id, added, removed);
7666
7669
  }
7667
7670
  }
7668
- prevNotes = [...notes];
7671
+ prevNotes = notes.map((n) => ({ ...n }));
7669
7672
  redrawAll();
7670
7673
  updateUndoRedo();
7671
7674
  }
@@ -7772,6 +7775,7 @@ var mountDAW = (target, options = {}) => {
7772
7775
  drawGrid(gridLineSteps);
7773
7776
  for (const t of trackStates) {
7774
7777
  if (hiddenTracks.has(t.config.id)) continue;
7778
+ if (isSolo && t.config.id !== activeTrackId) continue;
7775
7779
  const [r, g, b] = t.config.color;
7776
7780
  const a = t.config.id === activeTrackId ? 1 : 0.3;
7777
7781
  drawNotes(t.core.getNotes(), [r, g, b, a]);
@@ -9106,6 +9110,7 @@ var mountDAW = (target, options = {}) => {
9106
9110
  });
9107
9111
  refs.soloCheckbox.addEventListener("change", () => {
9108
9112
  isSolo = refs.soloCheckbox.checked;
9113
+ redrawAll();
9109
9114
  });
9110
9115
  refs.toolPen.addEventListener("click", () => setToolMode("pen"));
9111
9116
  refs.toolSelect.addEventListener("click", () => setToolMode("select"));
@@ -9577,6 +9582,8 @@ var mountDAW = (target, options = {}) => {
9577
9582
  suppressPatch = true;
9578
9583
  track.core.beginBatch();
9579
9584
  for (const n of added) {
9585
+ const existing = track.core.getNotes().find((e) => e.startStep === n.startStep && e.pitch === n.pitch);
9586
+ if (existing) track.core.deleteNoteById(existing.id);
9580
9587
  track.core.addNote(n.startStep, n.pitch, {
9581
9588
  noteLengthSteps: n.durationSteps,
9582
9589
  velocity: n.velocity
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "onjmin",
3
3
  "license": "MIT",
4
4
  "name": "@onjmin/dtm",
5
- "version": "0.1.41",
5
+ "version": "0.1.43",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {