A group holds only so many voices
Put your sounds in a named group, give the group a maxInstances limit, and play as
much as you like. Once the group is full, the oldest instance stops so the new one can start.
Watch the slots below fill up, then take the arcade game for a spin and hear what happens when
you fire faster than the limit allows.
sm.createSoundGroup('weapons', { maxInstances: 3 })
sm.play('laser', { createNewInstance: true, groupId: 'weapons' })
4th shot → oldest instance stops
Two groups, two limits. Hammer the buttons and watch a slot get taken over.
Retro Pong is a full game rather than a demo, and its audio runs on this same library: stereo-panned effects, a serve you aim yourself, power-ups, mines, and an end-of-match sequence that tells you how the match went.
npm i retro-pong-game