Studio Dynamic Compressor — User Guide

Professional RMS-based dynamics processing: transparent level control with auto-calibration, 6 factory presets, and mathematical compression curves for broadcast-quality results.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 1.0 (2025) License: MIT License Repo: https://github.com/ShaiCohen-ops/Praat-plugin_AudioTools
Contents:

What this does

This script implements a professional-grade dynamic compressor using RMS-based detection with automatic calibration for accurate level matching. The processor analyzes input levels, applies precise gain reduction based on mathematical compression curves, and automatically compensates with makeup gain. Key features include: (1) RMS detection: Uses Praat's Intensity object for perceptually accurate level measurement. (2) Auto-calibration: Automatically matches envelope levels to input signal for precise threshold operation. (3) 6 factory presets: Optimized settings for vocals, drums, mix bus, limiting, and creative effects. (4) Mathematical compression: Pure algorithmic processing without look-ahead artifacts. (5) Professional workflow: Automatic naming, peak normalization, and cleanup.

Key Features:

What is dynamic compression? Dynamic range compression reduces the difference between loud and quiet sounds. Benefits: (1) Level control: Prevents peaks from dominating, brings up quiet details. (2) Density: Creates thicker, more present sounds. (3) Control: Tames unpredictable dynamics for consistent levels. (4) Creative effects: Can create pumping, breathing, or aggressive effects. (5) Broadcast readiness: Meets loudness standards for streaming and broadcast. This implementation uses RMS (Root Mean Square) detection which responds to average levels rather than instantaneous peaks, creating more musical and transparent compression.

Technical Implementation: (1) Input analysis: Measure peak level and convert to dBFS. (2) Envelope generation: Create RMS envelope using Praat's Intensity object with calculated frequency response. (3) Auto-calibration: Shift envelope to match input levels for accurate threshold operation. (4) Gain computation: Apply mathematical compression formula to generate gain reduction curve. (5) Makeup gain: Apply calculated gain compensation. (6) Signal application: Multiply audio by gain envelope for final compression. (7) Output management: Peak normalization, automatic naming, and cleanup.

Quick start

  1. In Praat, select exactly one Sound object.
  2. Run script…studio_dynamic_compressor.praat.
  3. Choose Preset from dropdown:
    • Vocal Leveler: Smooth vocal compression
    • Drum Punch: Fast, aggressive drum control
    • Mix Bus Glue: Gentle bus compression
    • Hard Limiter: Peak control and protection
    • Squash: Heavy creative compression
    • NUKE: Extreme effect compression
  4. Or select Custom and adjust:
    • Threshold_dB: Compression start point
    • Ratio: Amount of compression
    • Attack_Release_window: Time response
    • Makeup_Gain_dB: Output level compensation
  5. Set Scale_peak (0.99 recommended)
  6. Enable Play_result for immediate audition
  7. Enable Keep_original to preserve source
  8. Click OK — processed sound created with descriptive suffix
Quick tip: Start with presets to understand different compression characters. For vocals: use Vocal Leveler for smooth, transparent control. For drums: use Drum Punch for aggressive, fast compression. For full mixes: use Mix Bus Glue for gentle cohesion. The auto-calibration ensures thresholds work correctly regardless of input levels. Makeup gain is automatically calculated for each preset — adjust manually if needed. Output is automatically normalized to prevent clipping.
Important: RMS DETECTION — compressor responds to average levels, not instantaneous peaks. Time constants: Very short windows (<0.01s) may cause distortion. Extreme ratios: High ratios (>10:1) create limiting behavior. Makeup gain: Can increase noise floor when compressing heavily. Auto-calibration: Requires measurable signal — very quiet sounds may not calibrate correctly. Peak normalization: Output scaled to prevent clipping — may be quieter than expected with heavy compression. Original preservation: "Keep_original=0" removes source sound — use with caution.

Compression Theory

Dynamic Range Fundamentals

What is Dynamic Range?

Audio level variation:

DYNAMIC RANGE = Difference between loudest and quietest parts DR = 20 × log₁₀(peak_level / noise_floor) Typical dynamic ranges: Speech: 30-40 dB Music: 50-60 dB (acoustic), 10-20 dB (heavily compressed) Symphony: 80+ dB Digital systems: 96 dB (16-bit), 144 dB (24-bit) Compression purpose: Reduce dynamic range Bring up quiet parts, control loud parts Make audio more consistent in level Prevent peaks from causing distortion Create denser, more present sound Our approach: RMS-based compression Responds to average levels (like human hearing) More musical than peak-based compression Creates smoother, more transparent results

