Repository navigation
feat(SoundFile): implement playMode() via internal Tone.Player management - #122
Merged
ogbabydiesal merged 1 commit intoOct 17, 2026
Merged
Conversation
|
🙏 ty for implementing this! |
Member
|
thank you! i discovered a different bug in |
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.
This PR resolves #117 by implementing the playMode() method for the SoundFile class, as suggested by @ogbabydiesal.
Changes Made:
Added playMode(mode) method accepting 'sustain' (default), 'restart', and 'untilDone'.
Refactored play() and start() to manage an internal array of Tone.Player clones (this._activePlayers) rather than a single node. This allows for proper polyphonic playback (sustain) without cutting off audio tails when triggered rapidly.
Implemented automatic garbage collection (dispose()) via player.onstop to prevent memory leaks as cloned players finish, and ensured onended callbacks still fire correctly when the final overlapping sound completes.
Updated stop(), pause(), loop(), loopPoints(), jump(), and rate() to iterate over _activePlayers so that property changes and transport controls properly affect all currently active polyphonic voices.
Testing:
Built locally using npm run build.
Ran Playwright integration suite. Core library functionality is intact. (Note: A few test-examples-on-web-editor tests threw 404s/loadSound is not defined network errors due to external fetching, but local functionality is verified).