Table of Contents

Class WaveformPainter

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

Professional real-time audio waveform painter control for WPF applications providing time-domain visualization.

This control displays audio waveform data as a continuous oscilloscope-style visualization, showing the time-domain representation of audio signals. It's designed for audio editing applications, monitoring systems, and diagnostic tools requiring waveform analysis.

Key features:

  • Real-time waveform visualization with scrolling display
  • Dual-channel support (top and bottom values for stereo or min/max)
  • Automatic scaling and centering for optimal display
  • Continuous scrolling with wraparound functionality
  • Configurable blank zone for visual separation
  • Professional bisque fill with black outline

Technical specifications:

  • Polygon-based rendering for smooth waveform curves
  • Automatic vertical scaling based on control height
  • Configurable horizontal scaling (default 2 pixels per sample)
  • Blank zone system for visual continuity
  • Center-line reference for zero-crossing indication

Performance characteristics:

  • Efficient polygon point management with reuse
  • Smooth scrolling without flicker
  • Minimal memory allocation through point recycling
  • Optimized for continuous real-time operation

Rendering architecture:

  • Uses WPF Polygon for anti-aliased waveform rendering
  • Maintains dual point arrays for top and bottom envelope
  • Automatic point insertion and position management
  • Responsive layout with size change handling

Usage pattern:

  1. Call Start() to begin waveform painting
  2. Feed audio samples via AddValue(float maxValue, float minValue)
  3. Call Stop() to pause painting
  4. Call Clear() to reset the display

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

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

Inheritance

Implements

Inherited Members

Constructors

WaveformPainter()

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

Sets up the waveform painter with professional appearance and optimal performance settings:

  • Creates a gray canvas background with black foreground
  • Initializes a bisque-filled polygon with black outline for the waveform
  • Sets up size change handling for responsive scaling
  • Positions the waveform at the control center

The control is created in a stopped state and requires Start() to begin processing.

public WaveformPainter()

Methods

AddValue(float, float)

Adds a new audio sample value to the waveform display.

This method processes audio amplitude data and updates the waveform visualization. It handles both the top and bottom envelope values to create a filled waveform shape.

The method performs the following operations:

  1. Checks if painting is active and calculates visible pixel width
  2. Creates polygon points for the current sample position
  3. Handles wraparound scrolling when reaching the right edge
  4. Maintains a blank zone for visual separation
  5. Updates polygon points for smooth waveform rendering

Performance optimizations:

  • Efficient polygon point management with reuse
  • Automatic wraparound for continuous display
  • Minimal memory allocation through point recycling

Thread safety: Must be called from the UI thread.

public void AddValue(float maxValue, float minValue)

Parameters

maxValue float

Maximum amplitude value for the current sample (top envelope).

minValue float

Minimum amplitude value for the current sample (bottom envelope).

Clear()

Clears the waveform display and repositions the rendering cursor to the left edge.

This method resets the waveform visualization to a blank state while maintaining the painter's started/stopped state. The rendering position is reset to the beginning, and all polygon points are cleared for a fresh start.

Useful for:

  • Clearing the display when switching audio sources
  • Resetting the visualization after long pauses
  • Starting fresh waveform capture

Thread safety: Must be called from the UI thread.

public void Clear()

Start()

Starts.

public void Start()

Stop()

Stops.

public void Stop()