Merged
Conversation
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.
New Smplr Player
Co-authored with Claude
Summary
Replaces the old
DefaultPlayer/RegionPlayeraudio stack with a newSmplrplayer. All nine instruments are migrated to the new player. The public API isunchanged for most instruments; the main additions are
onStart/onEndednote callbacks, aonLoadProgresscallback,and a
loadProgressgetter available on every instrument.What changed
New player:
src/smplr/A complete rewrite of the audio playback layer, built from scratch with full unit test
coverage.
smplr.tsSmplrJson+ options; exposesstart,stop,disconnect,loadProgress,outputtypes.tsSmplrJson,SmplrGroup,SmplrRegion,NoteEvent,StopTarget,LoadProgress,PlaybackParamsregion-matcher.tsvoice.tsAudioBufferSourceNodewith attack/release envelope, detune, LPF, loopingvoice-manager.tsstopById,stopGroup,stopAllwith optional scheduled timescheduler.tsstartevents and dispatches them on timesample-loader.tsSmplrJson; accepts pre-builtMap<string, AudioBuffer>to skip fetchparams.tssfz-convert.tsSmplrJsonwebsfz-convert.ts.websfz.jsonformat toSmplrJsonutils.tsspreadKeyRangeshelper for building key-mapped region arrayschannel.ts/signals.ts/volume.ts/midi.ts/sorted-queue.ts/load-audio.ts/connect.tssrc/player/(unchanged)New capabilities vs. the old stack:
onStart(event)/onEnded(event)note lifecycle callbacks — settable globally oninstrument options and/or per-note on the event object; both levels are composed when set
together.
onStartfires once per note event (at scheduler dispatch time);onEndedfiresonce per matched voice when its
AudioBufferSourceNodeends.onLoadProgress({ loaded, total })callback +loadProgressgetter — total is known beforeloading starts, enabling determinate progress bars
ccRange) for sustain-pedal-style region gatingampVelCurve) per regiontrigger: "first" | "legato"region triggersseqPosition/seqLength)SampleLoaderorSchedulervia options for cache reuse andcoordinated timing
Instrument migrations
Every instrument now delegates to a private
#smplr: Smplrinstance. The publicstart/stop/disconnect/output/loadinterface is preserved on all instruments.SplendidGrandPianonotesToLoadsubset loading preserved;hasLoopsflag preservedSoundfonthasLoopsflag preservedSamplerAudioBuffervalues directly inbuffersmap (new)DrumMachinegetGroupNames,getSampleNames,getSampleNamesForGroupAPI unchangedElectricPianoSfzSamplerbase class (shared with Mallet, Mellotron, Smolken, Versilian)MalletSfzSamplerMellotronSfzSamplerSmolkenSfzSamplerVersilianSfzSamplerSoundfont2SamplerSmplr.loadInstrument(json, buffers)with pre-decodedAudioBuffermapRemoved
src/player/region-player.ts— no longer imported anywheresrc/tests/splendid-grand-piano.spec.ts— replaced bysrc/splendid-grand-piano.test.tsTests
All 15 test suites pass (237 tests total). New suites added for every component:
Documentation
README.md— new Load progress section withonLoadProgressandloadProgressexamples;onLoadProgressadded to the shared options tableSite
site/pages/test.tsx— new manual test page at/test. Single ▶/⏸ button cycles throughall 8 instruments: loads a random preset, shows live
Loading… N / Mprogress, plays achromatic scale (C3–C5, 200 ms/note, random velocity) or each drum group in sequence.
Each note uses
onStart/onEndedcallbacks: the log line shows▶ C4 vel:80on startand updates to
■ C4 vel:80when the audio ends, visually confirming both callbacks fire.Pause exits within one note's delay via
AbortController.package.json— addedtestPathIgnorePatterns: ["/site/"]so Jest does not pick upNext.js pages whose filename contains
test.Breaking changes
Soundfont2Sampler: the publicplayer: RegionPlayerproperty is removed.Use
output,start, andstopinstead (already the documented API).Soundfont2Optionsno longer extendsRegionPlayerOptions. Onlydestination,volume, andvelocityare accepted (the options RegionPlayer exposed beyond thosewere implementation details not reachable from
Soundfont2Sampler).