HTMLMediaElement: preservesPitch プロパティ

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.

HTMLMediaElement.preservesPitch プロパティは、 HTMLMediaElement.playbackRate の設定で行われた再生速度の変更を補償するために、ブラウザーが音声の音程を調整すべきかどうかを決定します。

論理値で、既定値は true です。

preservesPitch プロパティの設定

この例には、 <audio> 要素、再生速度を制御する範囲コントロール、preservesPitchを設定するチェックボックスがあります。

音声を再生し、再生速度を調整し、チェックボックスを有効・無効にしてみてください。

html
<audio
  controls
  src="https://mdn.github.io/webaudio-examples/audio-basics/outfoxing.mp3"></audio>

<div>
  <label for="rate">再生レートを調整:</label>
  <input id="rate" type="range" min="0.25" max="3" step="0.05" value="1" />
</div>

<div>
  <label for="pitch">ピッチを維持:</label>
  <input type="checkbox" id="pitch" name="pitch" checked />
</div>
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;
});

仕様書

Specification
HTML
# dom-media-preservespitch-dev

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
preservesPitch

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Requires a vendor prefix or different name for use.
Has more compatibility info.

関連情報