-
Notifications
You must be signed in to change notification settings - Fork 823
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
Bug Fix, Temperament Widget: Play and Stop not working properly #2845
Conversation
Please review @meganindya @walterbender. |
js/widgets/temperament.js
Outdated
@@ -2005,7 +2005,10 @@ class TemperamentWidget { | |||
let p = 0; | |||
this.playbackForward = true; | |||
this._playing = !this._playing; | |||
|
|||
if (!this._playing) { | |||
logo.synth.setMasterVolume(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we want to mess with the Master volume. It may have broader impacts. Why not just exit the loop? (See the mode widget, that does something similar.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just returning out of the loop would work perfectly.
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this commit. Please review again.
Thanks.
js/widgets/temperament.js
Outdated
@@ -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){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add spaces around operators
js/widgets/temperament.js
Outdated
this.notesCircle.navItems[0].slicePathAttr.fill = "#c8C8C8"; | ||
this.notesCircle.navItems[0].sliceSelectedAttr.fill = "#c8C8C8"; | ||
} | ||
else if(i<11){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spaces...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temperament.js:1767 Uncaught TypeError: Assignment to constant variable.
at TemperamentWidget._save (temperament.js:1767)
at HTMLDivElement.widgetWindow.addButton.onclick (temperament.js:130)
Also, stop button doesn't reset after playing all the notes up and down is over.
I fixed this. Please check and review @meganindya |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't fixed
temperament.js:1767 Uncaught TypeError: Assignment to constant variable.
at TemperamentWidget._save (temperament.js:1767)
at HTMLDivElement.widgetWindow.addButton.onclick (temperament.js:130)
temperament.js:1471 Uncaught TypeError: Cannot read property 'addEventListener' of null
at temperament.js:1471
The error Also,can you specify when does this second error occur, because this event listener seems to work fine and it also generates the |
Hi @meganindya, Can you verify if this is happening in your environment setup too or is it just in mine? |
js/widgets/temperament.js
Outdated
@@ -1760,8 +1763,7 @@ class TemperamentWidget { | |||
} | |||
} | |||
|
|||
// Global value | |||
OCTAVERATIO = this.powerBase; | |||
const OctaveRatio = this.powerBase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
global constant ? simple rename?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it worked here perfectly.
Actually, making the variable OCTAVERATIO
as let
in the musicutils.js file didn't work. Thus, this step.
js/widgets/temperament.js
Outdated
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c8C8C8 should be a constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, how will it be beneficial?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One advantage of using a constant symbol instead of a magic number/string is that you can express the semantics of the value more precisely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
js/widgets/temperament.js
Outdated
this.circleIsVisible == true && | ||
docById("wheelDiv4") == null | ||
) { | ||
j = i - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
omit variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable can be omitted, it's a bad practice to declare temp variables if they are used only once.
i,j => naming should be meaningful for other people who read your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
js/widgets/temperament.js
Outdated
//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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at a particular position(i) you are setting value of nav items to a particular colour.
You can use a function. which changes this.notesCircle.navItems[pos].fillAttr = COLOUR
and call it in the code.
It will be a lot cleaner and maintainable in future.
setNotesCircleColour(pos,colour)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I will work on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can improve on code quality
Can you please review it again? @vaibhavdaren |
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed function call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, actually the function updateNotesCircle
works on notesCircle
, whereas these lines use wheel1
and this only happens once in the whole code. Thus, a different function would have to be made for wheel1
which would not be that useful given that this function would have to be called just once.
8d39d4d
to
0140cdf
Compare
This reverts commit aadd943.
I did a rebase of this branch after the above-mentioned error by @meganindya was resolved by @ricknjacky in #2862. Now, everything works as expected in the Temperament Widget. Play and stop functionality also works as expected. Also, these commits also cover the changes mentioned in reviews by @vaibhavdaren. I also reverted one commit which involved changes in variable |
Issue Reference: #2767
There were some bugs in this widget, all connected to the Play and Stop functionality.
screen-capture5.mp4
screen-capture6.mp4
this.playbackForward = false
, the stopping functionality would not be reflected in the UI and thus would result in a regression:screen-capture7.mp4
This PR solves these bugs as shown below (all solved bugs are shown in the sequence as they are mentioned above) :
screen-capture8.mp4