Skip to main content

setPlaybackRate

setPlaybackRate(id: string, rate: number, skipDispatchEvent?: boolean): void;

Set the playback speed of a sound. A rate of 1 is normal speed; 0.5 is half speed; 2 is double speed. Pitch changes along with the rate (Web Audio API behaviour).

ParameterTypeDescription
idstringID of the sound
ratenumberPlayback speed multiplier (e.g. 0.5, 1, 2)
skipDispatchEventboolean (optional)When true, skips dispatching the rate change event
tip

You can also set the initial rate at play time via PlayOptions.playbackRate.


Example

await soundManager.loadSounds([{ id: 'intro', url: 'intro.mp3' }]);

soundManager.play('intro');

// Half speed
soundManager.setPlaybackRate('intro', 0.5);

// Double speed
soundManager.setPlaybackRate('intro', 2);

// Back to normal
soundManager.setPlaybackRate('intro', 1);
⚡ Playback Rate1× (normal)
0.25×1× (normal)
Try it: Play the intro speech and drag the slider to hear the rate change in real time. Note that pitch shifts along with speed — this is native Web Audio API behaviour.