Skip to main content

SoundResetOptions

The SoundResetOptions interface defines which aspects of a sound (or the entire sound manager) should be reset. Use it with the reset() or resetSound() methods to selectively reset specific properties.

Try it

Change the volume, pan and playback rate, then reset with different options to see exactly which settings survive and which are restored.

Volume0.7
Pan0
Playback Rate1
Try it: Adjust volume, pan, and rate while playing. Click resetSound(id) to reset all properties to defaults. Use resetSound(id, { keepVolumes: true }) to selectively keep certain settings.
export interface SoundResetOptions {
keepVolumes?: boolean;
keepPanning?: boolean;
keepSpatial?: boolean;
keepPlaybackRate?: boolean;
unloadSounds?: boolean;
}

Resetting a Single Sound

Use resetSound() to reset a specific sound with selective options:

const mySoundHub = new SoundHub();
await mySoundHub.loadSound('voice', '/audio/voice.mp3');

mySoundHub.play('voice', {
volume: 0.5,
pan: -0.8,
playbackRate: 1.5,
loop: true,
});

// Only reset the volume and pan, keep other settings
mySoundHub.resetSound('voice', {
keepVolumes: false,
keepPanning: false,
});

// The sound keeps playing with default volume (1.0) and center pan,
// but keeps its custom playback rate (1.5) and loop setting (true).
  • reset - Reset the entire sound manager
  • resetSound - Reset a specific sound
  • destroy - Completely destroy the sound manager