Compression Parameters

Key control parameters:

🎛️ Compression Controls

Threshold:

  • Level where compression begins
  • Below threshold: no effect
  • Above threshold: gain reduction applied
  • Typical range: -40 dB to 0 dB

Ratio:

  • Amount of compression above threshold
  • 2:1 = gentle, 4:1 = medium, 10:1 = heavy
  • ∞:1 = limiting (no signal above threshold)
  • Our range: 1.5:1 to 100:1

Time Constants:

  • How fast compressor responds to level changes
  • Fast: aggressive, punchy
  • Slow: smooth, transparent
  • Our implementation: Unified attack/release window

RMS vs Peak Detection

Detection Method Differences

RMS (Root Mean Square):

RMS = Square root of mean of squares RMS = √( (x₁² + x₂² + ... + xₙ²) / n ) Properties: - Responds to average power (like human loudness perception) - Ignores brief peaks - Creates smoother, more musical compression - Less prone to over-compressing transients PEAK DETECTION: - Responds to instantaneous maximum levels - Catches all peaks, even very brief ones - Can sound aggressive or "grabby" - Good for peak limiting and protection Our choice: RMS detection - More musical for general compression - Better matches human loudness perception - Creates smoother gain reduction - Standard for vocal and mix bus compression

Perceptual Advantages

Why RMS sounds more natural:

RMS vs Peak Detection Comparison:

Scenario: Drum hit with sharp transient
Peak detection: Sees transient peak → heavy compression
RMS detection: Sees average level → moderate compression

Result:
Peak: Transient suppressed, "flat" sound
RMS: Transient preserved, natural dynamics

Human hearing:
We perceive loudness based on average power, not peaks
RMS matches our perceptual experience
Creates more transparent, musical compression

Exception: Peak limiting for protection still needed

Compression Mathematics

Gain Reduction Formula

Mathematical compression curve:

COMPRESSION FORMULA: gain_reduction = 10^( ( -1 × (level - threshold) × (1 - 1/ratio) ) / 20 ) Where: level = input level in dB threshold = compression threshold in dB ratio = compression ratio (e.g., 4.0 for 4:1) Step-by-step derivation: 1. Calculate overshoot above threshold: overshoot = level - threshold 2. Apply ratio to overshoot: compressed_overshoot = overshoot / ratio 3. Calculate output level: output_level = threshold + compressed_overshoot 4. Convert to gain reduction: gain_reduction_db = level - output_level = overshoot - (overshoot / ratio) = overshoot × (1 - 1/ratio) 5. Convert to linear gain: gain_reduction_linear = 10^( -gain_reduction_db / 20 ) Final formula matches professional compressors

Compression Curve Visualization

Compression Curves for Different Ratios

Input/Output Transfer Characteristics:
Ratio 1:1 | 2:1 | 4:1 | 10:1 | ∞:1
-40dB → -40 | -40 | -40 | -40 | -40
-30dB → -30 | -30 | -30 | -30 | -30
-20dB → -20 | -20 | -20 | -20 | -20
-10dB → -10 | -15 | -17.5| -19 | -20
0dB → 0 | -10 | -15 | -18 | -20

Threshold = -20 dB, makeup gain applied for visualization

Processing Algorithm

Auto-Calibration System

Input Level Measurement

Precise level matching:

STEP 1: Measure input peak selectObject: sound in_max = Get maximum: 0, 0, "Sinc70" in_db = 20 × log10(abs(in_max) + 0.000001) Why Sinc70 interpolation? - More accurate peak detection than simple maximum - Accounts for inter-sample peaks - Professional-grade peak measurement - Prevents underestimation of true peaks STEP 2: Generate RMS envelope detect_freq = 3.2 / attack_Release_window intensity = To Intensity: detect_freq, 0, "yes" Why this frequency calculation? - attack_Release_window determines time response - Lower frequency = slower response - 3.2 factor provides good time constant matching - Minimum 10Hz ensures reasonable response STEP 3: Auto-calibration env_max = Get maximum: 0, 0, "Parabolic" offset = in_db - env_max Formula: "self + offset" Result: Envelope accurately matches input levels Threshold settings work as expected No manual level adjustment needed Professional workflow

Time Constant Calculation

Attack/Release Response:

UNIFIED TIME WINDOW: Our implementation uses single window for both attack and release attack_Release_window determines overall response speed Frequency calculation: detect_freq = 3.2 / attack_Release_window Why 3.2? - Empirical testing showed this provides good response matching - Creates smooth, musical compression characteristics - Matches expected attack/release behavior Time constant examples: Window=0.05s → Frequency=64Hz → Medium response Window=0.02s → Frequency=160Hz → Fast response Window=0.10s → Frequency=32Hz → Slow response Practical ranges: Fast compression: 0.005-0.02s (drums, percussion) Medium compression: 0.03-0.08s (vocals, general) Slow compression: 0.09-0.20s (mix bus, mastering)

Gain Computation

Mathematical Compression

Precise gain reduction:

STEP 1: Convert to control matrix control_mat = Down to Matrix STEP 2: Apply compression formula Formula: "if self > t then 10^((-1 * (self - t) * (1 - 1/r)) / 20) else 1 fi" Where: t = threshold_dB r = ratio Explanation: - "self > t": Only compress above threshold - "(self - t)": Amount above threshold - "(1 - 1/r)": Compression factor based on ratio - "/ 20": Convert dB to linear gain - "10^(...)": dB to linear conversion STEP 3: Apply makeup gain Formula: "self * 10^(mkp/20)" Where: mkp = makeup_Gain_dB Result: Complete gain reduction envelope Ready for application to audio signal

Makeup Gain Strategy

Level compensation:

Makeup Gain Principles:

Purpose: Compensate for level loss from compression
Without makeup gain: Compressed signal is quieter

Automatic calculation in presets:
Vocal: +4dB (moderate compression)
Drum: +3dB (fast, aggressive)
Mix Bus: +1dB (gentle, transparent)
Limiter: 0dB (peak control only)
Squash: +8dB (heavy compression)
NUKE: +12dB (extreme effect)

Manual adjustment:
- Listen for consistent perceived loudness
- Avoid excessive gain that causes noise
- Match to target loudness standards if needed

Peak normalization: Final safety net to prevent clipping

Signal Application

Final Processing Stage

Gain envelope application:

STEP 1: Convert gain to audio selectObject: control_mat control_sig = To Sound Rename: "Control_Voltage" STEP 2: Apply to audio selectObject: sound compressed = Copy: original_name$ + "_Comp" Formula: "self * object(""Sound Control_Voltage"", x)" Why object reference? - Praat's object() function allows referencing other sounds - "Control_Voltage" is the gain envelope - x represents time coordinate - Real-time multiplication applies gain reduction STEP 3: Final processing Scale peak: scale_peak Rename: original_name$ + suffix$ Cleanup: removeObject: intensity, control_mat, control_sig Result: Professional compressed audio Ready for use in productions

Complete Processing Pipeline

PHASE 1: SETUP & ANALYSIS Validate selection (exactly 1 sound) Apply preset parameters or use custom Measure input peak level (Sinc70 interpolation) Calculate detection frequency from time window PHASE 2: ENVELOPE GENERATION Create RMS envelope (Intensity object) Auto-calibrate envelope to match input levels Convert envelope to control matrix PHASE 3: GAIN COMPUTATION Apply compression formula to control matrix Apply makeup gain compensation Convert gain matrix back to audio envelope PHASE 4: SIGNAL PROCESSING Apply gain envelope to audio signal Scale peak to prevent clipping Apply descriptive naming suffix PHASE 5: CLEANUP & OUTPUT Remove temporary objects Optional: Remove original sound Optional: Play result Select final compressed sound OUTPUT: Professional compressed audio All temporary objects cleaned up Consistent naming convention Peak-normalized for safety

Factory Presets

Vocal Leveler (Smooth)

ParameterValueRationale
Threshold-24.0 dBCatches most vocal phrases
Ratio2.5:1Gentle, transparent compression
Time Window0.08 sSmooth, musical response
Makeup Gain+4.0 dBCompensates for level reduction
Suffix_VocalClear identification

🎤 Vocal Compression Characteristics

