From ba4ec7f3051568e33769daeeffe669921f617076 Mon Sep 17 00:00:00 2001 From: Abhay Agarwal <161469723+Abhay145@users.noreply.github.com> Date: Sat, 4 Jan 2025 03:32:41 +0530 Subject: [PATCH] Fix: Corrected MIDI pitch note addition bug (#4216) * Fix: Corrected MIDI pitch addition bug * Fix: Corrected MIDI pitch addition bug --- js/widgets/musickeyboard.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/widgets/musickeyboard.js b/js/widgets/musickeyboard.js index db1450c688..d65eeff7fa 100644 --- a/js/widgets/musickeyboard.js +++ b/js/widgets/musickeyboard.js @@ -1917,7 +1917,7 @@ function MusicKeyboard(activity) { this._createAddRowPieSubmenu = function () { docById("wheelDivptm").style.display = ""; // docById("wheelDivptm").style.zIndex = "300"; - const pitchLabels = ["do", "re", "mi", "fa", "sol", "la", "ti"]; + const pitchLabels = ["do", "do♯", "re", "re♯", "mi", "fa", "fa♯", "sol", "sol♯", "la", "la♯", "ti"]; const hertzLabels = [262, 294, 327, 348, 392, 436, 490, 523]; const VALUESLABEL = ["pitch", "hertz"]; const VALUES = ["imgsrc: images/chime.svg", "imgsrc: images/synth.svg"]; @@ -2022,7 +2022,10 @@ function MusicKeyboard(activity) { } } - rLabel = pitchLabels[(i + 1) % pitchLabels.length]; + do { + rLabel = pitchLabels[(i + 1) % pitchLabels.length]; + i = (i + 1) % pitchLabels.length; + } while (this.layout.some(note => note.noteName === rLabel)); for (let j = this.layout.length; j > 0; j--) { rArg = this.layout[j - 1].noteOctave; if (isNaN(rArg)) { @@ -2115,6 +2118,11 @@ function MusicKeyboard(activity) { this.displayLayout = this.displayLayout.concat(sortedHertzList); this._createKeyboard(); this._createTable(); + const n = this.layout.length; + const key = this.layout[n - 1]; + this.getElement[key.noteName.toString() + key.noteOctave.toString()] = key.objId; + this.getElement[FIXEDSOLFEGE1[key.noteName.toString()] + "" + key.noteOctave] = + key.objId; //convet solfege to alphabetic. }, 500); } else { // eslint-disable-next-line no-console