Class VolumeBlock
- 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, IMediaBlockInternalsInheritance
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
Inputs
Gets all input pads. This block has a single audio input.
public override MediaBlockPad[] Inputs { get; }Property Value
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
Mute
Gets or sets a value indicating whether this VisioForge.Core.MediaBlocks.AudioProcessing.VolumeBlock is muted.
public bool Mute { get; set; }Property Value
Output
Gets the single audio output pad for this block.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads. This block has a single audio output.
public override MediaBlockPad[] Outputs { get; }Property Value
Type
Gets the block type identifier for this volume control block.
public override MediaBlockType Type { get; }Property Value
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
-
trueif the volume block was successfully built;falseif 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
disposingbool-
trueto release both managed and unmanaged resources;falseto 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
-
trueif 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
pipelineMediaBlocksPipeline-
The MediaBlocksPipeline that owns this volume block.