Best for: Lead vocals, spoken word, vocal ensembles

Sonic character: Smooth, transparent, controlled

Technical notes: Gentle ratio prevents "pumping", slow attack preserves transients, smooth release maintains natural decay

Drum Punch (Fast & Hard)

ParameterValueRationale
Threshold-18.0 dBCatches drum peaks
Ratio6.0:1Aggressive control
Time Window0.02 sFast, punchy response
Makeup Gain+3.0 dBBrings up body and sustain
Suffix_DrumClear identification

🥁 Drum Compression Characteristics

Best for: Drum buses, individual drums, percussion

Sonic character: Punchy, aggressive, controlled

Technical notes: Fast attack controls transients, high ratio adds density, makeup gain emphasizes body and sustain

Mix Bus Glue (Gentle)

ParameterValueRationale
Threshold-12.0 dBOnly catches peaks
Ratio1.5:1Very gentle compression
Time Window0.10 sSlow, transparent response
Makeup Gain+1.0 dBMinimal compensation
Suffix_BusClear identification

🎚️ Mix Bus Compression Characteristics

Best for: Stereo mixes, subgroup buses, mastering

Sonic character: Cohesive, transparent, "glued"

Technical notes: Very gentle ratio for transparency, slow timing for smooth operation, minimal makeup gain preserves dynamics

Hard Limiter (Peak Control)

ParameterValueRationale
Threshold-6.0 dBCatches only extreme peaks
Ratio20.0:1Effectively limiting
Time Window0.005 sVery fast response
Makeup Gain0.0 dBPure peak control
Suffix_LimClear identification

Squash (Heavy Effect)

ParameterValueRationale
Threshold-30.0 dBCompresses most of signal
Ratio10.0:1Heavy compression
Time Window0.05 sMedium response
Makeup Gain+8.0 dBSignificant compensation
Suffix_SquashClear identification

NUKE (Very Aggressive)

ParameterValueRationale
Threshold-40.0 dBCompresses everything
Ratio100.0:1Extreme compression
Time Window0.015 sFast, aggressive response
Makeup Gain+12.0 dBMaximum compensation
Suffix_NUKEClear identification
Preset Selection Guide:
  • Vocal Leveler: Everyday vocal compression
  • Drum Punch: Aggressive drum control
  • Mix Bus Glue: Subtle mix cohesion
  • Hard Limiter: Peak protection only
  • Squash: Creative heavy compression
  • NUKE: Extreme effect processing

Parameters & Settings

Compression Parameters

ParameterRangeDefaultDescription
Threshold_dB-60 to 0-20.0Level where compression begins
Ratio1.0-100.04.0Compression amount above threshold

Time Parameters

ParameterRangeDefaultDescription
Attack_Release_window0.001-1.00.05Combined attack/release time

Output Parameters

ParameterRangeDefaultDescription
Makeup_Gain_dB-20 to +202.0Output level compensation
Scale_peak0.1-1.00.99Final peak normalization
Play_resultboolean1Auto-play after processing
Keep_originalboolean1Preserve source sound

Parameter Guidance

Threshold selection:
  • -40 to -30 dB: Heavy compression (most of signal)
  • -30 to -20 dB: Medium compression
  • -20 to -10 dB: Light compression (only peaks)
  • -10 to 0 dB: Limiting (extreme peaks only)
Ratio selection:
  • 1.5:1 to 2:1: Very gentle, transparent
  • 2:1 to 4:1: Moderate, musical
  • 4:1 to 8:1: Heavy, obvious compression
  • 8:1 to 20:1: Very heavy, limiting territory
  • 20:1+: Hard limiting
Time window selection:
  • 0.005-0.02s: Very fast (drums, percussion)
  • 0.02-0.05s: Fast (vocals, bass)
  • 0.05-0.10s: Medium (general purpose)
  • 0.10-0.20s: Slow (mix bus, mastering)
  • 0.20s+: Very slow (special effects)

Applications

Vocal Processing

Use case: Consistent vocal levels in mixes

Technique: Use Vocal Leveler preset with medium threshold

Benefits: Smooth level control, preserved expression, reduced manual automation

Drum Enhancement

Use case: Adding punch and density to drums

Technique: Use Drum Punch preset on drum buses or individual drums

Results: Controlled transients, enhanced sustain, cohesive drum sound

