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.

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

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:

What is autocorrelation-based filtering? Traditional filtering: Fixed frequency response (EQ, resonators, formant filters), external impulse responses (convolution reverb), designed transfer functions (Butterworth, Chebyshev). Autocorrelation filtering: Signal's autocorrelation function used as time-varying impulse response. Key differences: (1) Self-referential: No external filter design — signal determines its own filtering. (2) Adaptive: Filter characteristics change with signal content. (3) Pitch-sensitive: Periodic signals (pitched notes) create resonances at fundamental + harmonics. (4) Noise-colorizing: Broadband signals acquire metallic/robotic timbre. (5) Morphing: Changing pitch/timbre creates continuously evolving filter response. Use cases: Experimental sound design (self-modulating timbres), voice transformation (robotic/metallic effects), generative music (adaptive processing), teaching signal processing (autocorrelation visualization), creating "impossible" resonances (signal resonates with itself). Effect character controlled by max_lag parameter: short lag = tight/metallic, long lag = ambient/reverberant.

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

  1. In Praat, select exactly one Sound object (mono recommended, stereo converted to mono).
  2. Run script…Autocorrelation-Based_Self-Filtering.praat.
  3. Choose Effect character: Tight/Metallic (lag=0.01s), Medium/Resonant (lag=0.02s), Loose/Ambient (lag=0.05s), or Custom.
  4. For Custom: Set Max_lag_(seconds) (IR extraction range, typical: 0.01-0.1s).
  5. Adjust Window_duration_(seconds) (analysis window size, default: 0.2s).
  6. Set Window_step_(seconds) (overlap control, default: 0.1s, must be < window_duration).
  7. Set Crossfade_duration_(seconds) (smoothing at window edges, default: 0.01s).
  8. Click OK — processing begins, output named "adaptive_originalname".
Quick tip: Start with Medium/Resonant preset (balanced effect). For robotic/metallic voice: use Tight/Metallic (lag=0.01s). For ambient shimmer: use Loose/Ambient (lag=0.05s). Window_step controls smoothness: smaller step (0.05s) = smoother but slower processing, larger step (0.15s) = faster but potential artifacts. Window_duration affects time resolution: 0.1s = fast changes tracked, 0.3s = smoother averaging. Processing time scales with audio duration and number of windows (calculated as: floor((duration - window_duration) / window_step) + 1). Script prints progress every 5 windows. Enable Play_result to auto-audition. Disable Keep_original to save memory (removes original from Objects window).
Important: MONO PROCESSING ONLY — stereo sounds automatically converted to mono (script uses channel 1). For stereo, process each channel separately then recombine. DESTRUCTIVE EFFECT0.2s) approaches reverb-like behavior but with self-referential character. Processing time significant for long audio: 60s audio with window_step=0.1s ≈ 600 windows ≈ 30-60 seconds processing. Output duration matches input (no tail extension). Effect is NON-LINEAR — does not preserve amplitude relationships (normalization applied multiple times).

Autocorrelation Theory

Autocorrelation Function Fundamentals

Mathematical Definition

Continuous-time autocorrelation:

Autocorrelation function: R(τ) R(τ) = ∫ x(t) · x(t + τ) dt Where: x(t) = signal as function of time τ (tau) = time lag (shift amount) R(τ) = autocorrelation value at lag τ Interpretation: R(τ) measures how much signal resembles itself shifted by τ seconds High R(τ) → strong similarity at lag τ (periodicity) Low R(τ) → weak similarity at lag τ (no periodicity) Properties: 1. Symmetric: R(τ) = R(-τ) (correlation same forwards/backwards) 2. Maximum at τ=0: R(0) = signal energy (perfect self-correlation) 3. For periodic signals: peaks at τ = period, 2×period, 3×period, ... 4. For random noise: R(τ) ≈ 0 for τ ≠ 0 (no correlation) Discrete-time implementation (Praat): R[k] = Σ x[n] · x[n + k] Where k = lag in samples, n = sample index

Periodicity Detection

Autocorrelation reveals pitch/periodicity:

