Class AudioBalanceBlock
- Assembly
- VisioForge.Core.dll
Audio balance processing block for stereo panorama control in the MediaBlocks pipeline. This block adjusts the stereo balance (left/right channel distribution) of audio content, allowing positioning of audio from full left (-1.0) through center (0.0) to full right (+1.0). Essential for stereo audio mixing, surround sound processing, and spatial audio applications. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class AudioBalanceBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
AudioBalanceBlock(float)
Initializes a new instance of the VisioForge.Core.MediaBlocks.AudioProcessing.AudioBalanceBlock class with the specified stereo balance. Creates an audio balance processing block for controlling stereo panorama positioning.
public AudioBalanceBlock(float balance = 0)Parameters
balancefloat-
The initial stereo balance value (-1.0 to +1.0, default 0.0 for center).
Examples
// Create balance block for center positioning
var centerBalance = new AudioBalanceBlock();
// Create balance block shifted to the left
var leftBalance = new AudioBalanceBlock(-0.5f);
// Create balance block shifted to the right
var rightBalance = new AudioBalanceBlock(0.7f);
Properties
Balance
Gets or sets the stereo balance controlling audio positioning in the stereo panorama. This property adjusts the relative levels of left and right audio channels to create a stereo positioning effect. Useful for audio mixing, spatial audio effects, and accessibility features.
public float Balance { get; set; }Property Value
Remarks
Balance adjustment works by:
- Negative values: Attenuate right channel, emphasize left channel
- Zero value: Equal left and right channel levels (no balance change)
- Positive values: Attenuate left channel, emphasize right channel The adjustment preserves overall audio energy while shifting stereo perception.
Input
Gets the primary input pad for receiving audio to be balance-processed.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads for this audio balance block. This block has a single input for stereo audio processing.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary output pad providing balanced stereo audio.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads for this audio balance block. This block has a single output for balanced stereo audio.
public override MediaBlockPad[] Outputs { get; }Property Value
Type
Gets the block type identifier for audio balance processing.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the audio balance block by creating the GStreamer audio balance filter. This method configures the underlying audio processing element, sets up input/output pads, and applies the initial balance settings for stereo panorama control.
public override bool Build()Returns
- bool
-
trueif the audio balance block was successfully built and configured;falseif initialization failed.
CleanUp()
Cleans up the audio balance block by disposing of the GStreamer audio balance filter. This method safely releases the underlying audio processing resources and resets the block to an unbuilt state for potential reuse or final disposal.
public void CleanUp()Dispose(bool)
Releases unmanaged and optionally managed resources used by the audio balance block. Properly disposes of the GStreamer audio balance filter and associated resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer base element for this audio balance block. Provides access to the underlying audio balance filter for advanced operations.
public BaseElement GetCore()Returns
- BaseElement
-
The BaseElement representing the audio balance filter component.
GetElement()
Gets the underlying GStreamer element for direct GStreamer API access. Provides low-level access to the audio balance filter element for advanced audio processing operations.
public Element GetElement()Returns
- Element
-
The GStreamer Element representing the audio balance filter.
IsAvailable()
Determines whether the audio balance block is available in the current environment. Checks for the presence of required GStreamer audio processing plugins and dependencies. The correct NuGet SDK redistribution package should be included in your project.
public static bool IsAvailable()Returns
- bool
-
trueif audio balance processing is available; otherwise,false.
Remarks
This method verifies that the underlying GStreamer audio balance filter is properly installed and can be instantiated. Always check availability before using the block in production code.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this audio balance block. This method is called internally by the MediaBlocks pipeline during block initialization to provide access to pipeline resources and logging context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The parent MediaBlocksPipeline that owns this block.