@onjmin/dtm 0.1.41 → 0.1.42

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
  }
@@ -9688,6 +9691,8 @@ var mountDAW = (target, options = {}) => {
9688
9691
  suppressPatch = true;
9689
9692
  track.core.beginBatch();
9690
9693
  for (const n of added) {
9694
+ const existing = track.core.getNotes().find((e) => e.startStep === n.startStep && e.pitch === n.pitch);
9695
+ if (existing) track.core.deleteNoteById(existing.id);
9691
9696
  track.core.addNote(n.startStep, n.pitch, {
9692
9697
  noteLengthSteps: n.durationSteps,
9693
9698
  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
  }
@@ -9577,6 +9580,8 @@ var mountDAW = (target, options = {}) => {
9577
9580
  suppressPatch = true;
9578
9581
  track.core.beginBatch();
9579
9582
  for (const n of added) {
9583
+ const existing = track.core.getNotes().find((e) => e.startStep === n.startStep && e.pitch === n.pitch);
9584
+ if (existing) track.core.deleteNoteById(existing.id);
9580
9585
  track.core.addNote(n.startStep, n.pitch, {
9581
9586
  noteLengthSteps: n.durationSteps,
9582
9587
  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.42",
6
6
  "description": "MMLを中間言語に用いた、モバイルファーストなDAW / ピアノロール打ち込みコンポーネント",
7
7
  "homepage": "https://onjmin.github.io/dtm",
8
8
  "repository": {