Fast Envelope Shaper — User Guide
Real-time amplitude modulation: uses efficient RMS envelope extraction to create dynamic effects like gates, expanders, and reverse-envelope swells without complex processing.
What this does
This script implements fast envelope shaping — a real-time amplitude modulation technique that extracts the RMS envelope of a signal and uses it to dynamically control the signal's own amplitude. The system provides two complementary effects: (1) Expander/Gate mode: Amplifies loud sections and attenuates quiet sections, emphasizing transients and creating punch. (2) Reverse envelope mode: Attenuates loud sections and amplifies quiet sections, creating swelling "ghost" effects and bringing out background content. The implementation uses an efficient "square-and-smooth" RMS method that avoids computationally expensive FFT processing while maintaining high quality.
Key Features:
- Dual Processing Modes — Expander/gate and reverse-envelope effects
- RMS Envelope Extraction — Accurate amplitude tracking without FFT
- Performance Optimization — Optional downsampling for speed
- Adjustable Smoothness — Control envelope response time
- Real-time Capable — Efficient processing suitable for live use
- Stereo Compatible — Automatic mono conversion with phase coherence
Technical Implementation: (1) Signal preparation: Convert stereo to mono, optionally downsample for speed. (2) Envelope extraction: Square samples (power calculation), apply lowpass filter (smoothing), take square root (RMS conversion). (3) Mode selection: Apply envelope directly or reverse it based on user choice. (4) Modulation: Multiply original signal by envelope control signal. (5) Output processing: Normalize peak level, cleanup intermediate objects. The system uses Praat's efficient filtering and interpolation to handle sample rate differences automatically, ensuring smooth operation even when downsampling is used for performance.
Quick start
- In Praat, select exactly one Sound object (mono or stereo).
- Run script… →
Fast_Envelope_Shaper.praat. - Choose Reverse_envelope mode (unchecked for expander, checked for reverse).
- Enable Use_downsampling for faster processing (recommended).
- Set Processing_sample_rate (16000 Hz works for most material).
- Adjust Envelope_smoothness_Hz (10-50 Hz typical range).
- Set Scale_peak output level (0.99 prevents clipping).
- Enable Play_after_processing to audition results.
- Click OK — processing completes almost instantly.
- Output appears as "originalname_Expander" or "originalname_RevEnv".
Envelope Shaping Theory
RMS Envelope Fundamentals
Square-and-Smooth Method
Mathematical envelope extraction:
Why RMS Over Peak Detection?
Perceptual advantages:
- Loudness accuracy: RMS correlates better with perceived volume
- Transient handling: Smooth response to sharp attacks
- Musical dynamics: Preserves natural amplitude relationships
- Noise immunity: Less sensitive to isolated peaks
- Consistent results: Predictable across different material
Dual Processing Modes
Expander/Gate Mode
Dynamic range expansion:
Reverse Envelope Mode
Inverse amplitude relationship:
📊 RMS Envelope Intuition
For speech "Hello World":
"H" consonant → high frequency energy → medium envelope
"e" vowel → sustained tone → high envelope
"llo" → lower energy → medium envelope
Silence between words → near-zero envelope
Expander mode: "e" vowel gets louder, silences get quieter
Reverse mode: "e" vowel gets quieter, silences get louder
Smoothness Control System
Envelope Response Time
Lowpass filter characteristics:
Why Adjustable Smoothness?
Application-specific tuning:
- Music: 20-30 Hz for natural dynamics
- Speech: 25-40 Hz for clear articulation
- Drums: 30-50 Hz for punchy transients
- Ambient: 10-20 Hz for gradual evolution
Performance Optimization
Intelligent Downsampling
Speed vs quality tradeoff:
When to Avoid Downsampling
Special cases:
- Very low-frequency content: Below 100 Hz may be affected
- Extreme smoothness: Very low cutoff frequencies
- Academic analysis: Maximum precision required
- Already low SR: Original near processing_sample_rate
Processing Pipeline
🔧 Eight-Stage Envelope Processing
Complete signal path from input to shaped output:
Stage 1: Signal Preparation
| Step | Operation | Purpose |
|---|---|---|
| 1.1 | Check single sound selection | Input validation |
| 1.2 | Extract original properties | SR, channels, duration |
| 1.3 | Stereo to mono conversion | Envelope calculation |
Stage 2: Performance Optimization
| Step | Operation | Purpose |
|---|---|---|
| 2.1 | Check downsampling option | User preference |
| 2.2 | Resample to processing SR | Speed improvement |
| 2.3 | Update working copy | Efficient processing |
Stage 3: RMS Envelope Extraction
| Step | Operation | Purpose |
|---|---|---|
| 3.1 | Square samples (x²) | Instantaneous power |
| 3.2 | Lowpass filter | Smooth power average |
| 3.3 | Square root (√) | RMS amplitude |
Stage 4: Mode Selection
| Step | Operation | Purpose |
|---|---|---|
| 4.1 | Check reverse_envelope | User mode selection |
| 4.2 | Apply reverse if selected | Effect direction |
| 4.3 | Set output suffix | Result identification |
Stage 5: Modulation Application
| Step | Operation | Purpose |
|---|---|---|
| 5.1 | Copy original sound | Preserve source |
| 5.2 | Apply envelope multiplication | Amplitude modulation |
| 5.3 | Automatic interpolation | Handle SR differences |
Stage 6: Output Finalization
| Step | Operation | Purpose |
|---|---|---|
| 6.1 | Peak normalization | Prevent clipping |
| 6.2 | Rename output | Clear identification |
| 6.3 | Optional playback | Result audition |
Stage 7: Resource Cleanup
| Step | Operation | Purpose |
|---|---|---|
| 7.1 | Remove envelope object | Memory management |
| 7.2 | Remove working copies | Clean object list |
| 7.3 | Select final output | User convenience |
Complete Signal Flow
Parameters Guide
⚙️ Complete Parameter Reference
Detailed explanation of all user-controllable parameters:
Direction Parameters
| Parameter | Default | Options | Description |
|---|---|---|---|
| Reverse_envelope | 0 | 0/1 | Expander mode (0) or Reverse mode (1) |
Performance Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Use_downsampling | 1 | 0/1 | Enable processing speed optimization |
| Processing_sample_rate | 16000 | 8000-44100 | Target SR for envelope calculation |
Envelope Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Envelope_smoothness_Hz | 25 | 5-100 | Envelope response speed in Hz |
Output Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Scale_peak | 0.99 | 0.1-1.0 | Output peak normalization level |
| Play_after_processing | 1 | 0/1 | Auto-play result after processing |
Parameter Interactions
- Reverse_envelope defines effect character: Expander vs Reverse
- Smoothness affects temporal response: Lower = more gradual
- Downsampling improves speed: Enabled for most applications
- Processing SR balances speed/quality: 16000 Hz optimal
Simple parameter set enables wide range of effects
Recommended Settings
🥁 Drum Expander
Goal: Add punch and impact to drums
Settings:
- Reverse_envelope: 0 (Expander)
- Use_downsampling: 1
- Processing_sample_rate: 16000
- Envelope_smoothness_Hz: 40
🌊 Ambient Swell
Goal: Create breathing, evolving textures
Settings:
- Reverse_envelope: 1 (Reverse)
- Use_downsampling: 1
- Processing_sample_rate: 16000
- Envelope_smoothness_Hz: 15
🎙️ Speech Clarifier
Goal: Improve speech intelligibility
Settings:
- Reverse_envelope: 0 (Expander)
- Use_downsampling: 1
- Processing_sample_rate: 16000
- Envelope_smoothness_Hz: 30
Applications
Music Production
Use case: Enhance dynamics and transients
Technique: Expander mode on drums and percussion
Example: Add punch to drum loops without compression artifacts
Sound Design
Use case: Create evolving textures and effects
Technique: Reverse mode on pads and ambient material
Example: Transform static pads into breathing, swelling textures
Audio Restoration
Use case: Improve intelligibility of recorded material
Technique: Expander mode on speech and dialogue
Example: Enhance consonant clarity in podcast recordings
Live Processing
Use case: Real-time dynamic effects
Technique: Fast processing enables live use
Example: Live vocal processing for performance enhancement
💡 Creative Techniques
Advanced applications:
- Serial processing: Apply both modes sequentially
- Frequency splitting: Process different bands separately
- Sidechain effects: Use one sound's envelope on another
- Automation: Vary parameters over time for evolving effects
Troubleshooting Common Issues
Cause: Smoothness too high for material
Solution: Reduce envelope_smoothness_Hz
Cause: Reverse mode with noisy source
Solution: Use expander mode or pre-clean source
Cause: Smoothness too low
Solution: Increase envelope_smoothness_Hz
Cause: Mono envelope on complex stereo
Solution: Process channels separately if needed