Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refractor/pitchslider:fixed linting errors and added js docs #2791

Merged
merged 2 commits into from
Jan 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion js/widgets/pitchslider.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,40 @@
// from given frequency to nextoctave frequency(two times the given frequency)
// in continuous manner.

/* global _, Tone, logo */

/*
Global locations
js/activity.js
logo, Tone
js/utils/utils.js
_
*/

/* exported PitchSlider */
class PitchSlider {
static ICONSIZE = 32;
static SEMITONE = Math.pow(2, 1 / 12);

/**
* @constructor
*/
constructor() {
this._delta = 0;
this.sliders = {};
this._cellScale = 0;
}

/**
* Intializes the pitch/slider
* @returns {void}
*/
init() {
if (window.widgetWindows.openWindows["slider"]) return;
if (!this.frequencies || !this.frequencies.length) this.frequencies = [392];

const oscillators = [];
for (const _ in this.frequencies) {
for (let i = 0; i < this.frequencies.length; i++) {
const osc = new Tone.AMSynth().toDestination();
oscillators.push(osc);
}
Expand Down Expand Up @@ -120,6 +138,11 @@ class PitchSlider {
setTimeout(this.widgetWindow.sendToCenter, 0);
}

/**
* @private
* @param {number} frequency
* @returns {void}
*/
_save(frequency) {
for (const name in logo.blocks.palettes.dict) {
logo.blocks.palettes.dict[name].hideMenu(true);
Expand Down