diff options
Diffstat (limited to 'files/zh-cn/web/api/audionode/connect(audioparam)/index.html')
-rw-r--r-- | files/zh-cn/web/api/audionode/connect(audioparam)/index.html | 163 |
1 files changed, 0 insertions, 163 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 deleted file mode 100644 index eb82534aed..0000000000 --- a/files/zh-cn/web/api/audionode/connect(audioparam)/index.html +++ /dev/null @@ -1,163 +0,0 @@ ---- -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> |