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 | |
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')
-rw-r--r-- | files/zh-cn/web/api/audionode/connect(audioparam)/index.html | 163 | ||||
-rw-r--r-- | files/zh-cn/web/api/audionode/connect/index.html | 145 | ||||
-rw-r--r-- | files/zh-cn/web/api/audionode/index.html | 370 |
3 files changed, 678 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/audionode/connect(audioparam)/index.html b/files/zh-cn/web/api/audionode/connect(audioparam)/index.html new file mode 100644 index 0000000000..eb82534aed --- /dev/null +++ b/files/zh-cn/web/api/audionode/connect(audioparam)/index.html @@ -0,0 +1,163 @@ +--- +title: AudioNode.connect(AudioParam) +slug: Web/API/AudioNode/connect(AudioParam) +translation_of: Web/API/AudioNode/connect(AudioParam) +--- +<p>{{ APIRef("Web Audio API") }}</p> + +<div> +<p>允许我们将当前节点的一个输出连接到音频参数的一个输入,并允许通过音频信号控制参数。<br> + 使AudioNode输出连接到多个AudioParam,并将多个AudioNode输出连接到单个 AudioParam,同时多次调用connect()。因此支持Fan-in and fan-out。<br> + AudioParam可以从连接到它的任何AudioNode输出获取渲染的音频数据,并通过下混合将其转换为单声道(如果本身不是单声道的话)。然后,它将其他这样的输出和固定参数混合( AudioParam的值通常没有任何连接),包括为参数调度的任何时间的变化。<br> + 因此,可以通过将AudioParam的值设置为中心频率来选择AudioParam将要更改的范围,并使用音频源和AudioParam之间的GainNode来调整AudioParam更改的范围。</p> +</div> + +<h2 id="Syntax">Syntax</h2> + +<pre class="brush: js;highlight[11]">var lfo = audioCtx.createOscillator(); +lfo.frequency.value = 2.0; // Hz, two times per second + +var lfoGain = audioCtx.createGain(); +lfoGain.gain.value = 0.5; + +// this is the parameter that is going to be modulated +var gain = audioCtx.createGain(); +gain.gain.value = 0.5; + +// Oscillators go from -1 to 1 +// Make it go from -0.5 to +0.5 by connecting it to a GainNode with a gain value of 0.5 +lfo.connect(lfoGain); + +// because the value of the gain.gain AudioParam is originaly 0.5, the value is added, and it will go from 0.0 to 1.0 +lfoGain.connect(gain.gain); + +lfo.connect(gain.gain);</pre> + +<div class="note"> +<p><strong>Note</strong>: There can only be one connection between an output from one specific <code>AudioNode</code> and an {{ domxref("AudioParam") }}. Multiple connections to the same termini are equivalent to a single such connection (the duplicates are ignored).</p> +</div> + +<h3 id="Description" name="Description">Returns</h3> + +<p>Void.</p> + +<h2 id="Examples" name="Examples">Example</h2> + +<p>In this example, we will be altering the gain value of a {{domxref("GainNode")}} using an {{domxref("OscillatorNode")}} with a slow frequency value. This technique is know as an <em>LFO</em>-controlled parameter.</p> + +<pre class="brush: js;highlight[8,9]">var AudioContext = window.AudioContext || window.webkitAudioContext; + +var audioCtx = new AudioContext(); + +// create an normal oscillator to make sound +var oscillator = audioCtx.createOscillator(); + +// create a second oscillator that will be used as an LFO (Low-frequency +// oscillator), and will control a parameter +var lfo = audioCtx.createOscillator(); + +// set the frequency of the second oscillator to a low number +lfo.frequency.value = 2.0; // 2Hz: two oscillations par second + +// create a gain whose gain AudioParam will be controlled by the LFO +var gain = audioCtx.createGain(); + +// connect the LFO to the gain AudioParam. This means the value of the LFO +// will not produce any audio, but will change the value of the gain instead +lfo.connect(gain.gain); + +// connect the oscillator that will produce audio to the gain +oscillator.connect(gain); + +// connect the gain to the destination so we hear sound +gain.connect(audioCtx.destination); + +// start the oscillator that will produce audio +oscillator.start(); + +// start the oscillator that will modify the gain value +lfo.start();</pre> + +<h2 id="Parameters" name="Parameters">Parameters</h2> + +<dl> + <dt>Destination</dt> + <dd>The {{ domxref("AudioParam") }} you are connecting to.</dd> + <dt>Output (optional)</dt> + <dd>An index describing which output of the current <code>AudioNode</code> you want to connect to the {{ domxref("AudioParam") }}. The index numbers are defined according to the number of output channels (see <a href="/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Audio_channels">Audio channels</a>.) If this parameter is out-of-bound, an <code>INDEX_SIZE_ERR</code> exception is thrown.</dd> +</dl> + +<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', '#widl-AudioNode-connect-void-AudioParam-destination-unsigned-long-output', 'connect(AudioParam)')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</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><code>connect</code><code>(AudioParam)</code></td> + <td>{{CompatVersionUnknown}} {{property_prefix("webkit")}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</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>Firefox OS (Gecko)</th> + <th>IE Phone</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td><code>connect</code><code>(AudioParam)</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> +</ul> diff --git a/files/zh-cn/web/api/audionode/connect/index.html b/files/zh-cn/web/api/audionode/connect/index.html new file mode 100644 index 0000000000..a0b5a763cb --- /dev/null +++ b/files/zh-cn/web/api/audionode/connect/index.html @@ -0,0 +1,145 @@ +--- +title: AudioNode.connect() +slug: Web/API/AudioNode/connect +translation_of: Web/API/AudioNode/connect +--- +<p>{{ APIRef("Web Audio API") }}</p> + +<div> +<p>{{ domxref("AudioNode") }} 接口的 <code>connect()</code> 方法使你能将一个节点的输出连接到一个指定目标,这个指定的目标可能是另一个 <code>AudioNode</code>(从而将音频数据引导到下一个指定节点)或一个{{domxref("AudioParam")}}, 以便上一个节点的输出数据随着时间流逝能自动地对下一个参数值进行改变。</p> +</div> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">var <em>destinationNode</em> = <em>AudioNode</em>.connect(<em>destination</em>, <em>outputIndex</em>, <em>inputIndex</em>); + +<em>AudioNode</em>.connect(<em>destination</em>, <em>outputIndex</em>); +</pre> + +<h3 id="属性">属性</h3> + +<dl> + <dt><code>destination</code></dt> + <dd>需要连接的 {{domxref("AudioNode")}} 或 {{domxref("AudioParam")}}.</dd> + <dt><code>outputIndex</code> {{optional_inline}}</dt> + <dd>一个索引,用于描述当前 <code>AudioNode</code> 的哪个输出会连接到destination。索引数字是由输出频道(详见 <a href="/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Audio_channels">Audio channels</a>)的数量来确定的。当你只能将给定的输出连接到给定的输入一次(重复的尝试会被忽略)时,可以通过多次调用 <code>connect()</code> 将一个输出连接到多个输入。可以通过这样来实现扇出。这个参数的默认值为0。</dd> + <dt><code>inputIndex</code> {{optional_inline}}</dt> + <dd>一个索引,用于描述当前 <code>AudioNode</code> 会连接到destination的哪个输入,它的默认值是0。索引数字是由输入频道(详见 <a href="/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Audio_channels">Audio channels</a>)的数量来确定的。将一个 <code>AudioNode</code> 连接回之前的 <code>AudioNode</code>,以此形成一个圈是可行的。 不过只在这个圈里有至少一个 {{domxref("DelayNode")}} 才可行。否则会抛出一个 <code>NotSupportedError</code> 异常。此参数在destination是 {{domxref("AudioParam")}}时不可用。</dd> +</dl> + +<h3 id="返回值">返回值</h3> + +<p>如果destination是一个节点, <code>connect()</code> 返回destination所表示的 {{domxref("AudioNode")}} 对象的引用,允许你链式地调用数个 <code>connect()</code> 。某些浏览器关于该接口的旧实现会返回 {{jsxref("undefined")}}。</p> + +<p>如果destination是一个 <code>AudioParam</code>,<code>connect()</code> 返回 <code>undefined</code>.</p> + +<h3 id="异常">异常</h3> + +<dl> + <dt><code>IndexSizeError</code></dt> + <dd>这个异常表明 <code>outputIndex</code> 或 <code>inputIndex</code> 与当前输入或输出不符。</dd> + <dt><code>InvalidAccessError</code></dt> + <dd>目标节点与原节点不在同一个音频上下文。</dd> + <dt><code>NotSupportedError</code></dt> + <dd>该链接会形成一个闭环(音频在这个环里不断重复经过同一个节点)并且这个闭环里没有 {{domxref("DelayNode")}} 来防止产生的波形被卡住,不停地构建相同的音频帧。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<h3 id="Connecting_to_an_audio_input">Connecting to an audio input</h3> + +<p>The most obvious use of the <code>connect()</code> method is to direct the audio output from one node into the audio input of another node for further processing. For example, you might send the audio from a {{domxref("MediaElementAudioSourceNode")}}—that is, the audio from an HTML5 media element such as {{HTMLElement("audio")}}—through a band pass filter implemented using a {{domxref("BiquadFilterNode")}} to reduce noise before then sending the audio along to the speakers.</p> + +<p>This example creates an oscillator, then links it to a gain node, so that the gain node controls the volume of the oscillator node.</p> + +<pre class="brush: js" style="font-size: 14px;">var AudioContext = window.AudioContext || window.webkitAudioContext; + +var audioCtx = new AudioContext(); + +var oscillator = audioCtx.createOscillator(); +var gainNode = audioCtx.createGain(); + +oscillator.connect(gainNode); +gainNode.connect(audioCtx.destination); +</pre> + +<h3 id="AudioParam_example">AudioParam example</h3> + +<p>In this example, we will be altering the gain value of a {{domxref("GainNode")}} using an {{domxref("OscillatorNode")}} with a slow frequency value. This technique is know as an <em>LFO</em>-controlled parameter.</p> + +<pre class="brush: js;highlight[8,9]">var AudioContext = window.AudioContext || window.webkitAudioContext; + +var audioCtx = new AudioContext(); + +// create an normal oscillator to make sound +var oscillator = audioCtx.createOscillator(); + +// create a second oscillator that will be used as an LFO (Low-frequency +// oscillator), and will control a parameter +var lfo = audioCtx.createOscillator(); + +// set the frequency of the second oscillator to a low number +lfo.frequency.value = 2.0; // 2Hz: two oscillations par second + +// create a gain whose gain AudioParam will be controlled by the LFO +var gain = audioCtx.createGain(); + +// connect the LFO to the gain AudioParam. This means the value of the LFO +// will not produce any audio, but will change the value of the gain instead +lfo.connect(gain.gain); + +// connect the oscillator that will produce audio to the gain +oscillator.connect(gain); + +// connect the gain to the destination so we hear sound +gain.connect(audioCtx.destination); + +// start the oscillator that will produce audio +oscillator.start(); + +// start the oscillator that will modify the gain value +lfo.start();</pre> + +<h4 id="AudioParam_notes">AudioParam notes</h4> + +<p>It is possible to connect an <code>AudioNode</code> output to more than one {{ domxref("AudioParam") }}, and more than one AudioNode output to a single {{ domxref("AudioParam") }}, with multiple calls to <code>connect()</code>. <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Fan-in_and_Fan-out">Fan-in and fan-out</a> are therefore supported.</p> + +<p>An {{ domxref("AudioParam") }} will take the rendered audio data from any <code>AudioNode</code> output connected to it and convert it to mono by <a href="/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#Up-mixing_and_down-mixing">down-mixing</a> (if it is not already mono). Next, it will mix it together with any other such outputs, and the intrinsic parameter value (the value the {{ domxref("AudioParam") }} would normally have without any audio connections), including any timeline changes scheduled for the parameter.</p> + +<p>Therefore, it is possible to choose the range in which an {{domxref("AudioParam")}} will change by setting the value of the {{domxref("AudioParam")}} to the central frequency, and to use a {{domxref("GainNode")}} between the audio source and the {{domxref("AudioParam")}} to adjust the range of the {{domxref("AudioParam")}} changes.</p> + +<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', '#widl-AudioNode-connect-AudioNode-AudioNode-destination-unsigned-long-output-unsigned-long-input', 'connect() to an AudioNode')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('Web Audio API', '#widl-AudioNode-connect-void-AudioParam-destination-unsigned-long-output', 'connect() to an AudioParam')}}</td> + <td>{{Spec2('Web Audio API')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<div> + + +<p>{{Compat("api.AudioNode.connect")}}</p> +</div> + +<h2 id="See_also">See also</h2> + +<ul> + <li><a href="/en-US/docs/Web/API/Web_Audio_API/Using_Web_Audio_API">Using the Web Audio API</a></li> +</ul> 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> |