OscillatorNode: thuộc tính frequency
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính frequency của giao diện OscillatorNode là một AudioParam a-rate đại diện cho tần số dao động tính bằng hertz.
Note:
Mặc dù AudioParam trả về là chỉ đọc, giá trị mà nó đại diện thì không.
Giá trị
Một AudioParam a-rate.
Ví dụ
Ví dụ dưới đây cho thấy cách sử dụng cơ bản của AudioContext để tạo oscillator node. Để xem ví dụ được áp dụng, hãy xem Violent Theremin demo (xem app.js để biết mã liên quan).
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();
Thông số kỹ thuật
| Specification |
|---|
| Web Audio API> # dom-oscillatornode-frequency> |