EXAMPLE 1: Pure tone (440 Hz sine wave) Period = 1/440 ≈ 0.00227s (2.27ms) Autocorrelation structure: R(0) = maximum (signal identical to itself at zero lag) R(0.00227s) = maximum (signal repeats at one period) R(0.00454s) = maximum (two periods) R(0.00681s) = maximum (three periods) ...peaks every 2.27ms Between peaks: R(τ) oscillates (correlation varies with phase) EXAMPLE 2: Complex tone (fundamental + harmonics) Fundamental: 200 Hz (period = 5ms) Harmonics: 400 Hz, 600 Hz, 800 Hz... Autocorrelation structure: Dominant peak at 5ms (fundamental period) Smaller peaks at 2.5ms, 1.67ms... (harmonic periods) Overall structure: strong 5ms periodicity Effect: Convolution with this IR reinforces 200 Hz + harmonics EXAMPLE 3: White noise No periodicity (random values) Autocorrelation structure: R(0) = energy (large value) R(τ) ≈ 0 for τ > 0 (no correlation with shifted self) Effect: Convolution with this IR acts like impulse (minimal change) except for coloration from window shaping

Impulse Response Extraction

IR Windowing Process

From autocorrelation to usable IR:

STEP 1: Compute full autocorrelation Input: Window of audio (e.g., 0.2s = 8820 samples at 44.1kHz) Autocorrelation length: 2 × window_length - 1 (17639 samples) Center: sample 8820 (τ=0) STEP 2: Extract IR region around center Extract: [center - max_lag, center + max_lag] Example (max_lag = 0.02s = 882 samples): Extract: samples [7938, 9702] (1765 samples total) This captures ±20ms of autocorrelation structure STEP 3: Normalize IR Find: irMax = maximum value in extracted region Scale: IR = IR / irMax Purpose: Prevent convolution from amplifying signal excessively STEP 4: Apply Hann window to IR Hann window: w(n) = 0.5 - 0.5 × cos(2π × n / N) Where: n = sample index (0 to N-1), N = IR length Result: Smooth fade in/out at IR edges Purpose: Prevent clicks/artifacts in convolution Final IR: IR_windowed = IR_normalized × w(n) Effect of max_lag: Small max_lag (0.01s): Short IR, captures fast periodicities → Tight, metallic, high-frequency character Large max_lag (0.05s): Long IR, captures slow modulations → Loose, ambient, low-frequency character

Convolution Mechanics

Linear Convolution Implementation

How window ⊗ IR works:

Convolution operation: y[n] = (x ⊗ h)[n] y[n] = Σ x[k] · h[n - k] Where: x = original window (8820 samples) h = IR from autocorrelation (1765 samples at max_lag=0.02s) y = convolution result (8820 + 1765 - 1 = 10584 samples) Interpretation: Each output sample is weighted sum of input samples Weights come from time-reversed IR Effect: IR's frequency response applied to input Praat implementation: Convolve: "sum", "zero" - "sum" normalization: preserves energy - "zero" padding: no circular wrapping Output longer than input: Must trim back to original window length Extract center: [convCenter - windowDuration/2, convCenter + windowDuration/2] Where convCenter = output_length / 2 Why convolution with autocorrelation IR? Autocorrelation = signal × time-shifted self When used as IR: reinforces patterns that repeat at lag τ Periodic components → resonance/enhancement Noise → coloration (metallic/robotic character)

Normalization Strategy

Multi-stage normalization prevents clipping:

STAGE 1: IR normalization (before convolution) IR = IR / max(|IR|) Purpose: Prevent single IR from causing excessive gain STAGE 2: Convolution normalization (after convolution) convolved = convolved / max(|convolved|) × 0.5 Purpose: Scale each window to safe level (-6dB headroom) STAGE 3: Final normalization (after concatenation) output = output / max(|output|) × 0.9 Purpose: Scale entire output to -0.9dB peak Why multiple stages? - Each window processed independently → levels vary - Convolution can amplify unpredictably (depends on IR shape) - Conservative scaling (0.5, 0.9) provides safety margin - Final pass ensures consistent output level Trade-off: Conservative normalization → safe but potentially quiet Aggressive normalization → loud but may clip if IR resonates strongly

