Phương thức createOscillator()
của giao thức AudioContext
tạo một cái OscillatorNode
(nút máy dao động). Tức là ta cái nguồn từ dạng sóng.
Cú pháp
var audioCtx = new AudioContext();
var oscillator = audioCtx.createOscillator();
Trả về
Một cái OscillatorNode
.
Ví dụ
Ví dụ này trình bày sử dụng đơn giản của một cái AudioContext để tạo một cái OsillatorNode. Để biết thêm thông tin, xem biểu hiện, và trang OscillatorNode
của chúng tôi
Ví dụ này trình bày sử dụng đơn giản của một cái AudioContext để tạo một cái OsillatorNode. Để biết thêm thông tin, xem biểu hiện Violent Theremin (app.js); và trang OscillatorNode
của chúng tôi.
// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
// create Oscillator node
var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = 3000; // Hz
oscillator.connect(audioCtx.destination);
oscillator.start();
Quy cách
Quy cách | Địa vị | Chú thích |
---|---|---|
Web Audio API The definition of 'createOscillator' in that specification. |
Working Draft |
Tương thích trình duyệt
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Đặc trưng | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 10.0webkit | (Yes) | 25.0 (25.0) | No support | 15.0webkit 22 (unprefixed) |
6.0webkit |
Đặc trưng | Android | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | ? | (Yes) | 26.0 | 1.2 | ? | ? | ? | 33.0 |