Since December 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
The HTMLMediaElement.preservesPitch property determines whether or not the browser should adjust the pitch of the audio to compensate for changes to the playback rate made by setting HTMLMediaElement.playbackRate.
A boolean value defaulting to true.
In this example, we have an <audio> element, a range control that adjusts the playback rate, and a checkbox that sets preservesPitch.
Try playing the audio, then adjusting the playback rate, then enabling and disabling the checkbox.
<audio controls src="https://mdn.github.io/webaudio-examples/audio-basics/outfoxing.mp3"></audio> <div> <label for="rate">Adjust playback rate:</label> <input id="rate" type="range" min="0.25" max="3" step="0.05" value="1" /> </div> <div> <label for="pitch">Preserve pitch:</label> <input type="checkbox" id="pitch" name="pitch" checked /> </div>
const audio = document.querySelector("audio");
document.getElementById("rate").addEventListener("change", (e) => {
audio.playbackRate = e.target.value;
});
document.getElementById("pitch").addEventListener("change", (e) => {
audio.preservesPitch = e.target.checked;
});
| Specification |
|---|
| HTML> # dom-media-preservespitch-dev> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
preservesPitch |
86 | 86 | 101 | 72 | 17.24 | 86 | 101 | 61 | 17.23.2 | 14.0 | 86 | 17.23.2 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/preservesPitch