aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/audiobuffersourcenode/buffer/index.html
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/audiobuffersourcenode/buffer/index.html
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/audiobuffersourcenode/buffer/index.html')
-rw-r--r--files/zh-cn/web/api/audiobuffersourcenode/buffer/index.html81
1 files changed, 81 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/audiobuffersourcenode/buffer/index.html b/files/zh-cn/web/api/audiobuffersourcenode/buffer/index.html
new file mode 100644
index 0000000000..39591c82ba
--- /dev/null
+++ b/files/zh-cn/web/api/audiobuffersourcenode/buffer/index.html
@@ -0,0 +1,81 @@
+---
+title: AudioBufferSourceNode.buffer
+slug: Web/API/AudioBufferSourceNode/buffer
+tags:
+ - API
+ - AudioBufferSourceNode
+ - Web Audio API
+translation_of: Web/API/AudioBufferSourceNode/buffer
+---
+<p>{{ APIRef("Web Audio API") }}</p>
+
+<p>{{ domxref("AudioBufferSourceNode") }} 接口的<span style='background-color: transparent; color: #333333; display: inline !important; float: none; font-family: "Open Sans",arial,x-locale-body,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;'> </span><code style=""><strong style="border-bottom-style: none; border-bottom-width: 0px; border-left-style: none; border-left-width: 0px; border-right-style: none; border-right-width: 0px; border-top-style: none; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;">buffer</strong></code><span style='background-color: transparent; color: #333333; display: inline !important; float: none; font-family: "Open Sans",arial,x-locale-body,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;'> 属性提供了重复播放音频的能力,该音频使用 </span>{{domxref("AudioBuffer")}} 作为声音文件的来源。</p>
+
+<p>如果 <code>buffer</code> 属性的值为 <code>null</code>, 节点会自动生成一个单声道的无声文件(所有采样均为0)。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>AudioBufferSourceNode</em>.buffer = <em>soundBuffer</em>;
+</pre>
+
+<h3 id="返回值">返回值</h3>
+
+<p>{{domxref("AudioBuffer")}},<span style='background-color: transparent; color: #333333; display: inline !important; float: none; font-family: "Open Sans",arial,x-locale-body,sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; white-space: normal;'>包含了节点将要播放的声音数据</span>。</p>
+
+<h2 id="示例">示例</h2>
+
+<div class="note">
+<p>完整的示例请查看 <a class="external external-icon" href="http://mdn.github.io/audio-buffer/"> this code running live</a>,或  <a class="external external-icon" href="https://github.com/mdn/audio-buffer">view the source。</a></p>
+</div>
+
+<pre class="brush: js;highlight[19]">var myArrayBuffer = audioCtx.createBuffer(2, frameCount, audioCtx.sampleRate);
+
+button.onclick = function() {
+ // Fill the buffer with white noise;
+ //just random values between -1.0 and 1.0
+ for (var channel = 0; channel &lt; channels; channel++) {
+ // This gives us the actual ArrayBuffer that contains the data
+ var nowBuffering = myArrayBuffer.getChannelData(channel);
+ for (var i = 0; i &lt; frameCount; i++) {
+ // Math.random() is in [0; 1.0]
+ // audio needs to be in [-1.0; 1.0]
+ nowBuffering[i] = Math.random() * 2 - 1;
+ }
+ }
+
+ // Get an AudioBufferSourceNode.
+ // This is the AudioNode to use when we want to play an AudioBuffer
+ var source = audioCtx.createBufferSource();
+ // set the buffer in the AudioBufferSourceNode
+ source.buffer = myArrayBuffer;</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName("Web Audio API", "#widl-AudioBufferSourceNode-buffer", "buffer")}}</td>
+ <td>{{Spec2("Web Audio API")}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("api.AudioBufferSourceNode.buffer")}}</p>
+</div>
+
+<h2 id="相关链接">相关链接</h2>
+
+<p>{{page("/en-US/docs/Web/API/AudioBufferSourceNode","See_also")}}</p>