resetAllCounters
Clear the counters behind instance ids. When a sound plays with overlap, each instance gets an id like 'click:1', 'click:2', and so on. After this call the numbering starts from 1 again.
resetAllCounters(): void;
This method is on the SoundHub class but not on SoundHubInterface.
Parameters
This method takes no parameters.
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('click', '/audio/click.mp3');
soundHub.play('click', { overlap: true }); // instance 'click:1'
soundHub.play('click', { overlap: true }); // instance 'click:2'
// New level: start numbering from scratch
soundHub.resetAllCounters();
Good to know
- The counters only decide the number in an instance id. They do not limit how many instances can play; that is
maxInstancesPerSoundinSoundHubConfigor a group'smaxInstances. - An id that is still in use is never handed out again. If
'click:1'is still registered after a reset, the next instance becomes'click:2'. - No event is dispatched. In debug mode a line is logged.
resetwithunloadSounds: trueanddestroyclear the counters as well.
See also
play: theoverlapoption that creates instances.getSoundIds: list every sound and instance id in the hub.reset: put the whole hub back to its starting state.