Time-Varying Processing

Sliding Window Analysis

Overlapping windows for time adaptation:

Window parameters: window_duration = 0.2s (analysis window size) window_step = 0.1s (hop size between windows) Overlap = window_duration - window_step = 0.1s (50% overlap) Window timeline (5s audio example): Window 1: [0.0s, 0.2s] Window 2: [0.1s, 0.3s] — overlaps 0.1s with window 1 Window 3: [0.2s, 0.4s] — overlaps 0.1s with window 2 ... Window 48: [4.7s, 4.9s] Window 49: [4.8s, 5.0s] — last window adjusted to reach end Number of windows: floor((duration - window_duration) / window_step) + 1 For 5s audio: floor((5.0 - 0.2) / 0.1) + 1 = 49 windows Why overlap? - Pitch/timbre changes gradually → adjacent windows similar - Crossfading smooths transitions between windows - Avoids abrupt filter changes (no "windowing artifacts") Parameter effects: Small window_step (0.05s): High overlap, very smooth, slower processing Large window_step (0.15s): Low overlap, faster, potential discontinuities Short window_duration (0.1s): Fast adaptation, captures rapid changes Long window_duration (0.3s): Slow adaptation, averages over longer time

Crossfading Algorithm

Smooth transitions between windows:

Crossfade implementation: Linear fade in/out FADE IN (first fadeSamples of each window except first): for i from 1 to fadeSamples: fade = i / fadeSamples (ramps from 0 to 1) sample[i] = sample[i] × fade FADE OUT (last fadeSamples of each window except last): for i from 1 to fadeSamples: fade = i / fadeSamples (ramps from 0 to 1) index = totalSamples - i + 1 (count backwards) sample[index] = sample[index] × fade Where: fadeSamples = crossfade_duration × sample_rate Example (crossfade_duration = 0.01s at 44.1kHz): fadeSamples = 441 samples At window boundary: Window N fades out: samples 8379-8820 ramp from 1→0 Window N+1 fades in: samples 1-441 ramp from 0→1 Overlap region: Both windows contribute, summing to ≈1.0 (assumes 50% overlap extends beyond fade region) Purpose: - Eliminates clicks/pops at window boundaries - Smooth timbral transitions as filter characteristics change - Allows IR to evolve gradually as pitch/spectrum changes

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

Custom max_lag exploration: Ultra-tight (0.005s = 5ms): Extreme metallic, aliasing artifacts possible Captures only very high periodicities (>200Hz) Use for: Harsh industrial, "bitcrushed" aesthetic Tight-medium (0.015s = 15ms): Compromise between metallic and resonant Good for: Voice robotization with some clarity Medium-loose (0.03s = 30ms): Smooth, chorused character Good for: Pad sounds, ambient vocals, sustained notes Loose-extreme (0.07s = 70ms): Very ambient, reverb-dominant Good for: Sound art, extreme textures Extreme (0.1s = 100ms): Long tail, almost reverb Processing slower (larger IRs) Good for: Experimental ambience, drone generation Recommended range: 0.005s to 0.1s Below 0.005s: Aliasing risk, harsh artifacts Above 0.1s: Diminishing returns, very slow processing Custom strategy: Start with preset closest to desired character Adjust max_lag ±0.005s to fine-tune Listen to effect on target material Optimize for specific pitch range or timbre goal

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:

numWindows = floor((duration - window_duration) / window_step) + 1 Example (10s audio, window_duration=0.2s, window_step=0.1s): numWindows = floor((10 - 0.2) / 0.1) + 1 = floor(98) + 1 = 99 windows Processing time estimate: ~0.3-0.5 seconds per window (typical) 99 windows × 0.4s = 40 seconds processing Trade-off: Fewer windows (large window_step) = faster but choppier More windows (small window_step) = slower but smoother

IR Length and Frequency Range

Frequency implications of max_lag:

