HTMLMediaElement: preservesPitch property

Baseline 2023
Newly available

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.

Value

A boolean value defaulting to true.

Examples

Setting the preservesPitch property

In this example, we have an 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.

html


js
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;
});

Specifications

Specification
HTML
# dom-media-preservespitch-dev

Browser compatibility

See also