Skip to content

Commit ae99427

Browse files
committed
black keys
1 parent 38031f8 commit ae99427

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

js/widgets/musickeyboard.js

Lines changed: 16 additions & 21 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,9 +1570,7 @@ function MusicKeyboard(activity) {
15701570
cell.style.maxWidth = cell.style.width;
15711571

15721572
if (
1573-
selectedNotes[j].blockNumber.includes(
1574-
this.displayLayout[n - i - 1].blockNumber
1575-
)
1573+
selectedNotes[j].blockNumber.includes(this.displayLayout[n - i - 1].blockNumber)
15761574
) {
15771575
ind = selectedNotes[j].blockNumber.indexOf(
15781576
this.displayLayout[n - i - 1].blockNumber
@@ -1996,10 +1994,7 @@ function MusicKeyboard(activity) {
19961994
lastNote = null;
19971995
}
19981996

1999-
if (
2000-
pitchLabels[i].includes(lastNote) ||
2001-
lastNote.includes(pitchLabels[i])
2002-
) {
1997+
if (pitchLabels[i].includes(lastNote) || lastNote.includes(pitchLabels[i])) {
20031998
break;
20041999
}
20052000
}
@@ -2227,7 +2222,7 @@ function MusicKeyboard(activity) {
22272222
/**
22282223
* Creates a column pie submenu based on the provided index and condition.
22292224
* @param {number} index - The index used to retrieve block information.
2230-
* @param {string} condition - The condition that determines the type of submenu to create ('synthsblocks' or 'pitchblocks').
2225+
* @param {string} condition - The condition that determines the type of submenu to create ('synthsblocks' or 'pitchblocks').
22312226
*/
22322227
this._createColumnPieSubmenu = function (index, condition) {
22332228
index = parseInt(index);
@@ -2619,7 +2614,7 @@ function MusicKeyboard(activity) {
26192614
parenttbl2 = document.getElementById("myrow2");
26202615
newel2 = document.createElement("td");
26212616
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
2622-
if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) {
2617+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
26232618
parenttbl2.appendChild(newel2);
26242619
el = docById("blackRow" + myrow2Id.toString());
26252620
el.style.background = "transparent";
@@ -2717,7 +2712,7 @@ function MusicKeyboard(activity) {
27172712
newel2 = document.createElement("td");
27182713
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
27192714
newel2.style.textAlign = "center";
2720-
if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) {
2715+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
27212716
parenttbl2.appendChild(newel2);
27222717
el = docById("blackRow" + myrow2Id.toString());
27232718
el.style.background = "transparent";
@@ -2769,7 +2764,7 @@ function MusicKeyboard(activity) {
27692764
// elementid2 = document.getElementsByTagName("td").length;
27702765
newel2.setAttribute("id", "blackRow" + myrow2Id.toString());
27712766
newel2.style.textAlign = "center";
2772-
if ([2, 6, 9, 13, 16, 20].includes(myrow2Id)) {
2767+
if ([2, 6, 9, 13, 16, 20, 23, 27, 30, 34].includes(myrow2Id)) {
27732768
parenttbl2.appendChild(newel2);
27742769
el = docById("blackRow" + myrow2Id.toString());
27752770
el.style.background = "transparent";
@@ -2921,7 +2916,7 @@ function MusicKeyboard(activity) {
29212916
* Adjacent notes with the same voice are clustered together to facilitate wrapping in "settimbre" block.
29222917
* For example, notes like piano-do piano-re piano-mi guitar-fa piano-sol piano-la piano-ti
29232918
* will be organized into clusters such as piano-[do re mi], guitar-fa, and piano-[sol la ti].
2924-
*
2919+
*
29252920
* @param {Array<Object>} selectedNotes - Array of selected notes to be processed.
29262921
* @returns {Array<Array<number>>} - Array of arrays containing indices of selected notes grouped by voice.
29272922
*/
@@ -2957,7 +2952,7 @@ function MusicKeyboard(activity) {
29572952
/**
29582953
* Calculate the required length of the next "setTimbre" block based on selected notes.
29592954
* This function computes the length of the next "setTimbre" block by considering the types and properties of the selected notes.
2960-
*
2955+
*
29612956
* @param {Array<Array<number>>} selectedNotesGrp - Groups of selected notes (indices) organized by voice similarity.
29622957
* @param {Array<Object>} selectedNotes - Array of selected notes.
29632958
* @returns {number} - Required length for the next "setTimbre" block.

0 commit comments

Comments
 (0)