Skip to content

Latest commit

 

History

History
169 lines (131 loc) · 5.62 KB

UI_METERING.md

File metadata and controls

169 lines (131 loc) · 5.62 KB

BC Compressor - Metering & UI Guide

Overview

The BC Compressor plugin features a comprehensive real-time metering display that provides visual feedback for audio levels, gain reduction, and DSP activity. This guide documents the UI/UX implementation and how to interpret the meters.

Editor Window

Dimensions

  • Default size: 700 × 400 pixels
  • Responsive: Can be resized by the host

Layout Sections

1. Header Section (Top)

  • Height: 50 pixels
  • Background: Dark gray (#3a3a3a)
  • Content: "BC COMPRESSOR" title in 24pt white font
  • Purpose: Visual branding and window identification

2. Control Panel (Center)

  • Controls: 7 rotary sliders + 1 toggle button

  • Layout:

    • Top Row (left-to-right): Threshold, Ratio, Attack, Release
    • Bottom Row (left-to-right): Knee, Makeup, Mix
    • Sidechain Button: Bottom-right corner
  • Slider Style: Rotary horizontal/vertical drag

  • Text Display: Below each slider (normalized value)

  • Label: Above each control

3. Metering Panel (Bottom)

  • Height: 80 pixels
  • Background: Dark panel (#1a1a1a) with rounded corners
  • Refresh Rate: 30 Hz (33ms update interval)
  • Three Meters (left-to-right):
Input Level Meter
  • Label: "INPUT"
  • Range: -60 dB to 0 dB
  • Bar Color (dynamic):
    • Green (#00aa00): Normal levels (-60 to -12 dB)
    • Orange (#ff8800): Warning zone (-12 to -3 dB)
    • Red (#ff0000): Clipping risk (-3 dB and above)
  • Display: Current dB value (1 decimal place)
  • Purpose: Monitor pre-compression input levels
Gain Reduction Meter
  • Label: "GAIN REDUCTION"
  • Range: -20 dB to 0 dB (shows compression amount)
  • Bar Color: Green (indicates amount of dynamic compression active)
  • Display: Current GR value in dB (1 decimal place)
  • Purpose: Real-time compression monitoring—higher bar = more active compression
Output Level Meter
  • Label: "OUTPUT"
  • Range: -60 dB to 0 dB
  • Bar Color (dynamic):
    • Green (#00aa00): Normal levels (-60 to -12 dB)
    • Orange (#ff8800): Warning zone (-12 to -3 dB)
    • Red (#ff0000): Clipping risk (-3 dB and above)
  • Display: Current dB value (1 decimal place)
  • Purpose: Monitor post-compression output levels (after makeup gain and mix)

Meter Behavior

Level Calculation

Input Level:

  • Peak amplitude across all channels per processing block
  • Converted to dB: dB = 20 * log10(peakAmplitude)
  • Floor: -80 dB (silence)

Output Level:

  • Peak amplitude after compression, makeup gain, and dry/wet mix
  • Same dB conversion as input
  • Reflects the actual audio leaving the plugin

Gain Reduction:

  • Peak GR across the processing block
  • Range: -20 dB to 0 dB
    • 0 dB = no compression active
    • -20 dB = maximum compression (hard limiting)
  • Displayed as negative value to indicate reduction

Smoothing

  • Algorithm: Exponential smoothing (70% hysteresis)
  • Formula: smoothed = 0.7 * smoothed_prev + 0.3 * current_value
  • Purpose: Reduce visual jitter and make meters easier to read
  • Update Frequency: 30 Hz timer callback

Real-Time Metering

The metering is thread-safe using std::atomic<float> for data exchange between audio thread and UI thread:

  1. Audio Thread (CompressorModule):

    • Calculates peak levels during process()
    • Stores results in atomic members
    • No blocking or allocations
  2. UI Thread (Editor):

    • Reads atomic values in timerCallback() (30 Hz)
    • Applies smoothing filter
    • Triggers repaint()

Color-Coded Alerts

Green Zone (-60 to -12 dB)

  • ✅ Optimal levels
  • Safe from clipping
  • Good headroom

Orange Zone (-12 to -3 dB)

  • ⚠️ Warning: approaching clipping
  • Consider reducing input gain or makeup gain
  • May indicate aggressive compression

Red Zone (-3 dB and above)

  • 🔴 Danger: imminent clipping
  • Immediate action recommended
  • Audio may be distorted in DAW

Interaction

Parameter Changes

  • Sliders are linked to APVTS (Audio Processor Value Tree State)
  • Changes are reflected in real-time
  • Gain reduction meter updates to show compression response

Lookahead Feedback

  • If lookahead is enabled (> 0 ms), the GR meter shows delayed response
  • Latency compensation is automatic (host-aware)

Sidechain Activity

  • When sidechain is enabled, the input meter reflects sidechain signal
  • Can be used to monitor external sidechain input

Best Practices for DAW Integration

  1. Monitor Input Levels: Ensure input doesn't exceed -3 dB
  2. Set Threshold Appropriately: Peak signals should trigger compression (~5-10 dB above threshold)
  3. Watch Makeup Gain: Use to compensate for GR while maintaining dynamic punch
  4. Mix Control: Use for parallel compression (dry/wet blend)
  5. Lookahead: Enable for smooth, transparent compression on transients

Technical Implementation

Files Modified

  • Source/PluginEditor.h — Added meter state variables
  • Source/PluginEditor.cpp — Enhanced paint() and timerCallback()
  • Source/DSP/CompressorModule.h — Added atomic level members
  • Source/DSP/CompressorModule.cpp — Implemented level tracking in process()
  • Source/DSP/EffectModule.h — MeterData struct with input/output/GR

Performance Impact

  • CPU Overhead: Negligible (<0.1%)
  • Memory: 12 bytes per compressor instance (3 × float atomics)
  • Latency: Zero (non-blocking)

Future Enhancements

Potential improvements for future versions:

  • Spectrum analyzer display
  • Peak hold indicators
  • RMS level display alongside peak
  • Graphical GR visualization (curve)
  • Automation curve recording display
  • A/B bypass comparison meter