fix: only pop instrumentNames if setTimbre pushed it#5932
Open
Ady0333 wants to merge 1 commit intosugarlabs:masterfrom
Open
fix: only pop instrumentNames if setTimbre pushed it#5932Ady0333 wants to merge 1 commit intosugarlabs:masterfrom
Ady0333 wants to merge 1 commit intosugarlabs:masterfrom
Conversation
Signed-off-by: Ady0333 <adityashinde1525@gmail.com>
Contributor
Author
|
@walterbender and @vanshika2720 and @omsuneri , Please review this pr. |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a stack imbalance in the Set Timbre block where nested blocks using the same instrument could remove the wrong entry from the instrumentNames stack, causing subsequent notes to play with an incorrect timbre.
What changed
Added a small guard in setTimbre() to track whether the current block instance actually pushed a value to instrumentNames. The cleanup listener now pops the stack only when that push occurred.
Why this change was needed
The push to instrumentNames was guarded by
!includes(synth)to prevent duplicate entries. However, the listener always executedpop().When identical Set Timbre blocks were nested, the inner block skipped the push but still executed the pop in its listener. This removed the outer block's entry, leaving the stack empty while still inside the outer scope.
As a result:
last(instrumentNames)returnedundefinedinSetTimbrewas also cleared prematurely, disabling timbre effects for the remaining notes inside the outer blockScope
setTimbre()injs/turtleactions/ToneActions.jsVerification
Fix