OscillatorNode: frequency-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 frequency-Eigenschaft der OscillatorNode-Schnittstelle ist ein a-rate AudioParam, das die Frequenz der Oszillation in Hertz darstellt.

Hinweis: Obwohl das zurückgegebene AudioParam schreibgeschützt ist, ist der Wert, den es repräsentiert, dies nicht.

Wert

Beispiele

Das folgende Beispiel zeigt die grundlegende Verwendung eines AudioContext, um einen Oszillator-Knoten zu erstellen. Für ein praktisches Beispiel schauen Sie sich unser Violent Theremin Demo an (siehe app.js für den relevanten Code).

js
// create web audio api context
const audioCtx = new AudioContext();

// create Oscillator node
const oscillator = audioCtx.createOscillator();

oscillator.type = "square";
oscillator.frequency.setValueAtTime(440, audioCtx.currentTime); // value in hertz
oscillator.start();

Spezifikationen

Specification
Web Audio API
# dom-oscillatornode-frequency

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
frequency

Legend

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

Full support
Full support

Siehe auch