Autocorrelation-Based Self-Filtering — User Guide
Time-varying convolution using signal's own autocorrelation structure: extracts local periodicity patterns as impulse responses, creates adaptive filtering where sound filters itself based on its own spectral-temporal characteristics, producing resonant, metallic, and morphing timbres.
What this does
This script implements autocorrelation-based self-filtering — a time-varying convolution effect where the audio signal filters itself using its own autocorrelation structure. Core concept: (1) Windowed analysis: Audio divided into overlapping time windows (default 0.2s). (2) Autocorrelation extraction: Each window's autocorrelation function computed (reveals local periodicity/pitch structure). (3) IR generation: Central region of autocorrelation (±max_lag) extracted and normalized as impulse response (IR). (4) Convolution: Original window convolved with its own autocorrelation IR. (5) Reconstruction: Processed windows crossfaded and concatenated. Result: Sound that resonates with its own harmonic/inharmonic structure — periodic signals enhance pitch/timbre, noisy signals create metallic coloration, changing pitches produce morphing resonances. Unlike fixed filters (EQ, static resonators), this adapts to local signal characteristics. Time-varying nature tracks evolving pitch/spectral content.
Key Features:
- Self-Referential Processing — Signal filters itself using its own structure
- Time-Varying Adaptation — Filter follows changing pitch/spectral content
- 3 Effect Character Presets — Tight/Metallic, Medium/Resonant, Loose/Ambient
- Sliding Window Processing — Overlapping windows with crossfade for continuity
- Autocorrelation IR — Local periodicity becomes convolution kernel
- Adaptive Resonance — Harmonic content enhanced, noise transformed
Technical Implementation: (1) Window extraction: Divide audio into overlapping windows (duration = window_duration, overlap = window_duration - window_step). (2) Per-window processing: (a) Compute autocorrelation: R(τ) = ∫ x(t) · x(t+τ) dt (reveals signal's correlation with time-shifted version of itself). (b) Autocorrelation is symmetric: center peak at τ=0, mirrored structure ±τ. (c) Extract IR region: ±max_lag seconds around center peak. (d) Normalize IR: divide by maximum to prevent amplitude explosion. (e) Window IR: apply Hann window (cosine taper) to smooth edges. (f) Convolve: window ⊗ IR (linear convolution, sum normalization). (g) Normalize convolution result: scale to 0.5 peak to prevent clipping. (h) Extract center: trim convolution output to original window length. (i) Apply crossfade: fade in/out at edges (linear fade, duration = crossfade_duration). (3) Concatenation: Combine all processed windows sequentially. (4) Final normalization: Scale output to 0.9 peak. Key insight: Autocorrelation captures signal's self-similarity over time. When used as IR, it reinforces periodicities (pitch enhancement) and colors noise (metallic character). Time-varying approach allows tracking pitch changes, creating morphing timbres. Short max_lag captures tight periodicities (high frequencies, metallic), long max_lag captures slower modulations (low frequencies, ambient).
Quick start
- In Praat, select exactly one Sound object (mono recommended, stereo converted to mono).
- Run script… →
Autocorrelation-Based_Self-Filtering.praat. - Choose Effect character: Tight/Metallic (lag=0.01s), Medium/Resonant (lag=0.02s), Loose/Ambient (lag=0.05s), or Custom.
- For Custom: Set Max_lag_(seconds) (IR extraction range, typical: 0.01-0.1s).
- Adjust Window_duration_(seconds) (analysis window size, default: 0.2s).
- Set Window_step_(seconds) (overlap control, default: 0.1s, must be < window_duration).
- Set Crossfade_duration_(seconds) (smoothing at window edges, default: 0.01s).
- Click OK — processing begins, output named "adaptive_originalname".
Autocorrelation Theory
Autocorrelation Function Fundamentals
Mathematical Definition
Continuous-time autocorrelation:
Periodicity Detection
Autocorrelation reveals pitch/periodicity:
Impulse Response Extraction
IR Windowing Process
From autocorrelation to usable IR:
Convolution Mechanics
Linear Convolution Implementation
How window ⊗ IR works:
Normalization Strategy
Multi-stage normalization prevents clipping:
Time-Varying Processing
Sliding Window Analysis
Overlapping windows for time adaptation:
Crossfading Algorithm
Smooth transitions between windows:
Effect Character Modes
Tight/Metallic (lag=0.01s)
Character: Sharp, robotic, high-frequency emphasis
Max_lag setting: 0.01s (10ms)
IR characteristics:
- Short IR length: 441 samples at 44.1kHz (20ms total = ±10ms)
- Captures fast periodicities: 50-100Hz fundamental, harmonics up to several kHz
- Tight resonance: Narrow in time domain = broad in frequency domain
Acoustic effect:
- Pitched material: Metallic, thin timbre. Emphasizes inharmonic partials. "Ring modulator" quality.
- Voice: Robotic, telephone-like. Loses warmth. "Vocoder without formants" character.
- Noise: Grainy, granular texture. High-frequency sizzle. "Digital artifact" aesthetic.
- Percussion: Sharpens transients. Adds "ping" or "ting" to hits. Metallic shimmer.
Use cases: Robotic voice effects, industrial sound design, metallic percussion, harsh electronic textures, glitch aesthetics
Technical note: Short max_lag means IR barely captures fundamental period of low notes. For 100Hz (period=10ms), IR is exactly one period — creates strong resonance. Below 100Hz, IR is shorter than period — creates inharmonic artifacts.
Medium/Resonant (lag=0.02s)
Character: Balanced, resonant, pitch-tracking
Max_lag setting: 0.02s (20ms, default)
IR characteristics:
- Medium IR length: 882 samples at 44.1kHz (40ms total = ±20ms)
- Captures moderate periodicities: 25-50Hz fundamental, good harmonic capture
- Balanced resonance: Moderate time-frequency trade-off
Acoustic effect:
- Pitched material: Enhanced harmonics. Resonant, "singing" quality. Pitch more prominent.
- Voice: Chorused, doubled character. Adds body without extreme robotization. Formant-like resonances.
- Noise: Moderate coloration. Less harsh than Tight mode. "Filtered noise" quality.
- Percussion: Adds resonant tail. Transforms transients into short notes. "Tuned percussion" effect.
Use cases: General sound design, voice enhancement, pitch reinforcement, resonant pads, textural layers, experimental mixing
Technical note: Max_lag of 20ms captures full period up to 50Hz. Suitable for bass/baritone voices (E2=82Hz has 12ms period, fully captured). Most musical material has strong periodicity at this scale — creates natural-sounding resonance.
Loose/Ambient (lag=0.05s)
Character: Spacious, ambient, reverb-like
Max_lag setting: 0.05s (50ms)
IR characteristics:
- Long IR length: 2205 samples at 44.1kHz (100ms total = ±50ms)
- Captures slow modulations: 10-20Hz fundamental, captures low-frequency energy
- Loose resonance: Long in time domain = narrow in frequency domain
Acoustic effect:
- Pitched material: Ambient shimmer. Long resonant tail. "Self-reverberating" quality. Blurred pitch.
- Voice: Ethereal, diffuse. Cathedral-like resonance. Loses intelligibility but gains atmosphere.
- Noise: Smooth, ambient wash. Low coloration. "Natural reverb" on noise.
- Percussion: Long, evolving tail. Transforms hits into sustained drones. Gong-like resonance.
Use cases: Ambient music, sound art, experimental drones, textural soundscapes, "impossible acoustics", cinematic sound design
Technical note: Max_lag of 50ms captures periodicities down to 20Hz (sub-bass). IR approaches short room impulse response in length. Effect similar to convolution reverb, but IR derived from signal itself rather than acoustic space — creates "self-referential ambience".
Custom Mode
Parameters & Settings
Core Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Window_duration_(seconds) | Positive | 0.2 | Duration of each analysis window. Range: 0.05-0.5s typical. Shorter = faster adaptation to pitch changes. Longer = smoother averaging. Must be > max_lag. |
| Window_step_(seconds) | Positive | 0.1 | Time between window start positions (hop size). Range: 0.05-0.2s. Must be < window_duration. Smaller = more overlap, smoother transitions. Overlap = window_duration - window_step. |
| Max_lag_(seconds) | Positive | 0.02 | Maximum lag for autocorrelation IR extraction (±max_lag around center). Range: 0.005-0.1s. Controls effect character: small=metallic, large=ambient. IR length = 2×max_lag. |
| Effect_character | Menu | Tight/Metallic | Preset selection: (1) Tight/Metallic (lag=0.01s), (2) Medium/Resonant (lag=0.02s), (3) Loose/Ambient (lag=0.05s), (4) Custom (use Max_lag value). Overrides Max_lag unless Custom selected. |
| Crossfade_duration_(seconds) | Positive | 0.01 | Duration of linear fade in/out at window edges. Range: 0.005-0.05s. Longer = smoother transitions but less temporal precision. Must be < window_step/2 to avoid conflicts. |
| Play_result | Boolean | 1 (true) | Auto-play output after processing. 1 = play immediately. 0 = silent (must play manually). Convenience for immediate audition. |
| Keep_original | Boolean | 1 (true) | Keep original sound in Objects window. 1 = keep both original and output. 0 = remove original (save memory). Output always created regardless of setting. |
Parameter Interaction Guide
Time Resolution vs Smoothness:
- Fast pitch tracking: Short window_duration (0.1s) + small window_step (0.05s) = high temporal resolution
- Smooth transitions: Long window_duration (0.3s) + small window_step (0.08s) = high overlap, blurred changes
- Computational efficiency: Large window_step (0.15s) = fewer windows, faster processing, potential artifacts
Effect Character Control:
- Metallic/robotic: Small max_lag (0.005-0.015s) captures high periodicities only
- Resonant/harmonic: Medium max_lag (0.015-0.03s) captures fundamental + harmonics
- Ambient/reverberant: Large max_lag (0.04-0.1s) captures long-term modulations
Smoothness Control:
- Minimal artifacts: crossfade_duration ≥ 0.01s (smooth edges)
- Temporal precision: crossfade_duration ≤ 0.005s (sharp edges, potential clicks)
- Overlap requirement: crossfade_duration < window_step/2 (avoid fade conflicts)
Advanced Parameter Tuning
Calculating Number of Windows
Formula:
IR Length and Frequency Range
Frequency implications of max_lag:
Applications & Use Cases
Voice Transformation
Robotic Voice Effect
Recommended settings: Tight/Metallic preset (max_lag=0.01s)
- window_duration = 0.15s (fast response to phonemes)
- window_step = 0.08s (moderate overlap for smoothness)
- crossfade_duration = 0.01s (balance smoothness/clarity)
Character: Metallic, robotic timbre. Similar to vocoder but without external carrier. Voice loses formants but retains pitch contour. Intelligibility moderate (better than ring modulation). Creates "telephone AI" or "synthetic voice" character. Good for: Sci-fi dialogue, robotic characters, electronic music vocals, experimental voice processing.
Chorused/Doubled Voice
Recommended settings: Medium/Resonant preset (max_lag=0.02s)
- window_duration = 0.2s (smooth averaging)
- window_step = 0.1s (50% overlap, balanced)
- crossfade_duration = 0.015s (smooth transitions)
Character: Thickened, resonant voice. Adds harmonic reinforcement without extreme robotization. Creates "layered" or "doubled" effect. Formants partially preserved. Good for: Ambient vocals, choir-like textures, thick lead vocals, experimental pop production.
Ethereal/Ambient Voice
Recommended settings: Loose/Ambient preset (max_lag=0.05s)
- window_duration = 0.3s (long averaging, smooth)
- window_step = 0.12s (40% overlap)
- crossfade_duration = 0.02s (very smooth)
Character: Diffuse, atmospheric voice. Long resonant tail. Loses intelligibility but creates "ghostly" or "cathedral" presence. Pitch blurred but present. Good for: Sound art, ambient soundscapes, cinematic atmospheres, textural background vocals.
Musical Instrument Processing
Bass/Low-Frequency Enhancement
Settings: Medium/Resonant or Loose/Ambient
- max_lag = 0.03s minimum (captures 33Hz fundamental)
- window_duration = 0.25s (smooth bass evolution)
- window_step = 0.12s (overlapping for continuity)
Effect: Bass notes acquire resonant sustain. Low frequencies reinforced. Transforms plucked bass into sustained drone. Creates "infinite sustain" effect similar to EBow. Good for: Ambient bass, drone music, sustained low-end textures, bass guitar transformation.
Percussion Transformation
Settings: Tight/Metallic for metallic hits, Medium/Resonant for tuned percussion
- window_duration = 0.1s (fast transient response)
- window_step = 0.05s (high temporal resolution)
- max_lag = 0.01s (metallic) or 0.02s (tuned)
Effect: Transients acquire pitched tail. Kick drums become tonal. Snares acquire resonance. Cymbals become metallic shimmers. Transforms rhythm into pitched material. Good for: Glitch percussion, tuned drum sounds, metallic percussion, experimental rhythm tracks.
Sustained Note Processing
Settings: Any preset depending on desired character
- window_duration = 0.3s (long averaging for stability)
- window_step = 0.15s (50% overlap)
- Adjust max_lag based on pitch range and desired resonance
Effect: Strings/pads acquire self-resonating quality. Harmonics emphasized. Timbre evolves continuously. Creates "morphing" or "breathing" character. Good for: Ambient pads, evolving textures, sound design layers, experimental orchestration.
Sound Design Applications
Noise Coloration
Material: White noise, pink noise, recorded ambience
Settings: Custom, experiment with different max_lag values
Effect: Broadband noise acquires structure. White noise becomes colored noise (spectral shaping). Creates unique timbres impossible with traditional filters. Good for: Textured noise beds, colored ambiences, cinematic wind/rain effects, abstract sound design.
Transient Morphing
Material: Impacts, hits, explosions, foley
Settings: Tight/Metallic (max_lag=0.01s), short windows (0.1s), small step (0.05s)
Effect: Transients become pitched/tonal. Impacts acquire metallic ring. Explosions become resonant booms. Good for: Sci-fi sound effects, otherworldly impacts, experimental foley, sound transformation for film/games.
Self-Generating Textures
Material: Short sound snippet (0.5-2s)
Settings: Loose/Ambient (max_lag=0.05s), long windows (0.3s), high overlap
Effect: Short sound extended into long texture. Acquires self-referential resonance. Creates evolving ambience from minimal source. Good for: Generative ambient music, drone creation, texture design from limited material.
Experimental & Pedagogical Uses
Teaching Autocorrelation Concepts
Exercise: Process pure sine wave (e.g., 440Hz) with different max_lag settings
Observation: (1) max_lag matching period (1/440 ≈ 2.27ms) → strong resonance. (2) max_lag = half-period → weaker resonance. (3) max_lag >> period → capturing multiple periods, rich harmonics. Demonstrates relationship between time-domain periodicity and frequency-domain resonance.
Pitch-Following Filter Demonstration
Exercise: Process gliding pitch (e.g., voice glissando, theremin, slide guitar)
Observation: Filter characteristics track pitch changes. Resonance follows fundamental frequency. Demonstrates adaptive filtering concept. Shows difference from fixed filter (EQ) where resonance stays constant as pitch changes.
Signal Structure Visualization
Exercise: Compare effect on: (1) Periodic signal (tuning fork), (2) Complex harmonic signal (voice), (3) Inharmonic signal (bell), (4) Noise signal (white noise)
Observation: Effect varies dramatically with signal structure. Periodic → strong resonance. Harmonic → selective reinforcement. Inharmonic → metallic coloration. Noise → filtering/coloration. Demonstrates autocorrelation's dependence on signal characteristics.
Comparison to Other Effects
| Effect Type | Characteristics | vs Autocorrelation Self-Filtering |
|---|---|---|
| Vocoder | External carrier modulated by speech. Preserves formants. Intelligible. | Autocorrelation: No external carrier. Loses formants. Creates self-referential character. Less intelligible but more "organic robotization". |
| Ring Modulator | Multiplication with sine carrier. Creates sum/difference frequencies. Metallic/bell-like. | Autocorrelation: Convolution, not multiplication. Reinforces existing structure rather than adding new frequencies. More resonant, less clangorous. |
| Resonator/Formant Filter | Fixed or designed frequency response. Bandpass/resonant peaks at specified frequencies. | Autocorrelation: Adaptive frequency response follows signal. No fixed peaks. Resonances track pitch/spectrum changes. |
| Convolution Reverb | External IR (room, hardware). Adds acoustic space. Static IR. | Autocorrelation: Self-derived IR. No acoustic space emulation. Time-varying IR. Creates "impossible" resonances. |
| Pitch Shifter | Changes pitch while preserving timbre (or vice versa). Granular or FFT-based. | Autocorrelation: Pitch unchanged but reinforced. Timbre fundamentally altered. No explicit pitch analysis. |
Troubleshooting Common Issues
Cause: Signal has no autocorrelation structure (pure noise, silence)
Solution: Ensure input has periodic content. Try with test tone (sine wave) to verify processing works.
Cause: Window_step too large, insufficient overlap, crossfade too short
Solution: Decrease window_step (increase overlap), increase crossfade_duration (0.015-0.02s)
Cause: Max_lag doesn't match signal's periodicity, or signal mostly aperiodic
Solution: Adjust max_lag to match pitch range. For voice, try 0.015-0.025s. For low bass, try 0.03-0.05s.
Cause: Max_lag too short (<0.005s), captures high frequencies only, potential aliasing
Solution: Increase max_lag to ≥0.01s. Check for clipping (peaks >1.0). Reduce input level if needed.
Cause: Small window_step, long audio duration, many windows to process
Solution: Increase window_step (0.12-0.15s), process shorter segments, or accept longer processing time
Cause: Insufficient crossfade, window boundaries audible
Solution: Increase crossfade_duration (0.015-0.03s), ensure window_step > 2×crossfade_duration
Mathematical Deep Dive
Autocorrelation Computation Details
Discrete-Time Implementation
Praat's autocorrelation algorithm:
Properties of Autocorrelation
Mathematical properties exploited by algorithm:
Convolution Mathematics
Discrete Linear Convolution
Convolution operation details:
Why Autocorrelation IR Works
Conceptual explanation:
Windowing and Overlap-Add
Windowing Theory
Why window and crossfade?
Optimal Overlap Calculation
Choosing window_step for best results: