AudioBufferSourceNode: detune-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.

Die detune-Eigenschaft der Schnittstelle AudioBufferSourceNode ist ein k-rate AudioParam, das die Verstimmung der Oszillation in Cent repräsentiert.

Zum Beispiel verstimmen die Werte +100 und -100 die Quelle um einen Halbton nach oben oder unten, während +1200 und -1200 sie um eine Oktave nach oben oder unten verstimmen.

Wert

Ein k-rate AudioParam, dessen Wert die Verstimmung der Oszillation in Cent angibt.

Hinweis: Obwohl das zurückgegebene AudioParam schreibgeschützt ist, ist der Wert, den es darstellt, es nicht.

Beispiele

js
const audioCtx = new AudioContext();

const channelCount = 2;
const frameCount = audioCtx.sampleRate * 2.0; // 2 seconds

const myArrayBuffer = audioCtx.createBuffer(
  channelCount,
  frameCount,
  audioCtx.sampleRate,
);

for (let channel = 0; channel < channelCount; channel++) {
  const nowBuffering = myArrayBuffer.getChannelData(channel);
  for (let i = 0; i < frameCount; i++) {
    nowBuffering[i] = Math.random() * 2 - 1;
  }
}

const source = audioCtx.createBufferSource();
source.buffer = myArrayBuffer;
source.connect(audioCtx.destination);
source.detune.value = 100; // value in cents
source.start();

Spezifikationen

Specification
Web Audio API
# dom-audiobuffersourcenode-detune

Browser-Kompatibilität

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
detune

Legend

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

Full support
Full support

Siehe auch