Table of Contents

Class VolumeBlock

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

Audio volume control block that provides precise control over audio levels and muting. This block allows dynamic adjustment of audio volume using a linear scale where 1.0 represents the original volume level. It supports both volume scaling (0.0 to 10.0 or higher) and instant muting without changing the volume setting. Unlike the AmplifyBlock which focuses on gain with clipping control, the VolumeBlock provides simple, direct volume control suitable for user-facing volume controls and audio mixing scenarios. The block processes audio in real-time with minimal latency and CPU overhead. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class VolumeBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

VolumeBlock()

Initializes a new instance of the VisioForge.Core.MediaBlocks.AudioProcessing.VolumeBlock class. Creates a volume control block with default settings (volume = 1.0, mute = false). The block is ready to be connected in a media pipeline for real-time volume adjustment.

public VolumeBlock()

Properties

Input

Gets the single audio input pad for this block.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads. This block has a single audio input.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Level

Gets or sets the volume level multiplier. Valid range is typically 0.0 to 10.0, where 0.0 is silence, 1.0 is original volume, and values greater than 1.0 amplify the audio. Changes take effect immediately during playback. Default value is 1.0 (100% original volume).

public double Level { get; set; }

Property Value

double

Mute

Gets or sets a value indicating whether this VisioForge.Core.MediaBlocks.AudioProcessing.VolumeBlock is muted.

public bool Mute { get; set; }

Property Value

bool

Output

Gets the single audio output pad for this block.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads. This block has a single audio output.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Type

Gets the block type identifier for this volume control block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds and initializes the volume control element within the pipeline. Creates the GStreamer volume element, sets initial volume and mute state, and establishes pad connections for audio flow.

public override bool Build()

Returns

bool

true if the volume block was successfully built; false if an error occurred.

CleanUp()

Releases all internal resources and disposes of the volume filter element. Called during disposal to ensure proper cleanup of native GStreamer resources.

public void CleanUp()

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 for the volume filter.

public BaseElement GetCore()

Returns

BaseElement

The VolumeFilter element that performs the volume adjustment.

GetElement()

Gets the underlying GStreamer element for this volume block.

public Element GetElement()

Returns

Element

The GStreamer volume element that controls audio levels.

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.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context for this volume block, providing access to shared resources. This method is called internally during pipeline construction.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline that owns this volume block.

See Also