Hilbert Transform (Time-Reversed Envelope) — User Guide
Extract amplitude envelope using Hilbert transform, reverse it in time, and apply it backwards to create retrograde envelope effects with preserved pitch.
What this does
This script performs time-reversed envelope processing using the Hilbert transform — a sophisticated signal processing technique that extracts the amplitude envelope of a sound (how loud it is over time) and applies it backwards. The result: sounds that seem to "grow" into their attacks rather than decay from them. Imagine drums that swell into the hit, voices that inhale into words, or music that builds backwards into each note. The pitch and harmonic content remain unchanged — only the amplitude contour is reversed. This creates dreamlike, reversed-yet-forward, impossibly organic temporal effects.
Key Features:
- Hilbert Transform — Mathematically precise envelope extraction via analytic signal
- Time Reversal — Envelope reversed in time, not the audio itself
- Pitch Preservation — Frequencies unchanged, only amplitude affected
- Envelope Shaping — Optional sharpening/smoothing with exponent control
- High-Pass Filtering — Reduces low-frequency envelope dominance
- Computationally Intensive — Long processing time on extended files
Technical Implementation: (1) Convert Sound to Spectrum using FFT or DFT, (2) Create Hilbert transform via 90-degree phase shift: swap real/imaginary components and negate, (3) Convert Hilbert spectrum back to time domain → hilbert_sound, (4) Calculate envelope: sqrt(original² + hilbert²) — this is the analytic signal magnitude, (5) Scale and optionally sharpen envelope with exponent, (6) High-pass filter envelope to reduce low-frequency buildup, (7) Reverse original sound in time, (8) Multiply reversed sound by forward-time envelope (applies envelope backwards), (9) Reverse result back to forward time → sound with time-reversed envelope, (10) Peak normalize. Key insight: Because we reverse the sound, apply the envelope, then reverse again, the final result has pitch/timbre moving forward but amplitude envelope moving backward.
Quick start
- In Praat, select exactly one Sound object.
- Run script… →
Hilbert Transform.praat. - Leave defaults (fast_fourier: no, sharpening off, highpass 50Hz) for standard envelope reversal.
- Click OK — script extracts envelope, reverses it, applies backwards, plays result.
- Experiment with envelope sharpening (exponent 0.5-0.8) for more dramatic swells.
Hilbert Transform Theory
🌊 Analytic Signal Fundamentals
Real signal: Standard audio — real numbers representing amplitude
Analytic signal: Complex representation — amplitude (magnitude) + phase (angle)
Hilbert transform: Creates imaginary component that pairs with real signal
Key insight: Magnitude of analytic signal = instantaneous envelope, independent of phase/frequency
The Hilbert Transform Operation
Mathematical Foundation
Standard audio signal:
Hilbert transform creates:
Analytic signal combines both:
Envelope extraction:
Why Hilbert Transform?
Traditional envelope methods (crude):
- Peak detection: Only captures maxima, misses subtle variations
- RMS (Root Mean Square): Averages over windows, loses temporal precision
- Absolute value: Doubles frequency, creates artifacts
- Low-pass filtering rectified signal: Phase distortion, imprecise
Hilbert transform advantages:
- Mathematically exact: True instantaneous envelope, no approximation
- Smooth: Continuous envelope, no jagged edges
- Phase-independent: Extracts amplitude regardless of waveform phase
- Frequency-agnostic: Works equally well on bass, mids, treble
- Preserves transients: Captures fast amplitude changes accurately
Frequency-Domain Implementation
The Hilbert transform is most efficiently computed in frequency domain:
Step 1: FFT — Convert time-domain sound to frequency-domain spectrum
Step 2: 90-degree phase shift — Swap and negate components
Step 3: Inverse FFT — Convert Hilbert spectrum back to time domain
Step 4: Envelope calculation — Compute magnitude of analytic signal
Time Reversal Process
Once envelope extracted, script applies it backwards:
Visual Representation
Original sound with natural envelope:
Extracted envelope (via Hilbert):
Reversed envelope:
Applied to original sound (not reversed):
Envelope Sharpening
The script offers optional envelope shaping via exponentiation:
Formula: envelope_shaped = envelope^exponent
| Exponent | Effect | Use Case |
|---|---|---|
| 1.0 | No change (original envelope) | Natural envelope contour |
| 0.8 | Slight sharpening (default when enabled) | Moderate enhancement of swells |
| 0.5 | Strong sharpening (square root) | Dramatic swells, gates-like effect |
| 0.3 | Extreme sharpening | Harsh gating, abrupt transitions |
| 2.0 | Smoothing (squaring) | Gentler swells, reduced dynamics |
| 3.0 | Heavy smoothing (cubing) | Very gradual swells, compressed feel |
Mathematical Effect
Sharpening (exponent < 1):
- Values near 0 become even smaller → deeper valleys
- Values near 1 barely affected → peaks remain prominent
- Result: Increased contrast between loud and soft
- Creates gate-like, "all or nothing" amplitude contour
Smoothing (exponent > 1):
- Values near 0 become smaller → softens attacks
- Values near 1 barely affected → peaks remain
- Result: Decreased contrast, compressed dynamics
- Creates gentle, flowing amplitude changes
Example with exponent 0.5 (square root):
High-Pass Filtering
The envelope is high-pass filtered to reduce low-frequency dominance:
Why necessary:
- Hilbert-derived envelopes often have DC offset and low-frequency drift
- Bass-heavy material creates envelope with strong sub-bass component
- Applying unfiltered envelope can make result muddy, boomy
- Low-frequency envelope modulation creates unnatural rumble
High-pass filter (default 50 Hz):
- Removes sub-bass and DC from envelope itself
- Envelope still affects all frequencies of original sound
- Prevents low-frequency envelope components from dominating
- Creates cleaner, more natural-sounding reversed envelope
Smoothing parameter (default 10 Hz):
- Controls filter rolloff steepness
- Lower smoothing = sharper cutoff (more aggressive filtering)
- Higher smoothing = gentler rolloff (more transparent)
Adjusting Filter Parameters
| Material | Cutoff (Hz) | Smoothing (Hz) | Reason |
|---|---|---|---|
| Bass-heavy (EDM, hip-hop) | 80-100 | 15-20 | More aggressive filtering to prevent boom |
| Balanced mix | 50 | 10 | Default — works for most material |
| Sparse, acoustic | 30-40 | 5-10 | Gentler filtering preserves envelope subtlety |
| High-frequency (cymbals) | 50-70 | 10 | Standard filtering adequate |
Processing Steps Breakdown
Complete signal flow:
- Original Sound — Input audio
- → Spectrum — FFT to frequency domain
- → Hilbert Spectrum — 90-degree phase shift
- → Hilbert Sound — Inverse FFT to time domain
- → Envelope — sqrt(original² + hilbert²)
- → Scaled Envelope — Peak normalization
- → Shaped Envelope — Optional exponentiation
- → Filtered Envelope — High-pass filter
- → Reversed Original — Time-reverse input sound
- → Reversed with Envelope — Multiply reversed sound by forward envelope
- → Final Sound — Reverse back to forward time
- → Normalized Output — Final peak scaling
Parameters
Core Settings
| Parameter | Type | Default | Description |
|---|---|---|---|
| fast_fourier | boolean | no | Use FFT (fast) vs DFT (precise but slow) |
| apply_envelope_sharpening | boolean | no | Enable envelope shaping via exponentiation |
| sharpening_exponent | positive | 0.8 | Exponent for envelope shaping (<1 sharper, >1 smoother) |
| highpass_cutoff | positive | 50 | High-pass filter cutoff frequency (Hz) |
| highpass_smoothing | positive | 10 | Filter smoothing/rolloff (Hz) |
| scale_peak | positive | 0.99 | Peak normalization level |
| play_after_processing | boolean | yes | Auto-play result when complete |
| show_info_report | boolean | yes | Display processing info in info window |
| keep_intermediate_objects | boolean | no | Keep intermediate objects for inspection |
Parameter Details
fast_fourier
Options: no (DFT, default) or yes (FFT)
Why default is "no" (DFT):
- Hilbert transform requires precise phase relationships
- DFT provides mathematically exact results
- FFT approximations can introduce subtle envelope artifacts
- For envelope extraction, precision more important than speed
When to use FFT (yes):
- Very long files (>2 minutes) where DFT prohibitively slow
- When speed critical and minor artifacts acceptable
- Batch processing many files
Performance comparison @ 1 minute 44.1kHz:
- DFT: ~45-60 seconds processing time
- FFT: ~15-20 seconds processing time
- Quality difference: subtle (most users won't notice)
apply_envelope_sharpening
Options: no (off, default) or yes (enabled)
Disable (no): Natural envelope contour preserved
Enable (yes): Envelope shaped by exponentiation
When to enable:
- Want more dramatic, sudden swells
- Original envelope too gradual
- Creating gated or rhythmic effects
- Enhancing percussive envelope definition
When to disable:
- Want natural, subtle envelope reversal
- Working with classical or acoustic material
- Envelope already has good definition
sharpening_exponent
Range: 0.1-10.0 (practical: 0.3-3.0)
Default: 0.8 (moderate sharpening)
Common values:
- 0.3-0.5: Extreme sharpening — gate-like, harsh transitions
- 0.6-0.8: Moderate sharpening — enhanced dynamics, clear swells
- 0.9-1.1: Minimal effect — nearly original envelope
- 1.5-2.0: Smoothing — compressed, gentle swells
- 2.5-3.0: Heavy smoothing — very gradual changes
Effect inactive if apply_envelope_sharpening disabled.
highpass_cutoff
Range: 10-200 Hz (practical: 30-100 Hz)
Default: 50 Hz
Purpose: Remove low-frequency components from envelope itself
Adjust lower (30-40 Hz):
- Preserve more envelope low-frequency content
- Gentler filtering, more transparent
- Risk: possible muddiness or boom
Adjust higher (70-100 Hz):
- More aggressive low-frequency removal
- Cleaner, tighter envelope application
- Risk: might lose subtle envelope qualities
highpass_smoothing
Range: 1-50 Hz (practical: 5-20 Hz)
Default: 10 Hz
Lower values (5 Hz): Sharp filter cutoff, more aggressive
Higher values (20 Hz): Gentle rolloff, more transparent
Recommendation: Keep default 10 Hz unless specific need
scale_peak
Range: 0.1-1.0 (practical: 0.9-0.99)
Default: 0.99
Purpose: Final output normalization
0.99: Maximum loudness with tiny headroom
0.95: Moderate safety margin
0.9: Conservative, guaranteed no clipping
play_after_processing
Options: yes (default) or no
Enable: Immediate audition after long processing wait
Disable: No playback — useful for batch work
show_info_report
Options: yes (default) or no
Enable: Display processing summary in Praat info window
Disable: Silent processing
Info report contains: Original filename, output name, duration, confirmation of processing complete
keep_intermediate_objects
Options: