BaseAudioContext.createOscillator()

这篇翻译不完整。请帮忙从英语翻译这篇文章

BaseAudioContext接口的createOscillator()方法创建一个OscillatorNode,它是一个表示周期性波形的源。 它基本上产生一个不变的音调。

Syntax

var oscillatorNode = audioCtx.createOscillator();

Returns

An OscillatorNode.

Example

以下示例显示了用于创建振荡器节点的AudioContext的基本用法。 有关应用示例/信息,请查看我们的Violent Theremin demo(有关相关代码,请参阅see app.js); 另请参阅我们的OscillatorNode页面以获取更多信息。

// create web audio api context
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();

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

oscillator.type = 'square';
oscillator.frequency.setValueAtTime(3000, audioCtx.currentTime); // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();

Specifications

Specification Status Comment
Web Audio API
createOscillator
Working Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 10
Prefixed
Full support 10
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support YesFirefox Full support 25IE No support NoOpera Full support 22
Full support 22
Full support 15
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari Full support 6
Prefixed
Full support 6
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Full support YesChrome Android Full support 33Edge Mobile Full support YesFirefox Android Full support 26Opera Android Full support YesSafari iOS No support NoSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also

文档标签和贡献者

此页面的贡献者: tanchi_wang
最后编辑者: tanchi_wang,