Used memory increases the longer samples are played in one session. You'll see a lot of GainNode objects piling up.
For those interested, I shared our fix here:
https://github.com/danigb/sample-player/pull/8
In our library (OpenSheetMusicDisplay, early access audio player), we patch this fix into node_modules/sample-player, otherwise we'd have to wait for a new release of sample-player and soundfont-player.
You can do this hotfix like this:
Add this in package.json under scripts:
prebuild is automatically executed with npm run build.
(you can just put the bottom line into prebuild if you don't have other prebuild scripts, otherwise use npm-run-all in prebuild)
(of course you need to put the patched .js files into src/SamplePlayerPatch/lib/)
Dependencies:
ncp is a dependency you'll need to add:
"ncp": "^2.0.0",
This is just cp (a copy command) that works on Mac, Linux and Windows. I'm not aware of another easy platform-agnostic way to do that. And it's 17.5KB.
Also npm-run-all, if you want to use it in prebuild:
"npm-run-all": "^4.1.5",
->
prebuild: npm-run-all myPrebuild prebuildSamplePlayer
Used memory increases the longer samples are played in one session. You'll see a lot of
GainNode
objects piling up. For those interested, I shared our fix here: https://github.com/danigb/sample-player/pull/8In our library (OpenSheetMusicDisplay, early access audio player), we patch this fix into
node_modules/sample-player
, otherwise we'd have to wait for a new release of sample-player and soundfont-player.You can do this hotfix like this: Add this in package.json under scripts:
prebuild
is automatically executed withnpm run build
. (you can just put the bottom line into prebuild if you don't have other prebuild scripts, otherwise usenpm-run-all
inprebuild
) (of course you need to put the patched .js files intosrc/SamplePlayerPatch/lib/
)Dependencies:
ncp
is a dependency you'll need to add:"ncp": "^2.0.0",
This is just
cp
(a copy command) that works on Mac, Linux and Windows. I'm not aware of another easy platform-agnostic way to do that. And it's 17.5KB.Also
npm-run-all
, if you want to use it inprebuild
: "npm-run-all": "^4.1.5", ->prebuild: npm-run-all myPrebuild prebuildSamplePlayer