Table of Contents

Class AudioMixerBlock

Namespace
VisioForge.Core.MediaBlocks.AudioProcessing
Assembly
VisioForge.Core.dll

Audio mixer block that combines multiple audio streams into a single output stream. This block accepts multiple audio inputs and mixes them together with individual volume and mute controls for each input channel. The mixer automatically handles format conversion through internal audio resamplers to ensure all inputs are converted to a common format before mixing. Essential for combining multiple audio sources like microphones, music tracks, sound effects, and other audio streams in broadcast, conferencing, and multimedia applications. Supports dynamic input addition/removal during playback and real-time volume/mute control. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class AudioMixerBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

AudioMixerBlock(AudioMixerSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.AudioProcessing.AudioMixerBlock class with the specified mixer settings. Creates an audio mixer block ready for input creation and audio mixing operations.

public AudioMixerBlock(AudioMixerSettings settings)

Parameters

settings AudioMixerSettings

The mixer settings defining output format and mixing parameters.

AudioMixerBlock(MediaBlocksPipeline, AudioMixerSourceSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.AudioProcessing.AudioMixerBlock class with predefined audio sources. Creates an audio mixer block and automatically connects the specified audio sources as inputs. This constructor provides a convenient way to create a mixer with multiple audio sources.

public AudioMixerBlock(MediaBlocksPipeline pipeline, AudioMixerSourceSettings settings)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocks pipeline that will contain this mixer.

settings AudioMixerSourceSettings

The mixer source settings containing input source definitions and output format.

Properties

Input

Gets the first input pad of the audio mixer. Returns null if no input pads have been created yet.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads available on this audio mixer. Returns an array of all input pads that have been created for receiving audio streams.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output pad that provides the mixed audio stream. This pad outputs the combined result of all input audio streams.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads from this audio mixer. Always returns a single output pad as mixers combine multiple inputs into one output.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the audio mixer settings. Contains configuration parameters for the output audio format including sample rate, channels, and audio format specifications.

public AudioMixerSettings Settings { get; set; }

Property Value

AudioMixerSettings

Type

Gets the block type identifier for audio mixing operations.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Constructs and initializes the audio mixer and its associated GStreamer elements. This method creates the mixer element, sets up audio resamplers for each input, establishes all pad connections, and prepares the mixer for combining multiple audio streams.

public override bool Build()

Returns

bool

true if the mixer was successfully built and configured; false if initialization failed.

CleanUp()

Releases all resources and performs cleanup operations for this audio mixer block. This method disposes of the mixer element, all resamplers, and input blocks.

public void CleanUp()

CreateNewInput()

Creates a new input pad for the audio mixer. Each input pad can receive an independent audio stream that will be mixed with other inputs. The new input is not connected to the mixer until the Build() method is called.

public MediaBlockPad CreateNewInput()

Returns

MediaBlockPad

A new MediaBlockPad configured for audio input.

CreateNewInputLive()

Creates a new input pad and immediately connects it to the running audio mixer. This method allows dynamic input addition while the pipeline is in playing state. Each input includes an audio resampler to ensure format compatibility.

public MediaBlockPad CreateNewInputLive()

Returns

MediaBlockPad

A new MediaBlockPad configured and connected for live audio input.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetCore()

Gets the core BaseElement wrapper that provides additional functionality around the GStreamer audio mixer element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the GStreamer audio mixer.

GetElement()

Gets the underlying GStreamer element that performs the audio mixing operations.

public Element GetElement()

Returns

Element

The GStreamer Element instance representing the audio mixer.

IsAvailable()

Determines whether this media block is available. Correct NuGet SDK redist should be included into your project.

public static bool IsAvailable()

Returns

bool

true if this media block is available; otherwise, false.

RemoveInputLive(MediaBlockPad)

Removes an input from the audio mixer while the pipeline is running. This method safely disconnects and removes an input pad, its associated resampler, and mixer sink pad without interrupting other audio streams.

public bool RemoveInputLive(MediaBlockPad blockPad)

Parameters

blockPad MediaBlockPad

The MediaBlockPad to remove from the mixer.

Returns

bool

true if the input was successfully removed; false if an error occurred.

SetMute(int, bool)

Sets the mute state for a specific input stream in the mixer. Muted streams continue to be processed but their audio is silenced in the mix.

public void SetMute(int streamIndex, bool value)

Parameters

streamIndex int

The zero-based index of the input stream to mute/unmute.

value bool

True to mute the stream, false to unmute.

SetVolume(int, double)

Sets the volume level for a specific input stream in the mixer. Volume is applied independently to each input before mixing.

public void SetVolume(int streamIndex, double value)

Parameters

streamIndex int

The zero-based index of the input stream to adjust.

value double

The volume multiplier (0.0 = silence, 1.0 = normal, 10.0 = maximum amplification).

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this audio mixer block with a pipeline and initializes its internal context. This method is called internally when the block is added to a pipeline.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

See Also