Mix Bus Processing

Use case: Creating cohesive final mixes

Technique: Use Mix Bus Glue preset on stereo mix

Benefits: Gentle cohesion, controlled peaks, "glued" sound

Creative Effects

Use case: Extreme compression for artistic effect

Technique: Use Squash or NUKE presets on various sources

Results: Pumping, breathing, aggressive textures

Practical Workflow Examples

🎤 Lead Vocal Compression

Goal: Smooth, consistent vocal level without artifacts

Setup:

  • Preset: Vocal Leveler
  • Source: Lead vocal recording
  • Adjustment: Lower threshold if more compression needed
  • Result: Professional vocal sound

Tip: Compare with/without compression to ensure transparency

🥁 Drum Bus Punch

Goal: Aggressive, punchy drum sound

Setup:

  • Preset: Drum Punch
  • Source: Drum bus or individual drum
  • Adjustment: Increase ratio for more aggression
  • Result: Powerful, controlled drums

Tip: Use parallel compression for extreme effects

🎚️ Mix Bus Glue

Goal: Cohesive final mix

Setup:

  • Preset: Mix Bus Glue
  • Source: Stereo mix
  • Adjustment: Very subtle - listen for "glue" not obvious compression
  • Result: Professional, cohesive mix

Tip: A/B compare to ensure transparency

Advanced Techniques

Parallel compression:
  • Method: Process copy with heavy compression, mix with dry signal
  • Benefits: Density without losing transients
  • Presets: Use Squash or NUKE for parallel processing
  • Result: Best of both worlds - dynamics and density
Multi-stage compression:
  • Stage 1: Gentle compression with Vocal Leveler
  • Stage 2: Aggressive compression with Drum Punch
  • Stage 3: Final control with Hard Limiter
  • Result: Complex, professional compression chain

Troubleshooting Common Issues

Problem: Pumping or breathing artifacts
Cause: Too fast release time or too low threshold
Solution: Increase time window, raise threshold, or reduce ratio
Problem: Lost transients
Cause: Too fast attack time or too low threshold
Solution: Increase time window, raise threshold, or use parallel compression
Problem: Noise becomes obvious
Cause: Too much makeup gain with heavy compression
Solution: Reduce makeup gain, use less compression, or address noise at source
Problem: No audible compression
Cause: Threshold too high or ratio too low
Solution: Lower threshold, increase ratio, or check auto-calibration

Algorithmic Extensions

Advanced Detection Methods

Multi-band Compression

Frequency-dependent compression:

MULTI-BAND APPROACH: Split into frequency bands (e.g., low, mid, high) Apply separate compression to each band Recombine bands for final output Benefits: - Compress bass without affecting vocals - Control sibilance without affecting body - More surgical, transparent compression - Prevents "pumping" from low frequencies Implementation: Use Praat's Filtering to create bands Process each band with current compressor Sum bands for final output Challenges: - Phase issues at crossover frequencies - More computationally intensive - More parameters to control

Advanced Time Constants

Separate Attack/Release

Independent time control:

SEPARATE ATTACK/RELEASE: Current: Unified attack_release_window Advanced: Separate attack_time and release_time Implementation options: OPTION 1: Envelope follower with separate times attack_coeff = exp(-1/(attack_time × sample_rate)) release_coeff = exp(-1/(release_time × sample_rate)) Different coefficients for rising vs falling levels OPTION 2: Dual RMS detectors Fast detector for attack Slow detector for release Blend based on level changes OPTION 3: Look-ahead processing Buffer audio to "see" future peaks Smooth attack without affecting transients More computationally intensive Benefits: More precise control over compression character

Advanced Metering

Comprehensive Level Analysis

Professional monitoring:

ADVANCED METERING FEATURES: INPUT/OUTPUT COMPARISON: Display both input and output levels Show gain reduction in real-time Visual feedback for parameter adjustment LOUDNESS METERING: Integrated LUFS (Loudness Units Full Scale) Short-term and integrated loudness True-peak detection Professional broadcast standards HISTOGRAM ANALYSIS: Level distribution over time Identify consistent problems Visual representation of dynamics GAIN REDUCTION HISTORY: Plot gain reduction over time Identify pumping or breathing Optimize time constants Benefits: Professional workflow, accurate settings, standards compliance