Connections
Nesting is connect(): every element connects to its parent, and top-level elements
connect to the context's destination.
Nesting
The signal flows from the inside out, from the source up to the output.
<!-- osc.connect(filter); filter.connect(gain); gain.connect(destination) -->
<gain gain={0.2}>
<biquadFilter frequency={800}>
<oscillator type="sawtooth"></oscillator>
</biquadFilter>
</gain>Mixing
Several children of one parent are all connected to it, so their signals add up.
<!-- both oscillators connect to the gain, which sums them -->
<gain gain={0.1}>
<oscillator frequency={220}></oscillator>
<oscillator frequency={330}></oscillator>
</gain>Into an AudioParam
param="…" connects the child to one of its parent's AudioParams instead of its input. The
signal is added to the param's value, which is how LFOs modulate a frequency or a gain.
<oscillator frequency={220}>
<!-- lfoGain.connect(osc.frequency): vibrato of ±10 Hz at 5 Hz -->
<gain gain={10} param="frequency">
<oscillator frequency={5}></oscillator>
</gain>
</oscillator>Outputs and inputs
output and input choose which output of the child connects to which
input of the parent, as the second and third arguments of connect().
<!-- low.connect(merger, 0, 1) and high.connect(merger, 0, 0): low on the right, high on the left -->
<channelMerger numberOfInputs={2}>
<oscillator frequency={220} input={1}></oscillator>
<oscillator frequency={330} input={0}></oscillator>
</channelMerger>One parent per node
Nesting describes a tree, so a node can't feed two places, such as a splitter whose outputs go to different nodes, or a feedback loop. For those, connect by hand with audioNode. The Echo example wires a feedback loop this way.