Audio Compressor - MATLAB
Real-Time Audio Dynamic Range Compressor
This project implements a digital dynamic range compressor to reduce audio signal dynamic range by attenuating amplitudes above a user-defined threshold. Leveraging MATLAB, Pro Tools, and DSP algorithms, the system features a Butterworth pre-filter, logarithmic dB conversion, gain computation/smoothing, and makeup gain stages. Designed for music production and broadcasting applications, it addresses clipping prevention, volume normalization, and transient preservation while maintaining <1 dBFS output compliance.
Objectives
- Implement threshold-based compression with adjustable ratio (1:1 to 10:1)
- Design attack/release time controls (1ms–500ms) for smooth gain transitions
- Integrate 4th-order Butterworth filter to limit input to human-audible frequencies (20Hz–20kHz)
- Validate dBFS conversion accuracy and prevent output clipping via makeup gain
- Test using synthetic sine waves (520Hz pulsed at 140BPM) and live drum recordings
Project Process
-
Algorithm Design:
- Developed core DSP blocks:
- Butterworth Filter: 4th-order IIR for anti-aliasing
- dB Converter: \( x_{dB}[n] = 20\log_{10}(x[n]) \) with dBFS scaling
- Gain Computer: Threshold/Ratio logic (\( g_c = x_{sc} - x_{dB} \))
- Gain Smoothing: Exponential averaging with αA/αR coefficients
- Derived time constants: \( \alpha = \exp(-\ln(9)/(F_s \cdot T)) \)
- Developed core DSP blocks:
-
Component Testing:
- dB Block: Verified 0.5 → -6 dB conversion (Figure 1)
- Gain Computer: Confirmed -6dB input → -12dB output at 10:1 ratio (Figure 2)
- Gain Smoothing: Validated attack/release response using 520Hz pulsed sine (Figures 3-4)
- Makeup Gain: Identified clipping issue during long attack/release (Figures 5-6)
-
System Integration:
- Processed drum recordings (48kHz) with varying snare dynamics
- Achieved 6dB LUFS loudness increase while preserving transient details
- Reduced peak-to-average ratio by 63% in amplitude tests (Figure 8)
Conclusion and Future Improvements
The compressor successfully normalized audio levels with configurable thresholds and smooth gain adjustments, though makeup gain limitations required constrained attack/release settings. Future enhancements could implement soft-knee compression for gradual ratio transitions, sidechain triggering for multi-track mixing, and adaptive sampling rate modulation for broader compatibility. The modular algorithm structure provides a foundation for embedded DSP deployment in DAWs or hardware audio processors.
Project Information
- Category: Digital Signal Processing / Software
- Client: Rensselaer Polytechnic Institute
- Project Date: December 9, 2023