diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/audionode/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/audionode/index.html')
-rw-r--r-- | files/zh-cn/web/api/audionode/index.html | 370 |
1 files changed, 370 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/audionode/index.html b/files/zh-cn/web/api/audionode/index.html new file mode 100644 index 0000000000..1c08f81dc4 --- /dev/null +++ b/files/zh-cn/web/api/audionode/index.html @@ -0,0 +1,370 @@ +--- +title: AudioNode +slug: Web/API/AudioNode +translation_of: Web/API/AudioNode +--- +<div>{{ APIRef("Web Audio API") }} {{SeeCompatTable}}</div> + +<p><img alt="AudioNodes participating in an AudioContext create a audio routing graph." src="https://mdn.mozillademos.org/files/5081/WebAudioBasics.png" style="float: left; height: 260px; margin: 10px; width: 355px;"><strong><code>AudioNode</code></strong><strong> </strong>接口是一个处理音频的通用模块, 比如一个音频源 (e.g. 一个 HTML {{HTMLElement("audio")}} or {{HTMLElement("video")}} 元素), 一个音频地址或者一个中间处理模块 (e.g. 一个过滤器如 {{domxref("BiquadFilterNode")}}, 或一个音量控制器如 {{domxref("GainNode")}}).</p> + +<p><code>一个AudioNode</code> 既有输入也有输出。输入与输出都有一定数量的通道。<em>只有一个输出而没有输入的</em> <code>AudioNode</code> 叫做音频源。</p> + +<p>处理多个 <code>AudioNode</code> 时,一般来说, 一个模块读取它的输入,做一些处理。后输出新生成的结果。</p> + +<p>不同的模块可以连接在一起构建一个处理图。 这样一个处理图包含 {{domxref("AudioContext")}}。 每个 <code>AudioNode</code> 只有一个这样的上下文。</p> + +<p>一个 <code>AudioNode</code> 可以作为事件的目标,所以它实现了 {{domxref("EventTarget")}} 接口。</p> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{domxref("AudioNode.context")}} {{readonlyInline}}</dt> + <dd>链接到关联的 {{domxref("AudioContext")}},处理图中模块的上下文对象。</dd> +</dl> + +<dl> + <dt>{{domxref("AudioNode.numberOfInputs")}} {{readonlyInline}}</dt> + <dd>返回这个node需要的输入数量. Source nodes are defined as nodes having a <code>numberOfInputs</code> attributes with a value of <code>0</code>.</dd> +</dl> + +<dl> + <dt>{{domxref("AudioNode.numberOfOutputs")}} {{readonlyInline}}</dt> + <dd>返回这个node的输出数量. Destination nodes, like <code>AudioDestinationNode</code>, have a value of <code>0</code> for this attribute.</dd> +</dl> + +<dl> + <dt>{{domxref("AudioNode.channelCount")}}</dt> + <dd>Represents an integer used in determining how many channels outputs must contains. Its usage and precise definition depends of the value of <code>AudioNode.channelCountMode</code>: it is ignored if the value is <code>"max"</code>, used as a maximum value for <code>"clamped-max"</code>, or used as the effective value for <code>"explicit"</code>.</dd> +</dl> + +<dl> + <dt>{{domxref("AudioNode.channelCountMode")}}</dt> + <dd>Represents an enumerated value describing the way channels must be matched between the inputs and the outputs. Possible values are: + <table class="standard-table"> + <thead> + <tr> + <th scope="col">Value</th> + <th scope="col">Description</th> + <th scope="col">Used as default for the following <code>AudioNode</code> children</th> + </tr> + </thead> + <tbody> + <tr> + <td><code>"max"</code></td> + <td>The number of channels is the maximum of the number of channels all connections. That implies that <code>channelCount</code> is ignored and only up-mixing happens</td> + <td>{{domxref("GainNode")}}, {{domxref("DelayNode")}}, {{domxref("ScriptProcessorNode")}}, {{domxref("ChannelSplitterNode")}}, {{domxref("ChannelMergerNode")}}, {{domxref("BiquadFilterNode")}}, {{domxref("WaveShaperNode")}}</td> + </tr> + <tr> + <td><code>"clamped-max"</code></td> + <td>The number of channels is the maximum of the number of channels of all connections, <em>clamped</em> to the value of <code>channelCount</code>.</td> + <td>{{domxref("PannerNode")}}, {{domxref("ConvolverNode")}}</td> + </tr> + <tr> + <td><code>"explicit"</code></td> + <td>The number of channels is defined by the value of <code>channelCount</code>.</td> + <td>{{domxref("AudioDestinationNode")}}, {{domxref("AnalyserNode")}}, {{domxref("DynamicsCompressorNode")}}</td> + </tr> + </tbody> + </table> + </dd> + <dt>{{domxref("AudioNode.channelInterpretation")}}</dt> + <dd>Represents an enumerated value describing the meaning of the channels. This interpretation will define how the up-mixing and the down-mixing will happen.<br> + The possible values are <code>"speakers"</code> or <code>"discrete"</code>. In the case of <code>"speakers"</code>, the ordering of the channels have the following meaning, and the channels are often represented by a standard abbreviation: + <table class="standard-table"> + <tbody> + <tr> + <td><em>Mono</em></td> + <td><code>0: M: mono</code></td> + </tr> + <tr> + <td><em>Stereo</em></td> + <td><code>0: L: left<br> + 1: R: right</code></td> + </tr> + <tr> + <td><em>Quad</em></td> + <td><code>0: L: left<br> + 1: R: right<br> + 2: SL: surround left<br> + 3: SR: surround right</code></td> + </tr> + <tr> + <td><em>5.1</em></td> + <td><code>0: L: left<br> + 1: R: right<br> + 2: C: center<br> + 3: LFE: subwoofer<br> + 4: SL: surround left<br> + 5: SR: surround right</code></td> + </tr> + </tbody> + </table> + When the amount of channels doesn't match between an input and an output, up- or down-mixing happens according the following rules: + + <table class="standard-table"> + <thead> + <tr> + <th scope="row">Interpretation</th> + <th scope="col">Input channels</th> + <th scope="col">Output channels</th> + <th scope="col">Mixing rules</th> + </tr> + </thead> + <tbody> + <tr> + <th colspan="1" rowspan="13" scope="row"><code>speakers</code></th> + <td><code>1</code> <em>(Mono)</em></td> + <td><code>2</code> <em>(Stereo)</em></td> + <td><em>Up-mix from mono to stereo</em>.<br> + The <code>M</code> input channel is used for both output channels (<code>L</code> and <code>R</code>).<br> + <code>output.L = input.M<br> + output.R = input.M</code></td> + </tr> + <tr> + <td><code>1</code> <em>(Mono)</em></td> + <td><code>4</code> <em>(Quad)</em></td> + <td><em>Up-mix from mono to quad.</em><br> + The <code>M</code> input channel is used for non-surround output channels (<code>L</code> and <code>R</code>). Surround output channels (<code>SL</code> and <code>SR</code>) are silent.<br> + <code>output.L = input.M<br> + output.R = input.M<br> + output.SL = 0<br> + output.SR = 0</code></td> + </tr> + <tr> + <td><code>1</code> <em>(Mono)</em></td> + <td><code>6</code> <em>(5.1)</em></td> + <td><em>Up-mix from mono to 5.1.</em><br> + The <code>M</code> input channel is used for the center output channel (<code>C</code>). All the others (<code>L</code>, <code>R</code>, <code>LFE</code>, <code>SL</code>, and <code>SR</code>) are silent.<br> + <code>output.L = 0<br> + output.R = 0</code><br> + <code>output.C = input.M<br> + output.LFE = 0<br> + output.SL = 0<br> + output.SR = 0</code></td> + </tr> + <tr> + <td><code>2</code> <em>(Stereo)</em></td> + <td><code>1</code> <em>(Mono)</em></td> + <td><em>Down-mix from stereo to mono</em>.<br> + Both input channels (<code>L</code> and <code>R</code>) are equally combined to produce the unique output channel (<code>M</code>).<br> + <code>output.M = 0.5 * (input.L + input.R)</code></td> + </tr> + <tr> + <td><code>2</code> <em>(Stereo)</em></td> + <td><code>4</code> <em>(Quad)</em></td> + <td><em>Up-mix from stereo to quad.</em><br> + The <code>L</code> and <code>R </code>input channels are used for their non-surround respective output channels (<code>L</code> and <code>R</code>). Surround output channels (<code>SL</code> and <code>SR</code>) are silent.<br> + <code>output.L = input.L<br> + output.R = input.R<br> + output.SL = 0<br> + output.SR = 0</code></td> + </tr> + <tr> + <td><code>2</code> <em>(Stereo)</em></td> + <td><code>6</code> <em>(5.1)</em></td> + <td><em>Up-mix from stereo to 5.1.</em><br> + The <code>L</code> and <code>R </code>input channels are used for their non-surround respective output channels (<code>L</code> and <code>R</code>). Surround output channels (<code>SL</code> and <code>SR</code>), as well as the center (<code>C</code>) and subwoofer (<code>LFE</code>) channels, are left silent.<br> + <code>output.L = input.L<br> + output.R = input.R<br> + output.C = 0<br> + output.LFE = 0<br> + output.SL = 0<br> + output.SR = 0</code></td> + </tr> + <tr> + <td><code>4</code> <em>(Quad)</em></td> + <td><code>1</code> <em>(Mono)</em></td> + <td><em>Down-mix from quad to mono</em>.<br> + All four input channels (<code>L</code>, <code>R</code>, <code>SL</code>, and <code>SR</code>) are equally combined to produce the unique output channel (<code>M</code>).<br> + <code>output.M = 0.25 * (input.L + input.R + </code><code>input.SL + input.SR</code><code>)</code></td> + </tr> + <tr> + <td><code>4</code> <em>(Quad)</em></td> + <td><code>2</code> <em>(Stereo)</em></td> + <td><em>Down-mix from quad to mono</em>.<br> + Both left input channels (<code>L</code> and <code>SL</code>) are equally combined to produce the unique left output channel (<code>L</code>). And similarly, both right input channels (<code>R</code> and <code>SR</code>) are equally combined to produce the unique right output channel (<code>R</code>).<br> + <code>output.L = 0.5 * (input.L + input.SL</code><code>)</code><br> + <code>output.R = 0.5 * (input.R + input.SR</code><code>)</code></td> + </tr> + <tr> + <td><code>4</code> <em>(Quad)</em></td> + <td><code>6</code> <em>(5.1)</em></td> + <td><em>Up-mix from quad to 5.1.</em><br> + The <code>L</code>, <code>R</code>, <code>SL</code>, and <code>SR</code> input channels are used for their respective output channels (<code>L</code> and <code>R</code>). Center (<code>C</code>) and subwoofer (<code>LFE</code>) channels are left silent.<br> + <code>output.L = input.L<br> + output.R = input.R<br> + output.C = 0<br> + output.LFE = 0<br> + output.SL = input.SL<br> + output.SR = input.SR</code></td> + </tr> + <tr> + <td><code>6</code> <em>(5.1)</em></td> + <td><code>1</code> <em>(Mono)</em></td> + <td><em>Down-mix from 5.1 to stereo.</em><br> + The left and right, both surround or not, and the central channels are all mixed together. The surround channels are slightly attenuated and the regular lateral channels are power-compensated to make them count as a single channel. The subwoofer (<code>LFE</code>) channel is lost.<br> + <code>output.M = 0.7071 * (input.L + input.R) + input.C + 0.5 * (input.SL + input.SR)</code></td> + </tr> + <tr> + <td><code>6</code> <em>(5.1)</em></td> + <td><code>2</code> <em>(Stereo)</em></td> + <td><em>Down-mix from 5.1 to stereo.</em><br> + The central (<code>C</code>) is summed with each lateral surround channels (<code>SL</code> or <code>SR</code>) and mixed to each lateral channel. As it is mixed in two channels, it is mixed at lower power, that is they are multiplied by <code>√2/2</code>. The subwoofer (<code>LFE</code>) channel is lost.<br> + <code>output.L = input.L + 0.7071 * (input.C + input.SL)<br> + output.R = input.R </code><code>+ 0.7071 * (input.C + input.SR)</code></td> + </tr> + <tr> + <td><code>6</code> <em>(5.1)</em></td> + <td><code>4</code> <em>(Quad)</em></td> + <td><em>Down-mix from 5.1 to quad.</em><br> + The central (<code>C</code>) is mixed with the lateral non-surround channels (<code>L</code> and <code>R</code>). As it is mixed in two channels, it is mixed at lower power, that is they are multiplied by <code>√2/2</code>. The surround channels are passed unchanged. The subwoofer (<code>LFE</code>) channel is lost.<br> + <code>output.L = input.L + 0.7071 * input.C<br> + output.R = input.R<br> + output.SL = input.SL<br> + output.SR = input.SR</code></td> + </tr> + <tr> + <td colspan="2" rowspan="1">Other</td> + <td>As these are non-standard channel layout, they are handled as if <code>channelInterpretation</code> was set to <code>discrete</code>.<br> + The specification explicitly allow the future definition of new speakers layout. This fallback is therefore not future proof as the behavior of the browsers for a specific amount of channels may change in the future.</td> + </tr> + <tr> + <th colspan="1" rowspan="2" scope="row"><code>discrete</code></th> + <td rowspan="1">any (<code>x</code>)</td> + <td rowspan="1">any (<code>y</code>) where <code>x<y</code></td> + <td><em>Up-mix discrete channels.</em><br> + Fill each output channel with its input counterpart, that is the input channel with the same index. Channels with no corresponding input channels are left silent.</td> + </tr> + <tr> + <td rowspan="1">any (<code>x</code>)</td> + <td rowspan="1">any (<code>y</code>) where <code>x>y</code></td> + <td><em>Down-mix discrete channels.</em><br> + Fill each output channel with its input counterpart, that is the input channel with the same index. Input channels with no corresponding output channels are dropped.</td> + </tr> + </tbody> + </table> + </dd> +</dl> + +<h2 id="方法">方法</h2> + +<p><em>Also implements methods from the interface </em>{{domxref("EventTarget")}}.</p> + +<dl> + <dt>{{domxref("AudioNode.connect(AudioNode)")}}</dt> + <dd>允许将此节点的一个输出连接到另一个节点的一个输入。</dd> + <dt>{{domxref("AudioNode.connect(AudioParam)")}}</dt> + <dd>允许将此节点的一个输出连接到音频参数的一个输入。</dd> + <dt>{{domxref("AudioNode.disconnect()")}}</dt> + <dd>允许将这个节点从另一个节点断开连接。</dd> +</dl> + +<h2 id="例子">例子</h2> + + + +<h2 id="规范">规范</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', '#AudioNode-section', 'AudioNode')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div>{{CompatibilityTable}}</div> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}{{property_prefix("webkit")}}</td> + <td>Activated on Nightly only</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>channelCount</code> <code>channelCountMode</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}} (?)</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + <tr> + <td><code>connect</code><code>(AudioParam)</code></td> + <td>{{CompatNo}}</td> + <td>Activated on Nightly only</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Phone</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>Activated on Nightly only</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>channelCount</code><br> + <code>channelCountMode</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}} (?)</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + <tr> + <td><code>connect</code><code>(AudioParam)</code></td> + <td>{{CompatNo}}</td> + <td>Activated on Nightly only</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="相关内容">相关内容</h2> + +<ul> + <li>Using Web Audio</li> +</ul> |