From 2cc19719549e8e82137280edb13c49392b92f9b8 Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Mon, 15 Feb 2021 19:44:36 +0530 Subject: [PATCH 01/13] Temperament: Bug Fix on stopping --- js/widgets/temperament.js | 91 +++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 3da839ffcb..ad2e469f2d 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -1468,7 +1468,7 @@ class TemperamentWidget { docById("wheelDiv3").addEventListener("mouseover", (e) => { this.arbitraryEditSlider(e, angle1, ratios, pitchNumber); }); - },1500); + }, 1500); }; this._createOuterWheel(); @@ -2005,7 +2005,10 @@ class TemperamentWidget { let p = 0; this.playbackForward = true; this._playing = !this._playing; - + if (!this._playing) { + logo.synth.setMasterVolume(0); + return; + } logo.resetSynth(0); const cell = this.playButton; @@ -2060,6 +2063,7 @@ class TemperamentWidget { } const __playLoop = (i) => { + console.log("Play Loop Called for " + i); let j; if (i === pitchNumber) { this.playbackForward = false; @@ -2078,7 +2082,6 @@ class TemperamentWidget { ); this.playNote(i); } - if (this.circleIsVisible == false && docById("wheelDiv4") == null) { if (i === pitchNumber) { this.notesCircle.navItems[0].fillAttr = "#808080"; @@ -2169,46 +2172,52 @@ class TemperamentWidget { i -= 1; } - if (i <= pitchNumber && i >= 0 && this._playing && p < 2) { + if (i <= pitchNumber && i >= 0 && p < 2) { setTimeout(() => { - __playLoop(i); - }, Singer.defaultBPMFactor * 1000 * duration); - } else { - cell.innerHTML = - '  ' +
-                    _(  '; - if (i !== -1) { - setTimeout(() => { - if (this.circleIsVisible == false && docById("wheelDiv4") == null) { - this.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8"; - this.notesCircle.refreshWheel(); - } else if (this.circleIsVisible == true && docById("wheelDiv4") == null) { - j = i - 1; - docById("pitchNumber_" + j).style.background = - platformColor.selectorBackground; - } else if (docById("wheelDiv4") !== null) { - this.wheel1.navItems[i - 1].fillAttr = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0"; - - this.wheel1.refreshWheel(); + if (!this._playing) { + cell.innerHTML = + '  ' +
+                            _(  '; + if (i !== -1) { + if (this.circleIsVisible == false && docById("wheelDiv4") == null) { + this.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8"; + this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = + "#c8C8C8"; + this.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = + "#c8C8C8"; + this.notesCircle.refreshWheel(); + } else if ( + this.circleIsVisible == true && + docById("wheelDiv4") == null + ) { + j = i - 1; + docById("pitchNumber_" + j).style.background = + platformColor.selectorBackground; + } else if (docById("wheelDiv4") !== null) { + this.wheel1.navItems[i - 1].fillAttr = "#e0e0e0"; + this.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0"; + this.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0"; + this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0"; + + this.wheel1.refreshWheel(); + } } - }, Singer.defaultBPMFactor * 1000 * duration); - } - this._playing = false; + this._playing = false; + } + else{ + __playLoop(i); + } + }, Singer.defaultBPMFactor * 1000 * duration); } }; if (this._playing) { From d2b0dcffdeca9ca80c40f2d003b8266e07e8f8dc Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Mon, 15 Feb 2021 21:36:22 +0530 Subject: [PATCH 02/13] Bug Fix on closing the temperament widget --- js/widgets/temperament.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index ad2e469f2d..e7ad5b1f9c 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -54,6 +54,7 @@ class TemperamentWidget { this.pitchNumber = 0; this.circleIsVisible = true; this.playbackForward = true; + this.closed = false; } /** @@ -74,8 +75,8 @@ class TemperamentWidget { widgetWindow.getWidgetBody().style.width = "500px"; widgetWindow.onclose = () => { + this.closed = true; logo.synth.setMasterVolume(0); - logo.synth.stop(); if (docById("wheelDiv2") != null) { docById("wheelDiv2").style.display = "none"; this.notesCircle.removeWheel(); @@ -2063,7 +2064,6 @@ class TemperamentWidget { } const __playLoop = (i) => { - console.log("Play Loop Called for " + i); let j; if (i === pitchNumber) { this.playbackForward = false; @@ -2174,7 +2174,11 @@ class TemperamentWidget { if (i <= pitchNumber && i >= 0 && p < 2) { setTimeout(() => { - if (!this._playing) { + if(this.closed){ + this.closed = !(this.closed); + return; + } + else if ((!this._playing)) { cell.innerHTML = '   Date: Mon, 15 Feb 2021 22:18:12 +0530 Subject: [PATCH 03/13] Bug Fix in case of counter-clockwise direction --- js/widgets/temperament.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index e7ad5b1f9c..7829d9b2be 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2199,6 +2199,20 @@ class TemperamentWidget { this.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8"; this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8"; + if(i==11){ + //on completion of a full circle and on hitting '0' note in clockwise direction + this.notesCircle.navItems[0].fillAttr = "#c8C8C8"; + this.notesCircle.navItems[0].sliceHoverAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[0].slicePathAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[0].sliceSelectedAttr.fill = "#c8C8C8"; + } + else if(i<11){ + //in case of counter-clockwise direction, i.e., when this.playbackForward = false + this.notesCircle.navItems[i + 1].fillAttr = "#c8C8C8"; + this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i + 1].slicePathAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = "#c8C8C8"; + } this.notesCircle.refreshWheel(); } else if ( this.circleIsVisible == true && From 280d1b93502ecea06018666242685ab5fcd372a4 Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Mon, 15 Feb 2021 22:25:06 +0530 Subject: [PATCH 04/13] Fix error in case of stoppin and closing --- js/widgets/temperament.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 7829d9b2be..559158c81d 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -75,7 +75,9 @@ class TemperamentWidget { widgetWindow.getWidgetBody().style.width = "500px"; widgetWindow.onclose = () => { - this.closed = true; + if (this._playing) { + this.closed = true; + } logo.synth.setMasterVolume(0); if (docById("wheelDiv2") != null) { docById("wheelDiv2").style.display = "none"; @@ -2174,11 +2176,10 @@ class TemperamentWidget { if (i <= pitchNumber && i >= 0 && p < 2) { setTimeout(() => { - if(this.closed){ - this.closed = !(this.closed); + if (this.closed) { + this.closed = !this.closed; return; - } - else if ((!this._playing)) { + } else if (!this._playing) { cell.innerHTML = '   Date: Tue, 16 Feb 2021 10:09:07 +0530 Subject: [PATCH 05/13] Removed the step to set the volume to 0 --- js/widgets/temperament.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 559158c81d..0b9562bb1e 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2009,7 +2009,6 @@ class TemperamentWidget { this.playbackForward = true; this._playing = !this._playing; if (!this._playing) { - logo.synth.setMasterVolume(0); return; } logo.resetSynth(0); From 4f92613fe89e92eada7c5126d40940f55ccd1e81 Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Tue, 16 Feb 2021 14:03:57 +0530 Subject: [PATCH 06/13] Fix error on completion of two cycles --- js/widgets/temperament.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 0b9562bb1e..7b12c2f9f2 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2234,6 +2234,22 @@ class TemperamentWidget { } }, Singer.defaultBPMFactor * 1000 * duration); } + else{ + this._playing = false; + cell.innerHTML = + '  ' +
+                            _(  '; + console.log("completed"); + } }; if (this._playing) { __playLoop(0); From 264141695af4e1061531555846d82f25e16d9b8c Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Tue, 16 Feb 2021 14:16:17 +0530 Subject: [PATCH 07/13] Remove log statement --- js/widgets/temperament.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 7b12c2f9f2..16f5d5257b 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2233,22 +2233,20 @@ class TemperamentWidget { __playLoop(i); } }, Singer.defaultBPMFactor * 1000 * duration); - } - else{ + } else { this._playing = false; cell.innerHTML = - '  ' +
-                            _(  '; - console.log("completed"); + '  ' +
+                    _(  '; } }; if (this._playing) { From c48a5188a9c0b969d600e12da382fb776a872c32 Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Tue, 16 Feb 2021 17:38:51 +0530 Subject: [PATCH 08/13] Remove unneccesary code --- js/widgets/temperament.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 16f5d5257b..9af11e047b 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2027,21 +2027,6 @@ class TemperamentWidget { '" width="' + TemperamentWidget.ICONSIZE + '" vertical-align="middle" align-content="center">  '; - } else { - logo.synth.setMasterVolume(0); - logo.synth.stop(); - cell.innerHTML = - '  ' +
-                _(  '; } const duration = 1 / 2; @@ -2249,8 +2234,6 @@ class TemperamentWidget { '" vertical-align="middle" align-content="center">  '; } }; - if (this._playing) { - __playLoop(0); - } + } } From 31d25c64af5319dcc3c2f2a71b986ccac9b0cd51 Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Tue, 16 Feb 2021 17:49:09 +0530 Subject: [PATCH 09/13] Correct a mistake --- js/widgets/temperament.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 9af11e047b..e67dd91b63 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2234,6 +2234,8 @@ class TemperamentWidget { '" vertical-align="middle" align-content="center">  '; } }; - + if (this._playing) { + __playLoop(0); + } } } From aadd9431640566c8924f139e7f79a22f0067d98c Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Wed, 17 Feb 2021 13:32:22 +0530 Subject: [PATCH 10/13] Fix Error: Assignment to constant variable --- js/widgets/temperament.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index e67dd91b63..2d70f5bf29 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -16,7 +16,7 @@ /* global platformColor, docById, wheelnav, slicePath, logo, Singer, isCustom, - TEMPERAMENT, OCTAVERATIO: true, rationalToFraction, _, getNoteFromInterval, + TEMPERAMENT, rationalToFraction, _, getNoteFromInterval, FLAT, SHARP, pitchToFrequency, updateTemperaments, _buildScale */ @@ -1763,8 +1763,7 @@ class TemperamentWidget { } } - // Global value - OCTAVERATIO = this.powerBase; + const OctaveRatio = this.powerBase; const value = logo.blocks.findUniqueTemperamentName(this.inTemperament); this.inTemperament = value; // change from temporary "custom" to "custom1" or "custom2" .. @@ -1776,8 +1775,8 @@ class TemperamentWidget { [4, ["number", { value: this.frequencies[0] }], 0, 0, [2]], [5, ["octavespace"], 0, 0, [2, 6, 9]], [6, ["divide"], 0, 0, [5, 7, 8]], - [7, ["number", { value: rationalToFraction(OCTAVERATIO)[0] }], 0, 0, [6]], - [8, ["number", { value: rationalToFraction(OCTAVERATIO)[1] }], 0, 0, [6]], + [7, ["number", { value: rationalToFraction(OctaveRatio)[0] }], 0, 0, [6]], + [8, ["number", { value: rationalToFraction(OctaveRatio)[1] }], 0, 0, [6]], [9, "vspace", 0, 0, [5, 10]] ]; let previousBlock = 9; From 89ed125a642ce5ed4fc512cd3a6a013dd7a6ab0a Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Thu, 18 Feb 2021 17:47:25 +0530 Subject: [PATCH 11/13] Assign colours to static variables --- js/widgets/temperament.js | 166 +++++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 67 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 2d70f5bf29..5a6bf92cce 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -37,6 +37,9 @@ class TemperamentWidget { static INNERWINDOWWIDTH = 600; static BUTTONSIZE = 53; static ICONSIZE = 32; + static LIGHTGREY = "#e0e0e0"; + static GREY = "#c8c8c8"; + static DARKGREY = "#808080"; /** * @constructor @@ -367,7 +370,7 @@ class TemperamentWidget { const sliceAngle = []; const angleDiff = []; for (let i = 0; i < this.notesCircle.navItemCount; i++) { - this.notesCircle.navItems[i].fillAttr = "#c8C8C8"; + this.notesCircle.navItems[i].fillAttr = TemperamentWidget.GREY; this.notesCircle.navItems[i].titleAttr.font = "20 20px Impact, Charcoal, sans-serif"; this.notesCircle.navItems[i].titleSelectedAttr.font = @@ -1051,10 +1054,11 @@ class TemperamentWidget { 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].slicePathAttr.fill = "#e0e0e0"; - this.notesCircle.navItems[i].sliceSelectedAttr.fill = "#e0e0e0"; + this.notesCircle.navItems[i].fillAttr = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].sliceHoverAttr.fill = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].slicePathAttr.fill = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; } this.notesCircle.refreshWheel(); docById("userEdit").style.paddingLeft = "0px"; @@ -1222,10 +1226,11 @@ class TemperamentWidget { 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].slicePathAttr.fill = "#e0e0e0"; - this.notesCircle.navItems[i].sliceSelectedAttr.fill = "#e0e0e0"; + this.notesCircle.navItems[i].fillAttr = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].sliceHoverAttr.fill = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].slicePathAttr.fill = TemperamentWidget.LIGHTGREY; + this.notesCircle.navItems[i].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; } this.notesCircle.refreshWheel(); docById("userEdit").style.paddingLeft = "0px"; @@ -1338,7 +1343,7 @@ class TemperamentWidget { const angle = []; const angleDiff = []; for (let i = 0; i < this.wheel1.navItemCount; i++) { - this.wheel1.navItems[i].fillAttr = "#e0e0e0"; + this.wheel1.navItems[i].fillAttr = TemperamentWidget.LIGHTGREY; this.wheel1.navItems[i].titleAttr.font = "20 20px Impact, Charcoal, sans-serif"; this.wheel1.navItems[i].titleSelectedAttr.font = "20 20px Impact, Charcoal, sans-serif"; @@ -1425,7 +1430,7 @@ class TemperamentWidget { this.wheel.slicePathCustom.maxRadiusPercent = 1.0; this.wheel.sliceSelectedPathCustom = this.wheel.slicePathCustom; this.wheel.sliceInitPathCustom = this.wheel.slicePathCustom; - this.wheel.colors = ["#c0c0c0", "#e0e0e0"]; + this.wheel.colors = ["#c0c0c0", TemperamentWidget.LIGHTGREY]; this.wheel.titleRotateAngle = 90; this.wheel.navItemsEnabled = false; @@ -2069,35 +2074,44 @@ class TemperamentWidget { } if (this.circleIsVisible == false && docById("wheelDiv4") == null) { if (i === pitchNumber) { - this.notesCircle.navItems[0].fillAttr = "#808080"; - this.notesCircle.navItems[0].sliceHoverAttr.fill = "#808080"; - this.notesCircle.navItems[0].slicePathAttr.fill = "#808080"; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = "#808080"; + this.notesCircle.navItems[0].fillAttr = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[0].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[0].slicePathAttr.fill = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[0].sliceSelectedAttr.fill = + TemperamentWidget.DARKGREY; } else { - this.notesCircle.navItems[i].fillAttr = "#808080"; - this.notesCircle.navItems[i].sliceHoverAttr.fill = "#808080"; - this.notesCircle.navItems[i].slicePathAttr.fill = "#808080"; - this.notesCircle.navItems[i].sliceSelectedAttr.fill = "#808080"; + this.notesCircle.navItems[i].fillAttr = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[i].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[i].slicePathAttr.fill = TemperamentWidget.DARKGREY; + this.notesCircle.navItems[i].sliceSelectedAttr.fill = + TemperamentWidget.DARKGREY; } if (this.playbackForward == false && i < pitchNumber) { if (i === pitchNumber - 1) { - this.notesCircle.navItems[0].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[0].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[0].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[0].fillAttr = TemperamentWidget.GREY; + this.notesCircle.navItems[0].sliceHoverAttr.fill = TemperamentWidget.GREY; + this.notesCircle.navItems[0].slicePathAttr.fill = TemperamentWidget.GREY; + this.notesCircle.navItems[0].sliceSelectedAttr.fill = + TemperamentWidget.GREY; } else { - this.notesCircle.navItems[i + 1].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i + 1].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i + 1].fillAttr = TemperamentWidget.GREY; + this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i + 1].slicePathAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = + TemperamentWidget.GREY; } } else { if (i !== 0) { - this.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i - 1].fillAttr = TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].slicePathAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = + TemperamentWidget.GREY; } } @@ -2116,35 +2130,42 @@ class TemperamentWidget { } } else if (docById("wheelDiv4") !== null) { if (i === pitchNumber) { - this.wheel1.navItems[0].fillAttr = "#808080"; - this.wheel1.navItems[0].sliceHoverAttr.fill = "#808080"; - this.wheel1.navItems[0].slicePathAttr.fill = "#808080"; - this.wheel1.navItems[0].sliceSelectedAttr.fill = "#808080"; + this.wheel1.navItems[0].fillAttr = TemperamentWidget.DARKGREY; + this.wheel1.navItems[0].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; + this.wheel1.navItems[0].slicePathAttr.fill = TemperamentWidget.DARKGREY; + this.wheel1.navItems[0].sliceSelectedAttr.fill = TemperamentWidget.DARKGREY; } else { - this.wheel1.navItems[i].fillAttr = "#808080"; - this.wheel1.navItems[i].sliceHoverAttr.fill = "#808080"; - this.wheel1.navItems[i].slicePathAttr.fill = "#808080"; - this.wheel1.navItems[i].sliceSelectedAttr.fill = "#808080"; + this.wheel1.navItems[i].fillAttr = TemperamentWidget.DARKGREY; + this.wheel1.navItems[i].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; + this.wheel1.navItems[i].slicePathAttr.fill = TemperamentWidget.DARKGREY; + this.wheel1.navItems[i].sliceSelectedAttr.fill = TemperamentWidget.DARKGREY; } if (this.playbackForward == false && i < pitchNumber) { if (i === pitchNumber - 1) { - this.wheel1.navItems[0].fillAttr = "#e0e0e0"; - this.wheel1.navItems[0].sliceHoverAttr.fill = "#e0e0e0"; - this.wheel1.navItems[0].slicePathAttr.fill = "#e0e0e0"; - this.wheel1.navItems[0].sliceSelectedAttr.fill = "#e0e0e0"; + this.wheel1.navItems[0].fillAttr = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[0].sliceHoverAttr.fill = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[0].slicePathAttr.fill = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[0].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; } else { - this.wheel1.navItems[i + 1].fillAttr = "#e0e0e0"; - this.wheel1.navItems[i + 1].sliceHoverAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i + 1].slicePathAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i + 1].sliceSelectedAttr.fill = "#e0e0e0"; + this.wheel1.navItems[i + 1].fillAttr = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i + 1].sliceHoverAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i + 1].slicePathAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i + 1].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; } } else { if (i !== 0) { - this.wheel1.navItems[i - 1].fillAttr = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0"; + this.wheel1.navItems[i - 1].fillAttr = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].sliceHoverAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].slicePathAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; } } @@ -2177,24 +2198,32 @@ class TemperamentWidget { '" vertical-align="middle" align-content="center">  '; if (i !== -1) { if (this.circleIsVisible == false && docById("wheelDiv4") == null) { - this.notesCircle.navItems[i - 1].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[i - 1].fillAttr = TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].slicePathAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = + TemperamentWidget.GREY; if (i == 11) { //on completion of a full circle and on hitting '0' note in clockwise direction - this.notesCircle.navItems[0].fillAttr = "#c8C8C8"; - this.notesCircle.navItems[0].sliceHoverAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[0].slicePathAttr.fill = "#c8C8C8"; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = "#c8C8C8"; + this.notesCircle.navItems[0].fillAttr = TemperamentWidget.GREY; + this.notesCircle.navItems[0].sliceHoverAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[0].slicePathAttr.fill = + TemperamentWidget.GREY; + this.notesCircle.navItems[0].sliceSelectedAttr.fill = + TemperamentWidget.GREY; } else if (i < 11) { //in case of counter-clockwise direction, i.e., when this.playbackForward = false - this.notesCircle.navItems[i + 1].fillAttr = "#c8C8C8"; + this.notesCircle.navItems[i + 1].fillAttr = + TemperamentWidget.GREY; this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = - "#c8C8C8"; - this.notesCircle.navItems[i + 1].slicePathAttr.fill = "#c8C8C8"; + TemperamentWidget.GREY; + this.notesCircle.navItems[i + 1].slicePathAttr.fill = + TemperamentWidget.GREY; this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = - "#c8C8C8"; + TemperamentWidget.GREY; } this.notesCircle.refreshWheel(); } else if ( @@ -2205,10 +2234,13 @@ class TemperamentWidget { docById("pitchNumber_" + j).style.background = platformColor.selectorBackground; } else if (docById("wheelDiv4") !== null) { - this.wheel1.navItems[i - 1].fillAttr = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceHoverAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].slicePathAttr.fill = "#e0e0e0"; - this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = "#e0e0e0"; + this.wheel1.navItems[i - 1].fillAttr = TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].sliceHoverAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].slicePathAttr.fill = + TemperamentWidget.LIGHTGREY; + this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = + TemperamentWidget.LIGHTGREY; this.wheel1.refreshWheel(); } } From 0140cdfe6625959cb780c308771d76c883fd410c Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Thu, 18 Feb 2021 18:52:21 +0530 Subject: [PATCH 12/13] Make function updateNotesCircle() to remove repeatition in code --- js/widgets/temperament.js | 101 ++++++++------------------------------ 1 file changed, 21 insertions(+), 80 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index 5a6bf92cce..e81694f6c2 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -2053,6 +2053,13 @@ class TemperamentWidget { pitchNumber = this.tempRatios1.length - 1; } + const updateNotesCircle = (index,color) => { + this.notesCircle.navItems[index].fillAttr = color; + this.notesCircle.navItems[index].sliceHoverAttr.fill = color; + this.notesCircle.navItems[index].slicePathAttr.fill = color; + this.notesCircle.navItems[index].sliceSelectedAttr.fill = color; + }; + const __playLoop = (i) => { let j; if (i === pitchNumber) { @@ -2074,44 +2081,20 @@ class TemperamentWidget { } if (this.circleIsVisible == false && docById("wheelDiv4") == null) { if (i === pitchNumber) { - this.notesCircle.navItems[0].fillAttr = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[0].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[0].slicePathAttr.fill = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = - TemperamentWidget.DARKGREY; + updateNotesCircle(0,TemperamentWidget.DARKGREY); } else { - this.notesCircle.navItems[i].fillAttr = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[i].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[i].slicePathAttr.fill = TemperamentWidget.DARKGREY; - this.notesCircle.navItems[i].sliceSelectedAttr.fill = - TemperamentWidget.DARKGREY; + updateNotesCircle(i,TemperamentWidget.DARKGREY); } if (this.playbackForward == false && i < pitchNumber) { if (i === pitchNumber - 1) { - this.notesCircle.navItems[0].fillAttr = TemperamentWidget.GREY; - this.notesCircle.navItems[0].sliceHoverAttr.fill = TemperamentWidget.GREY; - this.notesCircle.navItems[0].slicePathAttr.fill = TemperamentWidget.GREY; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(0,TemperamentWidget.GREY); } else { - this.notesCircle.navItems[i + 1].fillAttr = TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].slicePathAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(i + 1,TemperamentWidget.GREY); } } else { if (i !== 0) { - this.notesCircle.navItems[i - 1].fillAttr = TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].slicePathAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(i - 1,TemperamentWidget.GREY); } } @@ -2130,42 +2113,20 @@ class TemperamentWidget { } } else if (docById("wheelDiv4") !== null) { if (i === pitchNumber) { - this.wheel1.navItems[0].fillAttr = TemperamentWidget.DARKGREY; - this.wheel1.navItems[0].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; - this.wheel1.navItems[0].slicePathAttr.fill = TemperamentWidget.DARKGREY; - this.wheel1.navItems[0].sliceSelectedAttr.fill = TemperamentWidget.DARKGREY; + updateNotesCircle(0,TemperamentWidget.DARKGREY); } else { - this.wheel1.navItems[i].fillAttr = TemperamentWidget.DARKGREY; - this.wheel1.navItems[i].sliceHoverAttr.fill = TemperamentWidget.DARKGREY; - this.wheel1.navItems[i].slicePathAttr.fill = TemperamentWidget.DARKGREY; - this.wheel1.navItems[i].sliceSelectedAttr.fill = TemperamentWidget.DARKGREY; + updateNotesCircle(i,TemperamentWidget.DARKGREY); } if (this.playbackForward == false && i < pitchNumber) { if (i === pitchNumber - 1) { - this.wheel1.navItems[0].fillAttr = TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[0].sliceHoverAttr.fill = TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[0].slicePathAttr.fill = TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[0].sliceSelectedAttr.fill = - TemperamentWidget.LIGHTGREY; + updateNotesCircle(0,TemperamentWidget.LIGHTGREY); } else { - this.wheel1.navItems[i + 1].fillAttr = TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i + 1].sliceHoverAttr.fill = - TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i + 1].slicePathAttr.fill = - TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i + 1].sliceSelectedAttr.fill = - TemperamentWidget.LIGHTGREY; + updateNotesCircle(i + 1,TemperamentWidget.LIGHTGREY); } } else { if (i !== 0) { - this.wheel1.navItems[i - 1].fillAttr = TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i - 1].sliceHoverAttr.fill = - TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i - 1].slicePathAttr.fill = - TemperamentWidget.LIGHTGREY; - this.wheel1.navItems[i - 1].sliceSelectedAttr.fill = - TemperamentWidget.LIGHTGREY; + updateNotesCircle(i - 1,TemperamentWidget.LIGHTGREY); } } @@ -2198,40 +2159,20 @@ class TemperamentWidget { '" vertical-align="middle" align-content="center">  '; if (i !== -1) { if (this.circleIsVisible == false && docById("wheelDiv4") == null) { - this.notesCircle.navItems[i - 1].fillAttr = TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].sliceHoverAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].slicePathAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i - 1].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(i - 1,TemperamentWidget.GREY); if (i == 11) { //on completion of a full circle and on hitting '0' note in clockwise direction - this.notesCircle.navItems[0].fillAttr = TemperamentWidget.GREY; - this.notesCircle.navItems[0].sliceHoverAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[0].slicePathAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[0].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(0,TemperamentWidget.GREY); } else if (i < 11) { //in case of counter-clockwise direction, i.e., when this.playbackForward = false - this.notesCircle.navItems[i + 1].fillAttr = - TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].sliceHoverAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].slicePathAttr.fill = - TemperamentWidget.GREY; - this.notesCircle.navItems[i + 1].sliceSelectedAttr.fill = - TemperamentWidget.GREY; + updateNotesCircle(i + 1,TemperamentWidget.GREY); } this.notesCircle.refreshWheel(); } else if ( this.circleIsVisible == true && docById("wheelDiv4") == null ) { - j = i - 1; - docById("pitchNumber_" + j).style.background = + docById("pitchNumber_" + (i - 1)).style.background = platformColor.selectorBackground; } else if (docById("wheelDiv4") !== null) { this.wheel1.navItems[i - 1].fillAttr = TemperamentWidget.LIGHTGREY; From a9b0afac012fee4f996ae87684314c67bd3f9dbe Mon Sep 17 00:00:00 2001 From: Daksh Doshi Date: Tue, 2 Mar 2021 19:50:07 +0530 Subject: [PATCH 13/13] Revert "Fix Error: Assignment to constant variable" This reverts commit aadd9431640566c8924f139e7f79a22f0067d98c. --- js/widgets/temperament.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/widgets/temperament.js b/js/widgets/temperament.js index e81694f6c2..6f4d01ff64 100644 --- a/js/widgets/temperament.js +++ b/js/widgets/temperament.js @@ -16,7 +16,7 @@ /* global platformColor, docById, wheelnav, slicePath, logo, Singer, isCustom, - TEMPERAMENT, rationalToFraction, _, getNoteFromInterval, + TEMPERAMENT, OCTAVERATIO: true, rationalToFraction, _, getNoteFromInterval, FLAT, SHARP, pitchToFrequency, updateTemperaments, _buildScale */ @@ -1768,7 +1768,8 @@ class TemperamentWidget { } } - const OctaveRatio = this.powerBase; + // Global value + OCTAVERATIO = this.powerBase; const value = logo.blocks.findUniqueTemperamentName(this.inTemperament); this.inTemperament = value; // change from temporary "custom" to "custom1" or "custom2" .. @@ -1780,8 +1781,8 @@ class TemperamentWidget { [4, ["number", { value: this.frequencies[0] }], 0, 0, [2]], [5, ["octavespace"], 0, 0, [2, 6, 9]], [6, ["divide"], 0, 0, [5, 7, 8]], - [7, ["number", { value: rationalToFraction(OctaveRatio)[0] }], 0, 0, [6]], - [8, ["number", { value: rationalToFraction(OctaveRatio)[1] }], 0, 0, [6]], + [7, ["number", { value: rationalToFraction(OCTAVERATIO)[0] }], 0, 0, [6]], + [8, ["number", { value: rationalToFraction(OCTAVERATIO)[1] }], 0, 0, [6]], [9, "vspace", 0, 0, [5, 10]] ]; let previousBlock = 9;