Skip to content

Commit

Permalink
Global handling for extra notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
PoneyClairDeLune committed Jan 27, 2024
1 parent de87021 commit 9357d7c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/basic/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ let RootDisplay = class extends CustomEventSource {
this.#noteTime = time;
};
let events = this.#midiPool?.step(time) || [];
let extraPoly = 0, notes = new Set();
let extraPoly = 0, notes = new Set(), noteVelo = {};
let extraNotes = [];
let upThis = this;
let metaReplies = [];
// Reset strength for a new frame
Expand All @@ -243,14 +244,27 @@ let RootDisplay = class extends CustomEventSource {
if (raw.type == 9) {
if (raw.data[1] > 0) {
notes.add(raw.part * 128 + raw.data[0]);
noteVelo[raw.part * 128 + raw.data[0]] = raw.data[1];
} else {
if (notes.has(raw.part * 128 + raw.data[0])) {
extraNotes.push({
part: raw.part,
note: raw.data[0],
velo: noteVelo[raw.part * 128 + raw.data[0]],
state: 3 // OctaviaDevice.NOTE_SUSTAIN
});
extraPoly ++;
};
};
};
if (e.data.type == 8) {
if (notes.has(raw.part * 128 + raw.data[0])) {
extraNotes.push({
part: raw.part,
note: raw.data[0],
velo: noteVelo[raw.part * 128 + raw.data[0]],
state: 3 // OctaviaDevice.NOTE_SUSTAIN
});
extraPoly ++;
};
};
Expand Down Expand Up @@ -300,6 +314,7 @@ let RootDisplay = class extends CustomEventSource {
});
let repObj = {
extraPoly,
extraNotes,
curPoly,
chInUse,
chKeyPr,
Expand Down

0 comments on commit 9357d7c

Please sign in to comment.