';
- docById("frequencySlider1").oninput = function() {
- let frequency, ratio, labels, ratioDifference;
- docById("frequencydiv1").innerHTML = docById(
- "frequencySlider1"
- ).value;
- frequency = docById("frequencySlider1").value;
- ratio = frequency / that.frequencies[0];
- labels = [];
- ratioDifference = [];
- that.temporaryRatios = that.ratios.slice();
- that.temporaryRatios[i] = ratio;
- that._logo.resetSynth(0);
- that._logo.synth.trigger(
- 0, frequency, Singer.defaultBPMFactor * 0.01, "electronic synth", null, null
+ docById("frequencySlider1").oninput = () => {
+ docById("frequencydiv1").innerHTML = docById("frequencySlider1").value;
+ const frequency = docById("frequencySlider1").value;
+ const ratio = frequency / this.frequencies[0];
+ // labels = [];
+ // ratioDifference = [];
+ this.temporaryRatios = this.ratios.slice();
+ this.temporaryRatios[i] = ratio;
+ logo.resetSynth(0);
+ logo.synth.trigger(
+ 0,
+ frequency,
+ Singer.defaultBPMFactor * 0.01,
+ "electronic synth",
+ null,
+ null
);
- that.createMainWheel(that.temporaryRatios);
+ this.createMainWheel(this.temporaryRatios);
};
- docById("done").onclick = function() {
- let frequency1;
- that.ratios = that.temporaryRatios.slice();
- that.typeOfEdit = "nonequal";
- that.createMainWheel();
- frequency1 = that.frequencies[0];
- that.frequencies = [];
- for (let j = 0; j < that.ratios.length; j++) {
- that.frequencies[j] = that.ratios[j] * frequency1;
- that.frequencies[j] = that.frequencies[j].toFixed(2);
+ docById("done").onclick = () => {
+ this.ratios = this.temporaryRatios.slice();
+ this.typeOfEdit = "nonequal";
+ this.createMainWheel();
+ const frequency1 = this.frequencies[0];
+ this.frequencies = [];
+ for (let j = 0; j < this.ratios.length; j++) {
+ this.frequencies[j] = this.ratios[j] * frequency1;
+ this.frequencies[j] = this.frequencies[j].toFixed(2);
}
- that.checkTemperament(that.ratios);
+ this.checkTemperament(this.ratios);
docById("noteInfo").remove();
};
- docById("close").onclick = function() {
- that.temporaryRatios = that.ratios.slice();
- that.createMainWheel();
+ docById("close").onclick = () => {
+ this.temporaryRatios = this.ratios.slice();
+ this.createMainWheel();
docById("noteInfo").remove();
};
};
- this._graphOfNotes = function() {
+ /**
+ * Triggered when graph of notes UI element is stelected displays circular graph of all the
+ * notes present.
+ * @returns {void}
+ */
+ _graphOfNotes() {
this.circleIsVisible = true;
this.toggleNotesButton();
temperamentTableDiv.innerHTML = "";
@@ -452,21 +669,14 @@ function TemperamentWidget() {
}
temperamentTableDiv.innerHTML = '
';
- let notesGraph = docById("notesGraph");
- let headerNotes = notesGraph.createTHead();
- let rowNotes = headerNotes.insertRow(0);
+ const notesGraph = docById("notesGraph");
+ const headerNotes = notesGraph.createTHead();
+ headerNotes.insertRow(0);
let menuLabels = [];
if (isCustom(this.inTemperament)) {
menuLabels = ["Play", "Pitch Number", "Ratio", "Frequency"];
} else {
- menuLabels = [
- "Play",
- "Pitch Number",
- "Ratio",
- "Interval",
- "Note",
- "Frequency"
- ];
+ menuLabels = ["Play", "Pitch Number", "Ratio", "Interval", "Note", "Frequency"];
menuLabels.splice(5, 0, this.scale);
}
notesGraph.innerHTML =
@@ -479,7 +689,7 @@ function TemperamentWidget() {
docById("menu").innerHTML = menus;
- let menuItems = document.querySelectorAll("#menuLabels");
+ const menuItems = document.querySelectorAll("#menuLabels");
for (let i = 0; i < menuLabels.length; i++) {
menuItems[i].style.background = platformColor.labelColor;
menuItems[i].style.height = 30 + "px";
@@ -509,12 +719,9 @@ function TemperamentWidget() {
'
|
';
docById("tableOfNotes").innerHTML = pitchNumberColumn;
- let startingPitch = this._logo.synth.startingPitch;
- let that = this;
- let notesRow = [];
- let notesCell = [];
- let noteToPlay = [];
- let ratios = [];
+ const notesRow = [];
+ const notesCell = [];
+ const ratios = [];
let playImage;
for (let i = 0; i <= this.pitchNumber; i++) {
@@ -528,35 +735,32 @@ function TemperamentWidget() {
i +
'"> ';
notesCell[(i, 0)].style.width = 40 + "px";
- notesCell[(i, 0)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 0)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 0)].style.textAlign = "center";
- notesCell[(i, 0)].onmouseover = function() {
- this.style.backgroundColor =
- platformColor.selectorBackgroundHOVER;
+ notesCell[(i, 0)].onmouseover = (event) => {
+ event.target.style.backgroundColor = platformColor.selectorBackgroundHOVER;
};
- notesCell[(i, 0)].onmouseout = function() {
- this.style.backgroundColor = platformColor.selectorBackground;
+ notesCell[(i, 0)].onmouseout = (event) => {
+ event.target.style.backgroundColor = platformColor.selectorBackground;
};
playImage = docById("play_" + i);
- playImage.onmouseover = function(event) {
- this.style.cursor = "pointer";
+ playImage.onmouseover = (event) => {
+ event.target.style.cursor = "pointer";
};
- playImage.onclick = function(event) {
- that.playNote(event.target.dataset.id);
+ playImage.onclick = (event) => {
+ this.playNote(event.target.dataset.id);
};
//Pitch Number
notesCell[(i, 1)] = notesRow[i].insertCell(-1);
notesCell[(i, 1)].id = "pitchNumber_" + i;
notesCell[(i, 1)].innerHTML = i;
- notesCell[(i, 1)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 1)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 1)].style.textAlign = "center";
ratios[i] = this.ratios[i];
@@ -565,8 +769,7 @@ function TemperamentWidget() {
//Ratio
notesCell[(i, 2)] = notesRow[i].insertCell(-1);
notesCell[(i, 2)].innerHTML = ratios[i];
- notesCell[(i, 2)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 2)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 2)].style.textAlign = "center";
if (!isCustom(this.inTemperament)) {
@@ -574,16 +777,14 @@ function TemperamentWidget() {
notesCell[(i, 3)] = notesRow[i].insertCell(-1);
notesCell[(i, 3)].innerHTML = this.intervals[i];
notesCell[(i, 3)].style.width = 120 + "px";
- notesCell[(i, 3)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 3)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 3)].style.textAlign = "center";
//Notes
notesCell[(i, 4)] = notesRow[i].insertCell(-1);
notesCell[(i, 4)].innerHTML = this.notes[i];
notesCell[(i, 4)].style.width = 50 + "px";
- notesCell[(i, 4)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 4)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 4)].style.textAlign = "center";
//Mode
@@ -598,16 +799,14 @@ function TemperamentWidget() {
notesCell[(i, 5)].innerHTML = "Non Scalar";
}
notesCell[(i, 5)].style.width = 100 + "px";
- notesCell[(i, 5)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 5)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 5)].style.textAlign = "center";
}
//Frequency
notesCell[(i, 6)] = notesRow[i].insertCell(-1);
notesCell[(i, 6)].innerHTML = this.frequencies[i];
- notesCell[(i, 6)].style.backgroundColor =
- platformColor.selectorBackground;
+ notesCell[(i, 6)].style.backgroundColor = platformColor.selectorBackground;
notesCell[(i, 6)].style.textAlign = "center";
if (isCustom(this.inTemperament)) {
@@ -620,13 +819,17 @@ function TemperamentWidget() {
notesCell[(i, 2)].style.width = 60 + "px";
}
}
- };
+ }
+
+ /**
+ * Triggerred when any one of the UI edit elemnts is selected.
+ * @returns {void}
+ */
+ edit() {
+ this.editMode = null;
+ logo.synth.setMasterVolume(0);
+ logo.synth.stop();
- this.edit = function() {
- this.editMode = null ;
- this._logo.synth.setMasterVolume(0);
- this._logo.synth.stop();
- let that = this;
if (docById("wheelDiv2") != null) {
docById("wheelDiv2").style.display = "none";
this.notesCircle.removeWheel();
@@ -634,9 +837,9 @@ function TemperamentWidget() {
temperamentTableDiv.innerHTML = "";
temperamentTableDiv.innerHTML =
'
';
- let editMenus = ["Equal", "Ratios", "Arbitrary", "Octave Space"];
+ const editMenus = ["Equal", "Ratios", "Arbitrary", "Octave Space"];
let menus = "";
for (let i = 0; i < editMenus.length; i++) {
@@ -644,9 +847,8 @@ function TemperamentWidget() {
}
docById("menu").innerHTML = menus;
- docById("editOctave").innerHTML +=
- '
|
';
- let menuItems = document.querySelectorAll("#editMenus");
+ docById("editOctave").innerHTML += '
|
';
+ const menuItems = document.querySelectorAll("#editMenus");
for (let i = 0; i < editMenus.length; i++) {
menuItems[i].style.background = platformColor.selectorBackground;
menuItems[i].style.height = 30 + "px";
@@ -657,43 +859,47 @@ function TemperamentWidget() {
menuItems[0].style.background = "#c8C8C8";
this.equalEdit();
- menuItems[0].onclick = function(event) {
+ menuItems[0].onclick = () => {
menuItems[1].style.background = platformColor.selectorBackground;
menuItems[2].style.background = platformColor.selectorBackground;
menuItems[3].style.background = platformColor.selectorBackground;
menuItems[0].style.background = "#c8C8C8";
- that.equalEdit();
+ this.equalEdit();
};
- menuItems[1].onclick = function(event) {
+ menuItems[1].onclick = () => {
menuItems[0].style.background = platformColor.selectorBackground;
menuItems[2].style.background = platformColor.selectorBackground;
menuItems[3].style.background = platformColor.selectorBackground;
menuItems[1].style.background = "#c8C8C8";
- that.ratioEdit();
+ this.ratioEdit();
};
- menuItems[2].onclick = function(event) {
+ menuItems[2].onclick = () => {
menuItems[0].style.background = platformColor.selectorBackground;
menuItems[1].style.background = platformColor.selectorBackground;
menuItems[3].style.background = platformColor.selectorBackground;
menuItems[2].style.background = "#c8C8C8";
- that.arbitraryEdit();
+ this.arbitraryEdit();
};
- menuItems[3].onclick = function(event) {
+ menuItems[3].onclick = () => {
menuItems[0].style.background = platformColor.selectorBackground;
menuItems[1].style.background = platformColor.selectorBackground;
menuItems[2].style.background = platformColor.selectorBackground;
menuItems[3].style.background = "#c8C8C8";
- that.octaveSpaceEdit();
+ this.octaveSpaceEdit();
};
- };
+ }
- this.equalEdit = function() {
+ /**
+ * Triggerred when the Equal edit option is selected.
+ * @returns {void}
+ */
+ equalEdit() {
this.editMode = "equal";
docById("userEdit").innerHTML = "";
- let equalEdit = docById("userEdit");
+ const equalEdit = docById("userEdit");
equalEdit.style.backgroundColor = "#c8C8C8";
equalEdit.innerHTML =
'
Pitch Number
To
';
@@ -702,11 +908,11 @@ function TemperamentWidget() {
this.pitchNumber +
'">';
equalEdit.style.paddingLeft = "80px";
- let that = this;
- function addDivision(preview) {
+ let divAppend;
+ const addDivision = (preview) => {
// Add Buttons
- let divAppend = document.createElement("div");
+ divAppend = document.createElement("div");
divAppend.id = "divAppend";
if (preview) {
divAppend.innerHTML =
@@ -723,7 +929,7 @@ function TemperamentWidget() {
divAppend.style.cursor = "32px";
equalEdit.append(divAppend);
- let divAppend1 = docById("preview");
+ const divAppend1 = docById("preview");
divAppend1.style.height = "30px";
divAppend1.style.marginLeft = "3px";
divAppend1.style.backgroundColor = platformColor.selectorBackground;
@@ -731,7 +937,7 @@ function TemperamentWidget() {
divAppend1.style.lineHeight = "30px";
divAppend1.style.cursor = "pointer";
- let divAppend2 = docById("done_");
+ const divAppend2 = docById("done_");
divAppend2.style.height = "30px";
divAppend2.style.marginRight = "3px";
divAppend2.style.backgroundColor = platformColor.selectorBackground;
@@ -739,31 +945,29 @@ function TemperamentWidget() {
divAppend2.style.lineHeight = "30px";
divAppend2.style.cursor = "pointer";
}
+ };
+
addDivision(false);
- divAppend.onmouseover = function() {
- this.style.cursor = "pointer";
+ divAppend.onmouseover = (event) => {
+ event.target.style.cursor = "pointer";
};
let pitchNumber = this.pitchNumber;
let pitchNumber1 = Number(docById("octaveIn").value);
let pitchNumber2 = Number(docById("octaveOut").value);
let divisions = Number(docById("divisions").value);
- let ratio = [];
- let compareRatios = [];
- let ratio1 = [];
- let ratio2 = [];
- let ratio3 = [];
+ const ratio = [];
+ const compareRatios = [];
+ const ratio1 = [];
+ const ratio2 = [];
+ const ratio3 = [];
let ratio4;
- let index = [];
+ const index = [];
this.tempRatios = [];
- divAppend.addEventListener("click", function(event) {
- that.performEqualEdit(event);
- });
-
- this.performEqualEdit = function(event) {
+ divAppend.addEventListener("click", (event) => {
let angle1, angle2, divisionAngle, power, frequency;
pitchNumber1 = Number(docById("octaveIn").value);
pitchNumber2 = Number(docById("octaveOut").value);
@@ -778,17 +982,17 @@ function TemperamentWidget() {
ratio2[i] = this.tempRatios[i];
ratio2[i] = ratio2[i].toFixed(2);
}
- ratio4 = ratio1.filter(function(val) {
+ ratio4 = ratio1.filter((val) => {
return ratio2.indexOf(val) == -1;
});
- for(let i = 0; i < ratio4.length; i++) {
+ for (let i = 0; i < ratio4.length; i++) {
index[i] = ratio1.indexOf(ratio4[i]);
ratio3[i] = ratio[index[i]];
}
this.tempRatios = this.tempRatios.concat(ratio3);
- this.tempRatios.sort(function(a, b) {
+ this.tempRatios.sort((a, b) => {
return a - b;
});
pitchNumber = this.tempRatios.length - 1;
@@ -796,30 +1000,17 @@ function TemperamentWidget() {
this.divisions = divisions;
} else {
pitchNumber =
- divisions +
- Number(pitchNumber) -
- Math.abs(pitchNumber1 - pitchNumber2);
+ divisions + Number(pitchNumber) - Math.abs(pitchNumber1 - pitchNumber2);
angle1 =
270 +
- 360 *
- (Math.log10(this.tempRatios[pitchNumber1]) /
- Math.log10(this.powerBase));
+ 360 * (Math.log10(this.tempRatios[pitchNumber1]) / Math.log10(this.powerBase));
angle2 =
270 +
- 360 *
- (Math.log10(this.tempRatios[pitchNumber2]) /
- Math.log10(this.powerBase));
+ 360 * (Math.log10(this.tempRatios[pitchNumber2]) / Math.log10(this.powerBase));
divisionAngle = Math.abs(angle2 - angle1) / divisions;
- this.tempRatios.splice(
- pitchNumber1 + 1,
- Math.abs(pitchNumber1 - pitchNumber2) - 1
- );
+ this.tempRatios.splice(pitchNumber1 + 1, Math.abs(pitchNumber1 - pitchNumber2) - 1);
for (let i = 0; i < divisions - 1; i++) {
- power =
- (Math.min(angle1, angle2) +
- divisionAngle * (i + 1) -
- 270) /
- 360;
+ power = (Math.min(angle1, angle2) + divisionAngle * (i + 1) - 270) / 360;
ratio[i] = Math.pow(this.powerBase, power);
this.tempRatios.splice(pitchNumber1 + 1 + i, 0, ratio[i]);
compareRatios[i] = this.tempRatios[i];
@@ -843,16 +1034,13 @@ function TemperamentWidget() {
this._circleOfNotes();
} else if (event.target.innerHTML === "Preview") {
//Preview Notes
- docById("userEdit").innerHTML =
- '
';
+ docById("userEdit").innerHTML = '
';
this.createMainWheel(this.tempRatios, pitchNumber);
for (let i = 0; i < pitchNumber; i++) {
this.notesCircle.navItems[i].fillAttr = "#e0e0e0";
- this.notesCircle.navItems[i].sliceHoverAttr.fill =
- "#e0e0e0";
+ this.notesCircle.navItems[i].sliceHoverAttr.fill = "#e0e0e0";
this.notesCircle.navItems[i].slicePathAttr.fill = "#e0e0e0";
- this.notesCircle.navItems[i].sliceSelectedAttr.fill =
- "#e0e0e0";
+ this.notesCircle.navItems[i].sliceSelectedAttr.fill = "#e0e0e0";
}
this.notesCircle.refreshWheel();
docById("userEdit").style.paddingLeft = "0px";
@@ -861,56 +1049,60 @@ function TemperamentWidget() {
docById("preview").style.marginLeft = "80px";
//make temperary
- ratios = this.tempRatios.slice();
+ this.ratios = this.tempRatios.slice();
frequency = this.frequencies[0];
this.eqTempHzs = [];
for (let i = 0; i <= pitchNumber; i++) {
- this.eqTempHzs[i] = ratios[i] * frequency;
+ this.eqTempHzs[i] = this.ratios[i] * frequency;
this.eqTempHzs[i] = this.eqTempHzs[i].toFixed(2);
}
this.eqTempPitchNumber = pitchNumber;
this.checkTemperament(compareRatios);
- docById("done_").onclick = function() {
+ docById("done_").onclick = () => {
//Go to main Circle of Notes
- that.ratios = that.tempRatios.slice();
- frequency = that.frequencies[0];
- that.frequencies = [];
+ this.ratios = this.tempRatios.slice();
+ frequency = this.frequencies[0];
+ this.frequencies = [];
for (let i = 0; i <= pitchNumber; i++) {
- that.frequencies[i] = that.ratios[i] * frequency;
- that.frequencies[i] = that.frequencies[i].toFixed(2);
+ this.frequencies[i] = this.ratios[i] * frequency;
+ this.frequencies[i] = this.frequencies[i].toFixed(2);
}
- that.pitchNumber = pitchNumber;
- that.eqTempPitchNumber = null ;
- that.eqTempHzs = [] ;
- that.checkTemperament(compareRatios);
- that._circleOfNotes();
+ this.pitchNumber = pitchNumber;
+ this.eqTempPitchNumber = null;
+ this.eqTempHzs = [];
+ this.checkTemperament(compareRatios);
+ this._circleOfNotes();
};
- docById("preview").onclick = function() {
- that.equalEdit();
- that.eqTempPitchNumber = null ;
- that.eqTempHzs = [] ;
+ docById("preview").onclick = () => {
+ this.equalEdit();
+ this.eqTempPitchNumber = null;
+ this.eqTempHzs = [];
};
}
- };
- };
+ });
+ }
- this.ratioEdit = function() {
+ /**
+ * Triggerred when the Ratios edit option is selected.
+ * @returns {void}
+ */
+ ratioEdit() {
this.editMode = "ratio";
docById("userEdit").innerHTML = "";
- let ratioEdit = docById("userEdit");
+ const ratioEdit = docById("userEdit");
ratioEdit.style.backgroundColor = "#c8C8C8";
ratioEdit.innerHTML =
'
Ratio
:
';
ratioEdit.innerHTML +=
'Recursion
';
ratioEdit.style.paddingLeft = "100px";
- let that = this;
- function addButtons(preview) {
- let divAppend = document.createElement("div");
+ let divAppend;
+ const addButtons = (preview) => {
+ divAppend = document.createElement("div");
divAppend.id = "divAppend";
if (preview) {
divAppend.innerHTML =
@@ -927,7 +1119,7 @@ function TemperamentWidget() {
divAppend.style.lineHeight = "32px";
ratioEdit.append(divAppend);
- let divAppend1 = docById("preview");
+ const divAppend1 = docById("preview");
divAppend1.style.height = "30px";
divAppend1.style.marginLeft = "3px";
divAppend1.style.backgroundColor = platformColor.selectorBackground;
@@ -935,166 +1127,166 @@ function TemperamentWidget() {
divAppend1.style.lineHeight = "30px";
divAppend1.style.width = "215px";
- let divAppend2 = docById("done_");
+ const divAppend2 = docById("done_");
divAppend2.style.height = "30px";
divAppend2.style.marginRight = "3px";
divAppend2.style.backgroundColor = platformColor.selectorBackground;
divAppend2.style.cursor = "pointer";
divAppend2.style.lineHeight = "30px";
divAppend2.style.width = "205px";
- }
+ };
addButtons(false);
- divAppend.onmouseover = function() {
- this.style.cursor = "pointer";
+ divAppend.onmouseover = (event) => {
+ event.target.style.cursor = "pointer";
};
- divAppend.onclick = function(event) {
- let input1 = docById("ratioIn").value;
- let input2 = docById("ratioOut").value;
- let recursion = docById("recursion").value;
- let len = that.frequencies.length;
- let ratio1 = input1 / input2;
- let ratio = [];
- let frequency = [];
+ divAppend.onclick = (event) => {
+ const input1 = docById("ratioIn").value;
+ const input2 = docById("ratioOut").value;
+ const recursion = docById("recursion").value;
+ const len = this.frequencies.length;
+ const ratio1 = input1 / input2;
+ const ratio = [];
+ const frequency = [];
let frequency1;
- let ratioDifference = [];
- let index = [];
- let compareRatios = [];
- that.tempRatios = that.ratios.slice();
-
- calculateRatios = function(i) {
- if (frequency[i] < that.frequencies[len - 1]) {
- for (let j = 0; j < that.tempRatios.length; j++) {
- ratioDifference[j] = ratio[i] - that.tempRatios[j];
+ const ratioDifference = [];
+ const index = [];
+ const compareRatios = [];
+ this.tempRatios = this.ratios.slice();
+
+ const calculateRatios = (i) => {
+ if (frequency[i] < this.frequencies[len - 1]) {
+ for (let j = 0; j < this.tempRatios.length; j++) {
+ ratioDifference[j] = ratio[i] - this.tempRatios[j];
if (ratioDifference[j] < 0) {
index.push(j);
- that.tempRatios.splice(index[i], 0, ratio[i]);
+ this.tempRatios.splice(index[i], 0, ratio[i]);
break;
}
if (ratioDifference[j] == 0) {
index.push(j);
- that.tempRatios.splice(index[i], 1, ratio[i]);
+ this.tempRatios.splice(index[i], 1, ratio[i]);
break;
}
}
} else {
ratio[i] = ratio[i] / 2;
- frequency[i] = that.frequencies[0] * ratio[i];
+ frequency[i] = this.frequencies[0] * ratio[i];
calculateRatios(i);
}
};
for (let i = 0; i < recursion; i++) {
ratio[i] = Math.pow(ratio1, i + 1);
- frequency[i] = that.frequencies[0] * ratio[i];
+ frequency[i] = this.frequencies[0] * ratio[i];
calculateRatios(i);
}
- that.tempRatios.sort(function(a, b) {
+ this.tempRatios.sort((a, b) => {
return a - b;
});
- let pitchNumber = that.tempRatios.length - 1;
+ const pitchNumber = this.tempRatios.length - 1;
if (event.target.innerHTML == "Done") {
- that.ratios = that.tempRatios.slice();
- that.typeOfEdit = "nonequal";
- that.pitchNumber = that.ratios.length - 1;
- frequency1 = that.frequencies[0];
- that.frequencies = [];
- for (let i = 0; i <= that.pitchNumber; i++) {
- that.frequencies[i] = that.ratios[i] * frequency1;
- that.frequencies[i] = that.frequencies[i].toFixed(2);
+ this.ratios = this.tempRatios.slice();
+ this.typeOfEdit = "nonequal";
+ this.pitchNumber = this.ratios.length - 1;
+ frequency1 = this.frequencies[0];
+ this.frequencies = [];
+ for (let i = 0; i <= this.pitchNumber; i++) {
+ this.frequencies[i] = this.ratios[i] * frequency1;
+ this.frequencies[i] = this.frequencies[i].toFixed(2);
}
- for (let i = 0; i < that.ratios.length; i++) {
- compareRatios[i] = that.ratios[i];
+ for (let i = 0; i < this.ratios.length; i++) {
+ compareRatios[i] = this.ratios[i];
compareRatios[i] = compareRatios[i].toFixed(2);
}
- that.checkTemperament(compareRatios);
- that._circleOfNotes();
+ this.checkTemperament(compareRatios);
+ this._circleOfNotes();
} else if (event.target.innerHTML == "Preview") {
//Preview Notes
- docById("userEdit").innerHTML =
- '
';
- that.createMainWheel(that.tempRatios, pitchNumber);
+ docById("userEdit").innerHTML = '
';
+ this.createMainWheel(this.tempRatios, pitchNumber);
for (let i = 0; i < pitchNumber; i++) {
- that.notesCircle.navItems[i].fillAttr = "#e0e0e0";
- that.notesCircle.navItems[i].sliceHoverAttr.fill =
- "#e0e0e0";
- that.notesCircle.navItems[i].slicePathAttr.fill = "#e0e0e0";
- that.notesCircle.navItems[i].sliceSelectedAttr.fill =
- "#e0e0e0";
+ this.notesCircle.navItems[i].fillAttr = "#e0e0e0";
+ this.notesCircle.navItems[i].sliceHoverAttr.fill = "#e0e0e0";
+ this.notesCircle.navItems[i].slicePathAttr.fill = "#e0e0e0";
+ this.notesCircle.navItems[i].sliceSelectedAttr.fill = "#e0e0e0";
}
- that.notesCircle.refreshWheel();
+ this.notesCircle.refreshWheel();
docById("userEdit").style.paddingLeft = "0px";
addButtons(true);
divAppend.style.marginTop = docById("wheelDiv2").style.height;
docById("preview").style.marginLeft = "100px";
-
+
//make temperary
- ratios = that.tempRatios.slice();
- that.typeOfEdit = "nonequal";
- that.NEqTempPitchNumber = ratios.length - 1;
- frequency1 = that.frequencies[0];
- that.NEqTempHzs = [];
- for (let i = 0; i <= that.NEqTempPitchNumber; i++) {
- that.NEqTempHzs[i] = ratios[i] * frequency1;
- that.NEqTempHzs[i] = that.NEqTempHzs[i].toFixed(2);
+ this.ratios = this.tempRatios.slice();
+ this.typeOfEdit = "nonequal";
+ this.NEqTempPitchNumber = this.ratios.length - 1;
+ frequency1 = this.frequencies[0];
+ this.NEqTempHzs = [];
+ for (let i = 0; i <= this.NEqTempPitchNumber; i++) {
+ this.NEqTempHzs[i] = this.ratios[i] * frequency1;
+ this.NEqTempHzs[i] = this.NEqTempHzs[i].toFixed(2);
}
- for (let i = 0; i < ratios.length; i++) {
- compareRatios[i] = ratios[i];
+ for (let i = 0; i < this.ratios.length; i++) {
+ compareRatios[i] = this.ratios[i];
compareRatios[i] = compareRatios[i].toFixed(2);
}
- that.checkTemperament(compareRatios);
-
- docById("done_").onclick = function() {
+ this.checkTemperament(compareRatios);
+
+ docById("done_").onclick = () => {
//Go to main Circle of Notes
- that.ratios = that.tempRatios.slice();
- that.pitchNumber = that.ratios.length - 1;
- frequency1 = that.frequencies[0];
- that.frequencies = [];
- for (let i = 0; i <= that.pitchNumber; i++) {
- that.frequencies[i] = that.ratios[i] * frequency1;
- that.frequencies[i] = that.frequencies[i].toFixed(2);
+ this.ratios = this.tempRatios.slice();
+ this.pitchNumber = this.ratios.length - 1;
+ frequency1 = this.frequencies[0];
+ this.frequencies = [];
+ for (let i = 0; i <= this.pitchNumber; i++) {
+ this.frequencies[i] = this.ratios[i] * frequency1;
+ this.frequencies[i] = this.frequencies[i].toFixed(2);
}
- for (let i = 0; i < that.ratios.length; i++) {
- compareRatios[i] = that.ratios[i];
+ for (let i = 0; i < this.ratios.length; i++) {
+ compareRatios[i] = this.ratios[i];
compareRatios[i] = compareRatios[i].toFixed(2);
}
- that.checkTemperament(compareRatios);
- that._circleOfNotes();
- that.NEqTempPitchNumber = null ;
- that.NEqTempHzs = [] ;
+ this.checkTemperament(compareRatios);
+ this._circleOfNotes();
+ this.NEqTempPitchNumber = null;
+ this.NEqTempHzs = [];
};
- docById("preview").onclick = function() {
- that.ratioEdit();
- that.NEqTempPitchNumber = null ;
- that.NEqTempHzs = [] ;
+ docById("preview").onclick = () => {
+ this.ratioEdit();
+ this.NEqTempPitchNumber = null;
+ this.NEqTempHzs = [];
};
}
};
- };
+ }
- this.arbitraryEdit = function() {
- this.editMode = "arbitrary" ;
+ /**
+ * Triggerred when the Arbitrary edit option is selected.
+ * @returns {void}
+ */
+ arbitraryEdit() {
+ this.editMode = "arbitrary";
docById("userEdit").innerHTML = "";
- let arbitraryEdit = docById("userEdit");
- arbitraryEdit.innerHTML =
- '
';
+ const arbitraryEdit = docById("userEdit");
+ arbitraryEdit.innerHTML = '
';
arbitraryEdit.style.paddingLeft = "0px";
- let radius = 128;
- let height = 2 * radius;
+ const radius = 128;
+ const height = 2 * radius;
let angle1 = [];
this.tempRatios1 = this.ratios.slice();
- this._createInnerWheel = function(ratios, pitchNumber) {
+ this._createInnerWheel = (ratios, pitchNumber) => {
if (this.wheel1 !== undefined) {
docById("wheelDiv4").display = "none";
this.wheel1.removeWheel();
@@ -1105,7 +1297,7 @@ function TemperamentWidget() {
if (pitchNumber == undefined) {
pitchNumber = this.pitchNumber;
}
- let labels = [];
+ const labels = [];
let label;
for (let j = 0; j < pitchNumber; j++) {
label = j.toString();
@@ -1127,19 +1319,16 @@ function TemperamentWidget() {
this.wheel1.sliceInitPathCustom = this.wheel1.slicePathCustom;
this.wheel1.initWheel(labels);
- let baseAngle = [];
- let sliceAngle = [];
- let angle = [];
- let angleDiff = [];
+ const baseAngle = [];
+ const sliceAngle = [];
+ const angle = [];
+ const angleDiff = [];
for (let i = 0; i < this.wheel1.navItemCount; i++) {
this.wheel1.navItems[i].fillAttr = "#e0e0e0";
- this.wheel1.navItems[i].titleAttr.font =
- "20 20px Impact, Charcoal, sans-serif";
+ this.wheel1.navItems[i].titleAttr.font = "20 20px Impact, Charcoal, sans-serif";
this.wheel1.navItems[i].titleSelectedAttr.font =
"20 20px Impact, Charcoal, sans-serif";
- angle[i] =
- 270 +
- 360 * (Math.log10(ratios[i]) / Math.log10(this.powerBase));
+ angle[i] = 270 + 360 * (Math.log10(ratios[i]) / Math.log10(this.powerBase));
if (i !== 0) {
if (i == this.pitchNumber - 1) {
angleDiff[i - 1] = angle[0] + 360 - angle[i];
@@ -1168,30 +1357,29 @@ function TemperamentWidget() {
this.wheel1.slicePathCustom.menuRadius = menuRadius;
if (docById("frequencySlider") !== null) {
- docById("frequencySlider").oninput = function() {
- that._refreshInnerWheel();
+ docById("frequencySlider").oninput = () => {
+ this._refreshInnerWheel();
};
}
this.wheel1.createWheel();
};
- arbitraryEdit.innerHTML +=
- '
';
+ arbitraryEdit.innerHTML += '
';
this._createInnerWheel();
arbitraryEdit.innerHTML +=
'