Skip to content

Commit

Permalink
Add jsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkumar08 authored and meganindya committed Jan 29, 2021
1 parent 605e962 commit 59862ce
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions js/widgets/pitchdrummatrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,22 @@ save() : Saves the Drum Matrix in an array of blocks: Set
Drum and Pitch blocks.
*/

/* global platformColor, _, docById, getNote, getDrumName, getDrumIcon, getDrumSynthName, Singer, MATRIXSOLFEHEIGHT, MATRIXSOLFEWIDTH, SOLFEGECONVERSIONTABLE */

/*
Global locations
- js/utils/musicutils.js
getNote, getDrumName, getDrumIcon, getDrumSynthName, Singer, MATRIXSOLFEHEIGHT, MATRIXSOLFEWIDTH, SOLFEGECONVERSIONTABLE
- js/utils/utils.js
_, docById
- js/utils/platformstyle.js
platformColor
*/

/*exported PitchDrumMatrix */

class PitchDrumMatrix {
static BUTTONDIVWIDTH = 295; // 5 buttons
Expand Down Expand Up @@ -59,19 +75,43 @@ class PitchDrumMatrix {
this._blockMap = [];
}

/**
* @public
* @returns {void}
*/

clearBlocks() {
this._rowBlocks = [];
this._colBlocks = [];
}

/**
* @public
* @param {number} pitchBlock
* @return {void}
*/

addRowBlock(pitchBlock) {
this._rowBlocks.push(pitchBlock);
}

/**
* @public
* @param {number} drumBlock
* @return {void}
*/

addColBlock(drumBlock) {
this._colBlocks.push(drumBlock);
}

/**
* @public
* @param {number} pitchBlock
* @param {number} drumBlock
* @returns {void}
*/

addNode(pitchBlock, drumBlock) {
let obj;
for (let i = 0; i < this._blockMap.length; i++) {
Expand All @@ -83,6 +123,13 @@ class PitchDrumMatrix {
this._blockMap.push([pitchBlock, drumBlock]);
}

/**
* @public
* @param {number} pitchBlock
* @param {number} drumBlock
* @returns {void}
*/

removeNode(pitchBlock, drumBlock) {
let obj;
for (let i = 0; i < this._blockMap.length; i++) {
Expand All @@ -92,6 +139,10 @@ class PitchDrumMatrix {
}
}
}
/**
* @private
* @returns {HTMLElement}
*/

_get_save_lock() {
return this._save_lock;
Expand Down Expand Up @@ -339,6 +390,12 @@ class PitchDrumMatrix {
return cell;
}

/**
* @private
* @param {number} drumIdx
* @returns {void}
*/

_addDrum(drumIdx) {
const drumname = this.drums[drumIdx];
const pdmTable = docById("pdmTable");
Expand Down Expand Up @@ -405,6 +462,10 @@ class PitchDrumMatrix {
'" vertical-align="middle">&nbsp;&nbsp;';
cell.style.backgroundColor = platformColor.selectorBackground;
}
/**
* @public
* @returns {void}
*/

makeClickable() {
// Once the entire matrix is generated, this function makes it
Expand Down Expand Up @@ -477,6 +538,11 @@ class PitchDrumMatrix {
}
}

/**
* @private
* @returns {void}
*/

_playAll() {
// Play all of the pitch/drum combinations in the matrix.
this._logo.synth.stop();
Expand Down Expand Up @@ -511,6 +577,13 @@ class PitchDrumMatrix {
}
}

/**
* @private
* @param {number} i
* @param {number} pairs
* @returns {void}
*/

_playPitchDrum(i, pairs) {
// Find the drum cell
const drumTable = docById("pdmDrumTable");
Expand Down Expand Up @@ -545,6 +618,14 @@ class PitchDrumMatrix {
}
}

/**
* @private
* @param {number} colIndex
* @param {number} rowIndex
* @param {number} playNote
* @returns {void}
*/

_setCellPitchDrum(colIndex, rowIndex, playNote) {
// Sets corresponding pitch/drum when user clicks on any cell and
// plays them.
Expand Down Expand Up @@ -600,6 +681,8 @@ class PitchDrumMatrix {
}
}



_setPairCell(rowIndex, colIndex, cell, playNote) {
const pdmTable = docById("pdmTable");
let row = pdmTable.rows[rowIndex];
Expand Down Expand Up @@ -658,6 +741,11 @@ class PitchDrumMatrix {
}
}

/**
* @private
* @returns {void}
*/

_save() {
// Saves the current matrix as an action stack consisting of a
// set drum and pitch blocks.
Expand Down

0 comments on commit 59862ce

Please sign in to comment.