aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/baseaudiocontext/createoscillator
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/baseaudiocontext/createoscillator
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/baseaudiocontext/createoscillator')
-rw-r--r--files/zh-cn/web/api/baseaudiocontext/createoscillator/index.html64
1 files changed, 64 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/baseaudiocontext/createoscillator/index.html b/files/zh-cn/web/api/baseaudiocontext/createoscillator/index.html
new file mode 100644
index 0000000000..3b992092cc
--- /dev/null
+++ b/files/zh-cn/web/api/baseaudiocontext/createoscillator/index.html
@@ -0,0 +1,64 @@
+---
+title: BaseAudioContext.createOscillator()
+slug: Web/API/BaseAudioContext/createOscillator
+translation_of: Web/API/BaseAudioContext/createOscillator
+---
+<p>{{APIRef("Web Audio API")}}</p>
+
+<p>{{domxref("BaseAudioContext")}}接口的createOscillator()方法创建一个{{domxref("OscillatorNode")}},它是一个表示周期性波形的源。 它基本上产生一个不变的音调。</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">var <em>oscillatorNode</em> = <em>audioCtx</em>.createOscillator();</pre>
+
+<h3 id="Description" name="Description">Returns</h3>
+
+<p>An {{domxref("OscillatorNode")}}.</p>
+
+<h2 id="Examples" name="Examples">Example</h2>
+
+<p>以下示例显示了用于创建振荡器节点的AudioContext的基本用法。 有关应用示例/信息,请查看我们的<a href="http://mdn.github.io/violent-theremin/">Violent Theremin demo</a>(有关相关代码,请参阅<a href="https://github.com/mdn/violent-theremin/blob/gh-pages/scripts/app.js">see app.js</a>); 另请参阅我们的OscillatorNode页面以获取更多信息。</p>
+
+<pre class="brush: js">// 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();</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Web Audio API', '#dom-baseaudiocontext-createoscillator', 'createOscillator')}}</td>
+ <td>{{Spec2('Web Audio API')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+<div>
+
+
+<p>{{Compat("api.BaseAudioContext.createOscillator")}}</p>
+</div>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li>
+</ul>