Skip to content

feat(SoundFile): implement playMode() via internal Tone.Player management - #122

Merged
ogbabydiesal merged 1 commit into
processing:mainfrom
sadSanta-07:feature/soundfile-playmode
Oct 17, 2026
Merged

ogbabydiesal merged 1 commit into
processing:mainfrom
sadSanta-07:feature/soundfile-playmode

Conversation

@sadSanta-07

Copy link
Copy Markdown
Contributor

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).

@bmoren

bmoren commented Oct 9, 2026

Copy link
Copy Markdown

🙏 ty for implementing this!

@ogbabydiesal
ogbabydiesal merged commit 7ff47c2 into processing:main Oct 17, 2026
@ogbabydiesal

Copy link
Copy Markdown
Member

thank you! i discovered a different bug in pause() and rate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create playMode() method for SoundFile

3 participants