Table of Contents

Class VolumeMeter

Namespace
VisioForge.Core.UI.WPF.VolumeMeterPro
Assembly
VisioForge.Core.dll

Professional audio volume meter control for WPF applications providing real-time VU-style level indication.

This control displays audio signal levels as a traditional VU meter with customizable appearance, orientation, and dynamic response characteristics. It's designed for audio monitoring applications, mixing consoles, and broadcast equipment requiring accurate level visualization.

Key features:

  • Horizontal and vertical orientation support
  • Configurable decibel range with professional audio standards
  • Real-time level indication with smooth visual response
  • Boost functionality for gain visualization
  • Minimal update interval control for performance optimization
  • Professional gray/green color scheme

Technical specifications:

  • Default range: -60dB to +18dB (professional audio standard)
  • Configurable boost multiplier for gain indication
  • Automatic scaling based on control dimensions
  • Efficient rectangle-based rendering
  • Update rate limiting to prevent excessive redraws

Performance characteristics:

  • Lightweight canvas-based rendering
  • Efficient rectangle reuse to minimize allocations
  • Configurable update intervals for CPU optimization
  • Smooth level transitions with minimal flickering

Usage pattern:

  1. Set MinDb, MaxDb, and Orientation properties
  2. Call Start() to begin level monitoring
  3. Update Amplitude property with current level
  4. Call Update() to refresh the display
  5. Call Stop() to pause monitoring

Thread safety: All methods should be called from the UI thread as this control manipulates WPF visual elements.

public class VolumeMeter : UserControl, IAnimatable, ISupportInitialize, IFrameworkInputElement, IInputElement, IQueryAmbient, IAddChild

Inheritance

Implements

Inherited Members

Constructors

VolumeMeter()

Initializes a new instance of the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter class.

public VolumeMeter()

Remarks

Sets up the volume meter with default professional audio standards:

  • Range: -60dB to +18dB for standard VU meter operation
  • Gray background with black foreground for professional appearance
  • Vertical orientation matching traditional VU meters
  • 100ms update interval for smooth visual response
  • Creates internal canvas for efficient rectangle-based rendering

Fields

AmplitudeProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.Amplitude dependency property.

public static readonly DependencyProperty AmplitudeProperty

Field Value

DependencyProperty

BoostProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.Boost dependency property.

public static readonly DependencyProperty BoostProperty

Field Value

DependencyProperty

MaxDbProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.MaxDb dependency property.

public static readonly DependencyProperty MaxDbProperty

Field Value

DependencyProperty

MinDbProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.MinDb dependency property.

public static readonly DependencyProperty MinDbProperty

Field Value

DependencyProperty

MinimalUpdateIntervalProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.MinimalUpdateInterval dependency property.

public static readonly DependencyProperty MinimalUpdateIntervalProperty

Field Value

DependencyProperty

OrientationProperty

Identifies the VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.Orientation dependency property.

public static readonly DependencyProperty OrientationProperty

Field Value

DependencyProperty

Properties

Amplitude

Gets or sets the current audio signal amplitude in decibels.

public float Amplitude { get; set; }

Property Value

float

Remarks

Setting this property does not auto-redraw. Call VisioForge.Core.UI.WPF.VolumeMeterPro.VolumeMeter.Update to repaint, so the internal rate limiter remains in control.

Boost

Gets or sets the boost multiplier for level indication.

public float Boost { get; set; }

Property Value

float

MaxDb

Gets or sets the maximum decibel level for the meter scale.

public float MaxDb { get; set; }

Property Value

float

MinDb

Gets or sets the minimum decibel level for the meter scale.

public float MinDb { get; set; }

Property Value

float

MinimalUpdateInterval

Gets or sets the minimal update interval to prevent excessive refresh operations.

public TimeSpan MinimalUpdateInterval { get; set; }

Property Value

TimeSpan

Orientation

Gets or sets the visual orientation of the volume meter.

public Orientation Orientation { get; set; }

Property Value

Orientation

Methods

Clear()

Clears the volume meter display and resets the amplitude to zero.

public void Clear()

Remarks

This method sets the amplitude to 0.0 and immediately redraws the control to provide a clean slate for new level readings. Useful for resetting the display when switching audio sources or clearing stale data.

Start()

Starts the volume meter and enables level display updates.

public void Start()

Remarks

This method activates the volume meter for receiving amplitude updates. Once started, the meter will respond to Update() calls and display level changes based on the current amplitude value.

Stop()

Stops the volume meter and disables level display updates.

public void Stop()

Remarks

This method deactivates the volume meter, causing it to ignore Update() calls. The current display state is preserved until Start() is called again.

Update()

Updates the volume meter display with the current amplitude value.

public void Update()

Remarks

This method performs rate-limited updates based on the MinimalUpdateInterval to optimize performance and prevent excessive redraws. The meter is only redrawn if sufficient time has passed since the last update and the control is in started state.