Skip to content

Commit

Permalink
added JS docs
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekkumar08 authored and meganindya committed Jan 29, 2021
1 parent f820fca commit 0b69cc8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions js/widgets/tempo.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ class Tempo {
widgetWindow.sendToCenter();
}

/**
* @private
* @param {number} i
* @returns {void}
*/
_updateBPM(i) {
this._intervals[i] = (60 / this.BPMs[i]) * 1000;

Expand All @@ -211,10 +216,18 @@ class Tempo {
}
}

/**
* @public
* @returns {void}
*/
pause() {
clearInterval(this._intervalID);
}

/**
* @public
* @returns {void}
*/
resume() {
// Reset widget time since we are restarting. We will no longer keep synch with the turtles.
const d = new Date();
Expand All @@ -234,6 +247,11 @@ class Tempo {
}, Tempo.TEMPOINTERVAL);
}

/**
* @private
* @param {number} i
* @returns {void}
*/
_useBPM(i) {
this.BPMs[i] = this.BPMInputs[i].value;
if (this.BPMs[i] > 1000) {
Expand All @@ -248,6 +266,11 @@ class Tempo {
this.BPMInputs[i].value = this.BPMs[i];
}

/**
* @public
* @param {number} i
* @returns {void}
*/
speedUp(i) {
this.BPMs[i] = parseFloat(this.BPMs[i]) + Math.round(0.1 * this.BPMs[i]);

Expand All @@ -259,6 +282,11 @@ class Tempo {
this.BPMInputs[i].value = this.BPMs[i];
}

/**
* @public
* @param {number} i
* @returns {void}
*/
slowDown(i) {
this.BPMs[i] = parseFloat(this.BPMs[i]) - Math.round(0.1 * this.BPMs[i]);
if (this.BPMs[i] < 30) {
Expand All @@ -269,6 +297,10 @@ class Tempo {
this.BPMInputs[i].value = this.BPMs[i];
}

/**
* @private
* @returns {void}
*/
_draw() {
// First thing to do is figure out where we are supposed to be based on the elapsed time.
const d = new Date();
Expand Down Expand Up @@ -350,6 +382,11 @@ class Tempo {
}
}

/**
* @private
* @param {number} i
* @returns {void}
*/
__save(i) {
setTimeout(() => {
// console.debug("saving a BPM block for " + this.BPMs[i]);
Expand All @@ -367,13 +404,21 @@ class Tempo {
}, 200 * i);
}

/**
* @private
* @returns {void}
*/
_saveTempo() {
// Save a BPM block for each tempo.
for (let i = 0; i < this.BPMs.length; i++) {
this.__save(i);
}
}

/**
* @private
* @returns {HTMLElement}
*/
_get_save_lock() {
return this._save_lock;
}
Expand Down

0 comments on commit 0b69cc8

Please sign in to comment.