IR captures periodicities with periods ≤ 2×max_lag Fundamental frequency range: f_min = 1 / (2×max_lag) Examples: max_lag = 0.01s → IR length = 20ms → f_min = 50Hz max_lag = 0.02s → IR length = 40ms → f_min = 25Hz max_lag = 0.05s → IR length = 100ms → f_min = 10Hz Interpretation: - Frequencies above f_min: Well captured, strong resonance - Frequencies below f_min: Partially captured, weak resonance - Very high frequencies: Always captured (periods < 1ms) Rule of thumb: Set max_lag ≥ 2×(period of lowest desired resonance) For bass voice (E2 = 82Hz, period = 12ms): max_lag = 0.015s minimum (captures E2 and above) For kick drum (50Hz, period = 20ms): max_lag = 0.025s minimum (captures fundamental)
Memory and Performance: Memory usage scales with: (1) Audio duration (longer = more windows to process). (2) Window_duration (larger windows = more samples per autocorrelation). (3) Max_lag (longer IR = larger convolution). Typical memory: <100MB for 60s audio at default settings. Processing bottleneck: Autocorrelation computation (O(N²) complexity per window) and convolution (O(N×M) where N=window length, M=IR length). Very long audio (>5 minutes) with small window_step (<0.08s) may take 5-10 minutes to process.
Parameter Constraint Violations: Script does NOT validate: (1) window_step < window_duration (required). If violated: Windows overlap excessively, potential artifacts. (2) crossfade_duration < window_step/2 (recommended). If violated: Fade regions may conflict at boundaries. (3) max_lag < window_duration/2 (required). If violated: IR extraction fails (not enough autocorrelation data). (4) window_duration ≥ 0.05s (minimum). If violated: Too few samples for meaningful autocorrelation. If processing fails or produces artifacts, check parameter constraints first.

Applications & Use Cases

Voice Transformation

Robotic Voice Effect

Recommended settings: Tight/Metallic preset (max_lag=0.01s)

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)

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)

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

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

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

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

Problem: Output silent or very quiet
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.
Problem: Output sounds "choppy" or "gated"
Cause: Window_step too large, insufficient overlap, crossfade too short
Solution: Decrease window_step (increase overlap), increase crossfade_duration (0.015-0.02s)
Problem: Effect too subtle/inaudible
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.
Problem: Harsh, aliased, or distorted output
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.
Problem: Processing extremely slow
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
Problem: Output has clicks/pops at regular intervals
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:

Autocorrelate command: "sum", "zero" Discrete autocorrelation: R[k] = Σ(n=0 to N-1-k) x[n] · x[n + k] Where: x[n] = input signal (N samples) k = lag index (0 to N-1) R[k] = autocorrelation at lag k "sum" normalization: Preserves energy - R[0] = signal energy (maximum by definition) - R[k] decreases for non-periodic signals "zero" padding: No circular wrapping - Assumes signal is zero outside [0, N-1] - Avoids artifacts from circular correlation Output length: 2N - 1 samples - Lags from -(N-1) to +(N-1) - Center at sample N (lag=0) - Symmetric: R[-k] = R[k] Computational complexity: O(N²) naive, O(N log N) via FFT Praat uses efficient FFT-based implementation

Properties of Autocorrelation

Mathematical properties exploited by algorithm:

PROPERTY 1: Symmetry R(τ) = R(-τ) Consequence: Only need half of autocorrelation (±max_lag) Script extracts [center - max_lag, center + max_lag] PROPERTY 2: Maximum at zero lag R(0) ≥ R(τ) for all τ Consequence: Center peak always present (signal energy) Normalization: IR scaled by R(0) to prevent energy explosion PROPERTY 3: Periodicity preservation If x(t) periodic with period T: R(τ) also periodic with period T R(T) = R(0) (perfect correlation at one period) Consequence: Periodic signals produce periodic IRs → Convolution reinforces periodicity PROPERTY 4: For white noise R(τ) ≈ 0 for τ ≠ 0 R(0) = noise power Consequence: IR is impulse-like (zero everywhere except center) → Convolution has minimal effect (noise remains noisy) PROPERTY 5: For sine wave (pure tone) R(τ) = cos(2πf·τ) × energy Where f = sine frequency Consequence: IR is cosine-shaped → Convolution acts like bandpass filter at frequency f

