Skip to main content
Version: Latest

ChannelMergerNode

The ChannelMergerNode interface combines multiple mono inputs into a single output whose channels correspond, in order, to the node's inputs. It is an AudioNode with a variable number of single-channel inputs and one output.

Each input is treated as a single channel: the signal connected to input i becomes channel i of the output. This is the counterpart of ChannelSplitterNode.

Press play, then choose which merger input each split channel feeds; click either box to bypass the pair and hear the original stereo image again. The default sample carries the voice in the left channel and the music in the right, so each routing choice is easy to place, and the meters show what reaches each speaker.

Loading...

Constructor​

constructor(context: BaseAudioContext, options?: ChannelMergerOptions)

ChannelMergerOptions​

Inherits all properties from AudioNodeOptions.

ParameterTypeDefault
numberOfInputs
Optional
number6Number of inputs to merge. Must be in the range 1 – 32.

You can also create a ChannelMergerNode via the BaseAudioContext.createChannelMerger(numberOfInputs?: number) factory method, which uses default values when called without arguments.

Example​

import { AudioContext } from 'react-native-audio-api';

const ctx = new AudioContext();
const merger = ctx.createChannelMerger(2);

const left = ctx.createOscillator();
const right = ctx.createOscillator();

left.connect(merger, 0, 0);
right.connect(merger, 0, 1);

merger.connect(ctx.destination);

Properties​

Inherits all properties from AudioNode.

AudioNodeproperties

ChannelMergerNode does not define any additional properties.

Methods​

Inherits all methods from AudioNode.

AudioNodemethods

ChannelMergerNode does not define any additional methods.

Remarks​

numberOfInputs​

  • Default value is 6.
  • Nominal range is 1 – 32. Values outside this range throw an IndexSizeError.
  • Cannot be changed after construction.

Channel configuration​

  • channelCount is fixed at 1 and channelCountMode is fixed at explicit. Attempts to change them throw an error.
  • Use the input argument of connect to target a specific input, e.g. source.connect(merger, 0, 2) routes into channel 2.