Skip to content

Commit d9f2061

Browse files
FIXED: Fixed slowdown caused when the app receives a flood of midi signals.
When a flood of midi signals (e.g., hard note-off) was received the app was slowing down. Problem occurred with Musescore.
1 parent f5baee6 commit d9f2061

File tree

3 files changed

+47
-40
lines changed

3 files changed

+47
-40
lines changed

assets/js/dhc.js

+40-34
Original file line numberDiff line numberDiff line change
@@ -867,38 +867,41 @@ HUM.DHC = class {
867867
// Search the FT number in the playQueue array
868868
let position = this.playQueue.ft.findIndex(qt => qt.xtNum === dhcMsg.xtNum);
869869
// If the FTn exist
870-
if (position > -1) {
870+
if (position !== -1) {
871871
// Remove the FTn from the playQueue array
872872
this.playQueue.ft.splice(position, 1);
873-
// If the FTn does not exist
874-
} else {
875-
if (dhcMsg.panic === false) {
876-
console.log("STRANGE: there is NOT a FT pressed key #:", dhcMsg.xtNum);
877-
}
878-
}
879873

880-
this.sendMessageToApps(dhcMsg);
881-
882-
// If there are other notes, read and play the next note on the playQueue array
883-
if (this.playQueue.ft.length > 0) {
884-
// Read the next FT
885-
let nextIndex = this.playQueue.ft.length - 1;
886-
let nextTone = this.playQueue.ft[nextIndex];
887-
// If the next tone is NOT the active one
888-
if (nextTone.xtNum !== this.settings.ht.curr_ft) {
889-
890-
// Recalculate the ht table passing the frequency (Hz)
891-
this.createHTtable(this.tables.ft[nextTone.xtNum].hz);
892-
// Store the current FT into the global slot for future HT table re-computations and UI monitor updates
893-
this.settings.ht.curr_ft = nextTone.xtNum;
894-
895-
this.sendMessageToApps(nextTone);
896-
897-
// Update the UI
898-
this.dhcMonitor("ft", nextTone.xtNum);
874+
this.sendMessageToApps(dhcMsg);
875+
876+
// If there are other notes, read and play the next note on the playQueue array
877+
if (this.playQueue.ft.length > 0) {
878+
// Read the next FT
879+
let nextIndex = this.playQueue.ft.length - 1;
880+
let nextTone = this.playQueue.ft[nextIndex];
881+
// If the next tone is NOT the active one
882+
if (nextTone.xtNum !== this.settings.ht.curr_ft) {
883+
884+
// Recalculate the ht table passing the frequency (Hz)
885+
this.createHTtable(this.tables.ft[nextTone.xtNum].hz);
886+
// Store the current FT into the global slot for future HT table re-computations and UI monitor updates
887+
this.settings.ht.curr_ft = nextTone.xtNum;
888+
889+
this.sendMessageToApps(nextTone);
890+
891+
// Update the UI
892+
this.dhcMonitor("ft", nextTone.xtNum);
899893

894+
}
900895
}
896+
897+
// If the FTn does not exist
901898
}
899+
// else {
900+
// // if (dhcMsg.panic === false) {
901+
// // console.log("STRANGE: there is NOT a FT pressed key #:", dhcMsg.xtNum);
902+
// // }
903+
// }
904+
902905
}
903906

904907
/**
@@ -981,27 +984,30 @@ HUM.DHC = class {
981984
// Search the HT number in the queue array
982985
let position = this.playQueue.ht.findIndex(qt => qt.xtNum === dhcMsg.xtNum);
983986
// If the HTn exist
984-
if (position > -1) {
987+
if (position !== -1) {
985988
// Remove the HTn from the queue array
986989
this.playQueue.ht.splice(position, 1);
987990
// Update the curr_ht
988991
if (this.playQueue.ht.length > 0) {
989992
this.settings.ht.curr_ht = this.playQueue.ht[this.playQueue.ht.length-1].xtNum;
990993
}
994+
995+
this.sendMessageToApps(dhcMsg);
996+
991997
// If the FTn does not exist
992-
} else {
993-
if (dhcMsg.panic === false) {
994-
console.log("STRANGE: there is NOT a HT pressed key #:", dhcMsg.xtNum);
995-
}
996-
}
998+
}
999+
// else {
1000+
// // if (dhcMsg.panic === false) {
1001+
// // console.log("STRANGE: there is NOT a HT pressed key #:", dhcMsg.xtNum);
1002+
// // }
1003+
// }
9971004

9981005
// If HT0 is pressed, it's the Piper feature
9991006
} else if (dhcMsg.xtNum === 0 && dhcMsg.panic === false) {
10001007
// Note OFF the active piped HT
10011008
this.piping(0);
1009+
this.sendMessageToApps(dhcMsg);
10021010
}
1003-
1004-
this.sendMessageToApps(dhcMsg);
10051011

10061012
}
10071013

assets/js/synth.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -397,18 +397,19 @@ HUM.Synth = class {
397397
// Mute the voice only in there are no more HT tones with the same number
398398
// (in order to manage the pressure of multiple copy of the same HT on the controller eg. HT 8)
399399
let sameTones = this.dhc.playQueue.ht.findIndex(qt => qt.xtNum === toneID);
400-
if (sameTones < 0) {
400+
if (sameTones === -1) {
401401
// If there is an active voice with ctrlNoteNumber ID
402402
if (this.voices.ht[toneID]) {
403403
// Shut off the note playing and clear it
404404
this.voices.ht[toneID].voiceMute();
405405
this.voices.ht[toneID] = null;
406406
delete this.voices.ht[toneID];
407-
} else {
408-
if (panic === false) {
409-
console.log("STRANGE: there is NOT an HT active voice with ID:", toneID);
410-
}
411407
}
408+
// else {
409+
// // if (panic === false) {
410+
// // console.log("STRANGE: there is NOT an HT active voice with ID:", toneID);
411+
// // }
412+
// }
412413
}
413414

414415
// **FT**

assets/js/templates.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ HUM.tmpl = {
241241
<h2>License</h2>
242242
<h3 style="margin-bottom: 0;">Harmonicarium</h2>
243243
<p style="margin-top: 0; margin-bottom: 0;">a Dynamic Harmonics Calculator</p>
244-
<p style="margin-top: 0;"><span class="monospace">ver. 0.7.0 (Kepler)</span></p>
244+
<p style="margin-top: 0;"><span class="monospace">ver. 0.7.1 (Kepler)</span></p>
245245
<h3>Copyright (C) 2017-2022 by Walter Mantovani</h3>
246246
<p>This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</p>
247247
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.</p>

0 commit comments

Comments
 (0)