Skip to content

Commit 9928b1e

Browse files
committed
keyboard final fix
1 parent 1f80392 commit 9928b1e

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

js/widgets/musickeyboard.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function MusicKeyboard(activity) {
132132
* @type {Array}
133133
*/
134134
this.idContainer = [];
135-
135+
136136
/**
137137
* Flag to track tick status.
138138
* @type {boolean}
@@ -179,7 +179,7 @@ function MusicKeyboard(activity) {
179179
// Each element in the array is [start time, note, id, duration, voice].
180180
this._notesPlayed = [];
181181

182-
/**
182+
/**
183183
* Adds a row block to the keyboard.
184184
* @param {number} rowBlock - The row block to add.
185185
*/
@@ -882,7 +882,7 @@ function MusicKeyboard(activity) {
882882

883883
/**
884884
* Plays a sequence of musical notes recursively with a specified time delay.
885-
*
885+
*
886886
* @param {number} counter - The index of the current note in the sequence.
887887
* @param {number} time - The time duration of the current note.
888888
* @param {HTMLElement} playButtonCell - The HTML element representing the play button.
@@ -970,7 +970,7 @@ function MusicKeyboard(activity) {
970970

971971
/**
972972
* Plays a chord (multiple notes simultaneously) using a synthesizer.
973-
*
973+
*
974974
* @param {string[]} notes - Array of note names to be played as a chord.
975975
* @param {number[]} noteValue - Array of note values (durations) for each note in the chord.
976976
* @param {string[]} instruments - Array of instrument names or identifiers for each note.
@@ -1026,7 +1026,7 @@ function MusicKeyboard(activity) {
10261026

10271027
/**
10281028
* Fills chromatic gaps in a given list of notes by padding with missing notes.
1029-
*
1029+
*
10301030
* @param {Object[]} noteList - List of notes represented as dictionaries containing `noteName` and `noteOctave`.
10311031
* @returns {Object[]} A new list of notes with chromatic gaps filled.
10321032
*/
@@ -1173,7 +1173,7 @@ function MusicKeyboard(activity) {
11731173

11741174
/**
11751175
* Generates a sorted and filtered layout of keys based on note information.
1176-
*
1176+
*
11771177
* @returns {Object[]} An array of objects representing the layout of keys:
11781178
* [
11791179
* {
@@ -1270,7 +1270,7 @@ function MusicKeyboard(activity) {
12701270
/**
12711271
* Sets notes in a specified column based on cell color markings.
12721272
* Removes existing notes starting at the specified start time.
1273-
*
1273+
*
12741274
* @param {number} colIndex - The index of the column to set notes in.
12751275
* @param {boolean} playNote - Indicates whether to trigger note playback.
12761276
*/
@@ -1310,7 +1310,7 @@ function MusicKeyboard(activity) {
13101310

13111311
/**
13121312
* Sets a note cell based on the provided parameters.
1313-
*
1313+
*
13141314
* @param {number} j - The row index of the note cell.
13151315
* @param {number} colIndex - The column index of the note cell.
13161316
* @param {string} start - The start time of the note.
@@ -1570,7 +1570,9 @@ function MusicKeyboard(activity) {
15701570
cell.style.maxWidth = cell.style.width;
15711571

15721572
if (
1573-
selectedNotes[j].blockNumber.includes(this.displayLayout[n - i - 1].blockNumber)
1573+
selectedNotes[j].blockNumber.includes(
1574+
this.displayLayout[n - i - 1].blockNumber
1575+
)
15741576
) {
15751577
ind = selectedNotes[j].blockNumber.indexOf(
15761578
this.displayLayout[n - i - 1].blockNumber
@@ -1994,7 +1996,10 @@ function MusicKeyboard(activity) {
19941996
lastNote = null;
19951997
}
19961998

1997-
if (pitchLabels[i].includes(lastNote) || lastNote.includes(pitchLabels[i])) {
1999+
if (
2000+
pitchLabels[i].includes(lastNote) ||
2001+
lastNote.includes(pitchLabels[i])
2002+
) {
19982003
break;
19992004
}
20002005
}
@@ -2222,7 +2227,7 @@ function MusicKeyboard(activity) {
22222227
/**
22232228
* Creates a column pie submenu based on the provided index and condition.
22242229
* @param {number} index - The index used to retrieve block information.
2225-
* @param {string} condition - The condition that determines the type of submenu to create ('synthsblocks' or 'pitchblocks').
2230+
* @param {string} condition - The condition that determines the type of submenu to create ('synthsblocks' or 'pitchblocks').
22262231
*/
22272232
this._createColumnPieSubmenu = function (index, condition) {
22282233
index = parseInt(index);
@@ -2614,7 +2619,7 @@ function MusicKeyboard(activity) {
26142619
parenttbl2 = document.getElementById("myrow2");
26152620
newel2 = document.createElement("td");
26162621
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
2617-
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
2622+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34, 37, 41, 44, 48, 51, 55, 58, 62].includes(myrow2Id)) {
26182623
parenttbl2.appendChild(newel2);
26192624
el = docById("blackRow" + myrow2Id.toString());
26202625
el.style.background = "transparent";
@@ -2712,7 +2717,7 @@ function MusicKeyboard(activity) {
27122717
newel2 = document.createElement("td");
27132718
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
27142719
newel2.style.textAlign = "center";
2715-
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
2720+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34, 37, 41, 44, 48, 51, 55, 58, 62].includes(myrow2Id)) {
27162721
parenttbl2.appendChild(newel2);
27172722
el = docById("blackRow" + myrow2Id.toString());
27182723
el.style.background = "transparent";
@@ -2764,7 +2769,7 @@ function MusicKeyboard(activity) {
27642769
// elementid2 = document.getElementsByTagName("td").length;
27652770
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
27662771
newel2.style.textAlign = "center";
2767-
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
2772+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34, 37, 41, 44, 48, 51, 55, 58, 62].includes(myrow2Id)) {
27682773
parenttbl2.appendChild(newel2);
27692774
el = docById("blackRow" + myrow2Id.toString());
27702775
el.style.background = "transparent";
@@ -2916,7 +2921,7 @@ function MusicKeyboard(activity) {
29162921
* Adjacent notes with the same voice are clustered together to facilitate wrapping in "settimbre" block.
29172922
* For example, notes like piano-do piano-re piano-mi guitar-fa piano-sol piano-la piano-ti
29182923
* will be organized into clusters such as piano-[do re mi], guitar-fa, and piano-[sol la ti].
2919-
*
2924+
*
29202925
* @param {Array<Object>} selectedNotes - Array of selected notes to be processed.
29212926
* @returns {Array<Array<number>>} - Array of arrays containing indices of selected notes grouped by voice.
29222927
*/
@@ -2952,7 +2957,7 @@ function MusicKeyboard(activity) {
29522957
/**
29532958
* Calculate the required length of the next "setTimbre" block based on selected notes.
29542959
* This function computes the length of the next "setTimbre" block by considering the types and properties of the selected notes.
2955-
*
2960+
*
29562961
* @param {Array<Array<number>>} selectedNotesGrp - Groups of selected notes (indices) organized by voice similarity.
29572962
* @param {Array<Object>} selectedNotes - Array of selected notes.
29582963
* @returns {number} - Required length for the next "setTimbre" block.

0 commit comments

Comments
 (0)