Table of Contents

Class RemoveSilenceBlock

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

Audio silence removal block that automatically detects and removes silent sections from audio streams. This block analyzes incoming audio to identify sections where the signal level falls below a specified threshold and drops them from the stream. Essential for cleaning up recordings, podcasts, voice content, and any audio that contains unwanted silent gaps or quiet segments. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class RemoveSilenceBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

RemoveSilenceBlock()

Initializes a new instance of the VisioForge.Core.MediaBlocks.AudioProcessing.RemoveSilenceBlock class with default silence removal settings suitable for general audio processing.

public RemoveSilenceBlock()

Properties

Input

Gets the primary input pad for audio silence removal processing.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads for this remove silence block. This block has a single input for audio processing.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad providing audio with silence processed.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads for this remove silence block. This block has a single output for processed audio.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Squash

Gets or sets the squash mode. Silent sections are always dropped; squash controls what happens to the timeline afterwards. When enabled (true), the timestamps of the surviving buffers are pulled back by the dropped duration, so the output is shorter and gapless - which also means the audio no longer lines up with the video of the same recording. When disabled (false), the gap is left in place and the surviving buffers keep their original timestamps, which keeps A/V sync.

public bool Squash { get; set; }

Property Value

bool

Threshold

Gets or sets the silence detection threshold. Audio levels below this threshold will be considered as silence. Values range from 0.0 (clamped to the element's -70 dB floor - only near-digital silence is removed) to 1.0 (full scale - every sample counts as silence). Lower values are more permissive; higher values remove more audio.

public double Threshold { get; set; }

Property Value

double

Remarks

Converted to the dB scale the underlying removesilence element uses (20 * log10(value), clamped to the element's -70..70 dB range), so the default 0.001 reaches the element as -60 dB - the same threshold the element itself defaults to. The element then keeps whole decades of it, truncating toward zero - so anything in (-70, -60] is applied as -60 dB. Over the negative range that rounds up: a threshold asked for as -65 dB removes as much audio as -60 dB, never as little as -70 dB.

Two limits of the element are worth knowing before it is put in a graph, because neither is reachable from here. Its pads are S16LE, mono only, and this block inserts no converter, so a stereo stream is downmixed for everything downstream of it - the graph links at all only because UniversalSourceBlock carries its own converter. And its detector ANDs the level test with a zero-crossing test - a buffer counts as speech only when it is both loud enough and low-frequency enough - so noise-like or high-frequency content is treated as silence at every threshold, including the -70 dB floor.

Exceptions

ArgumentOutOfRangeException

Thrown when the value is not between 0.0 and 1.0.

Type

Gets the type of this media block.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Constructs and initializes the removesilence filter and its associated GStreamer elements. This method creates the filter with the specified silence detection parameters, establishes input and output pads, and prepares the block for processing audio with silence removal capabilities.

public override bool Build()

Returns

bool

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

CleanUp()

Releases all resources and performs cleanup operations for this remove silence block. This method disposes of the GStreamer elements and resets the build state.

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 that provides additional functionality around the GStreamer removesilence filter element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the GStreamer removesilence filter.

GetElement()

Gets the underlying GStreamer element that performs the silence removal processing.

public Element GetElement()

Returns

Element

The GStreamer Element instance representing the removesilence filter.

IsAvailable()

Determines whether this media block is available. Checks if the required GStreamer removesilence plugin is installed and accessible.

public static bool IsAvailable()

Returns

bool

true if the removesilence element is available; otherwise, false.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this remove silence 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