Convolution Mathematics

Discrete Linear Convolution

Convolution operation details:

Linear convolution: y = x ⊗ h y[n] = Σ(k=-∞ to ∞) x[k] · h[n - k] Finite sequences: x: N samples (window) h: M samples (IR from autocorrelation) y: N + M - 1 samples (convolution output) Praat Convolve: "sum", "zero" - "sum": Energy preserved (no additional normalization) - "zero": Finite support (no circular wrapping) Frequency domain interpretation: y = x ⊗ h ⟺ Y(f) = X(f) · H(f) Convolution in time = multiplication in frequency Where: X(f) = FFT of window H(f) = FFT of IR (autocorrelation) Y(f) = filtered spectrum Effect: IR's frequency response applied to input - Peaks in H(f) → resonances in output - Valleys in H(f) → attenuation in output - Phase of H(f) → phase shifts in output Praat implementation: FFT-based - Convert x and h to frequency domain - Multiply X(f) × H(f) - Inverse FFT to get y[n] - Complexity: O((N+M) log(N+M))

Why Autocorrelation IR Works

Conceptual explanation:

Autocorrelation R(τ) measures self-similarity at lag τ When used as IR: Convolution: output[t] = Σ input[t-τ] × R[τ] Interpretation: - Each output sample = weighted sum of past input - Weights come from autocorrelation (self-similarity measure) - High R[τ] → strong contribution from input[t-τ] - Low R[τ] → weak contribution from input[t-τ] For periodic signal with period T: - R[T] is large (signal similar to itself shifted by one period) - Convolution strongly weights input[t-T] - Creates resonance at frequency 1/T (reinforces periodicity) For noisy signal: - R[τ] ≈ 0 for τ ≠ 0 (no self-similarity) - Convolution mostly uses input[t] (τ=0) - Minimal effect (or coloration from window shaping) Result: Signal filters itself based on its own structure - Periodic structure → reinforcement - Noisy structure → minimal change (or metallic coloration) - Time-varying periodicity → time-varying resonance

Windowing and Overlap-Add

Windowing Theory

Why window and crossfade?

Without windowing: - Abrupt truncation at window boundaries - Spectral leakage (discontinuities → high frequencies) - Audible clicks/pops With Hann window on IR: w(n) = 0.5 - 0.5 × cos(2π × n / N) Properties: - Smooth fade in/out (no discontinuities) - Main lobe: Good frequency resolution - Side lobes: -31dB (minimal spectral leakage) IR windowing effect: - Prevents clicks in convolution output - Smooths IR edges (gradual onset/offset) - Slight spectral smearing (acceptable trade-off) Crossfading between windows: - Linear fade in/out at overlap regions - Ensures continuity of amplitude envelope - Smooth transitions as IR characteristics change Overlap-add reconstruction: output(t) = Σ windows_i(t) × fade_i(t) Where fade_i(t) = 1 at window center, 0 at edges Sum of fades ≈ 1.0 in overlap regions (continuous output)

Optimal Overlap Calculation

Choosing window_step for best results:

Overlap percentage: (window_duration - window_step) / window_duration × 100% Examples: window_duration=0.2s, window_step=0.1s → 50% overlap window_duration=0.2s, window_step=0.05s → 75% overlap window_duration=0.2s, window_step=0.15s → 25% overlap Trade-offs: High overlap (>60%): + Very smooth transitions + Gradual filter evolution - More windows to process (slower) - Higher redundancy Moderate overlap (40-60%): + Balanced smoothness and efficiency + Good for most applications - Standard choice Low overlap (<40%): + Faster processing (fewer windows) - Potential discontinuities - Filter jumps may be audible Recommendation: Start with 50% overlap (window_step = window_duration / 2) Increase overlap if artifacts present Decrease overlap if processing too slow and quality acceptable