Skip to content

Commit

Permalink
Fix: Corrected MIDI pitch note addition bug (#4216)
Browse files Browse the repository at this point in the history
* Fix: Corrected MIDI pitch addition bug

* Fix: Corrected MIDI pitch addition bug
  • Loading branch information
Abhay145 authored Jan 3, 2025
1 parent f0ac406 commit ba4ec7f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/widgets/musickeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba4ec7f

Please sign in to comment.