Granular Displacement — User Guide

Temporal micro-shifting: applies different delay offsets to audio segments creating complex phasing, flanging, and micro-temporal effects.

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 granular displacement — an advanced audio processing technique that applies different delay offsets to individual time segments (grains) of audio. Creates complex phasing, flanging, and micro-temporal effects by displacing segments relative to each other, then mixing them with the original signal. Process divides audio into grains, applies random delays and amplitudes to each, then recombines for rich temporal textures.

Key Features:

What is granular displacement? Traditional effects: uniform processing across entire signal. Granular displacement: processes audio in small segments (grains) with varying parameters. Advantages: (1) Micro-temporal effects: Creates complex phasing and flanging. (2) Segment independence: Each grain processed differently. (3) Rich textures: Combines multiple delay times. (4) Stereo enhancement: Independent processing creates width. (5) Controlled chaos: Random within defined boundaries. Use cases: Creative sound design, psychedelic effects, temporal manipulation, stereo enhancement, experimental processing.

Quick start

  1. Select Sound object in Praat
  2. Run granular_displacement.praat
  3. Choose preset for pre-configured displacement characters
  4. Or adjust number_of_grains for segment density
  5. Set delay_min and delay_divisor for timing range
  6. Configure amplitude_min/max for effect intensity
  7. Click OK — granular displacement applied
Quick tip: Start with Medium Granular for balanced phasing effects. Use Subtle Granular for gentle enhancement or Extreme Granular for dramatic temporal distortion. Each processing creates unique results due to random variations.
Random Results: Due to the random delay and amplitude assignments, each processing creates different results even with identical parameters. The presets provide characteristic behaviors rather than exact patterns.

Granular Theory

Granular Segmentation

⏱️ Time Division Algorithm

Audio segmentation and processing:

1. Calculate grain size: total_samples = Get number of samples grain_size = total_samples / number_of_grains 2. For each grain (1 to number_of_grains): Calculate grain boundaries: start_sample = (grain - 1) × grain_size + 1 end_sample = grain × grain_size 3. Generate random parameters per grain: grain_delay = randomUniform(delay_min, grain_size/delay_divisor) grain_amplitude = randomUniform(amplitude_min, amplitude_max) 4. Apply displacement formula: Formula: "self + grain_amplitude × (self[col+grain_delay] - self[col])" Key properties: Each grain processed independently Random delays create complex phasing Amplitude variations add texture Formula ensures clean mixing

Displacement Mathematics

🔄 Advanced Mixing Formula

Core displacement equation:

Displacement formula: output = original + amplitude × (delayed - original) Expanded: output = original + amplitude×delayed - amplitude×original output = (1 - amplitude)×original + amplitude×delayed Mathematical properties: When amplitude = 0: output = original (no effect) When amplitude = 1: output = delayed (full displacement) When 0 < amplitude < 1: mix of original and delayed Benefits: Prevents amplitude buildup Maintains signal integrity Creates natural phasing effects Allows controlled intensity For each sample in grain: output[col] = input[col] + grain_amplitude × (input[col+grain_delay] - input[col])

Stereo Processing System

ChannelDelay RangeAmplitude RangeEffect
Left Channeldelay_min to grain_size/delay_divisoramplitude_min to amplitude_maxPrimary displacement character
Right Channel15 to grain_size/3.50.15 to 0.75Slightly different parameters for stereo width
Mono SourceSame as left channelSame as left channelProcessed then converted to stereo

Parameter Interactions

Grain density control: number_of_grains (5-18): Fewer grains (5-8): Larger segments, broader effects More grains (12-18): Smaller segments, detailed textures Optimal range: 8-12 for balanced processing Delay timing: delay_min (8-15 samples): Minimum delay offset in samples Smaller = subtler phasing Larger = more noticeable displacement delay_divisor (2.5-5): Controls maximum delay: max_delay = grain_size/divisor Smaller divisor = larger maximum delays Larger divisor = smaller maximum delays Amplitude range: amplitude_min (0.15-0.3): Minimum mix level for displaced signal Higher = more intense effect amplitude_max (0.6-1.1): Maximum mix level >1.0 can create amplification (use with scale_peak)

Displacement Presets

PresetGrainsMin DelayDelay DivisorAmp MinAmp MaxCharacter
Subtle Granular5850.150.6Gentle phasing, barely noticeable
Medium Granular81040.20.8Balanced flanging effects
Heavy Granular121230.250.95Pronounced temporal distortion
Extreme Granular18152.50.31.1Intense, chaotic displacement

🎛️ Effect Character Applications

Subtle Granular: Add gentle movement and dimension to vocals and instruments. Creates subtle phasing that enhances without overwhelming the original sound.

Medium Granular: Produce classic flanging and phasing effects for musical applications. Balanced between effect character and signal preservation.

Heavy Granular: Create dramatic temporal effects for sound design and experimental music. Noticeable displacement that transforms audio character.

Extreme Granular: Generate chaotic, unpredictable textures for extreme sound design and noise art. Maximum displacement intensity.

Technical Processing Pipeline

Complete processing stages: 1. PREPARE AUDIO: - Select original sound - Create silent tail (tail_duration_seconds) - Concatenate original + tail - Handle stereo/mono conversion 2. CHANNEL PROCESSING: For stereo: - Extract left and right channels - Process left with main parameters - Process right with slightly different parameters For mono: - Process single channel - Convert to stereo 3. GRANULAR PROCESSING: For each channel: - Calculate grain_size = total_samples / number_of_grains - For each grain 1 to number_of_grains: start_sample = (grain-1)×grain_size + 1 end_sample = grain×grain_size grain_delay = randomUniform(delay_min, grain_size/delay_divisor) grain_amplitude = randomUniform(amplitude_min, amplitude_max) Apply displacement formula to grain region 4. FINALIZE: - Scale peak to prevent clipping - Combine channels (if stereo) - Cleanup intermediate objects - Play result (if enabled)

Applications

Creative Sound Design

Phasing and Flanging Effects: Use Medium Granular to create rich, evolving phasing effects that are more complex and organic than traditional flangers. The multiple delay times create intricate comb filtering.
Temporal Texture Creation: Apply Heavy or Extreme Granular to create complex temporal textures from simple sounds. Useful for transforming static sounds into dynamic, evolving textures.

Music Production

Vocal Enhancement: Use Subtle Granular to add dimension and movement to vocal tracks without obvious effect artifacts. Creates natural-sounding enhancement.
Instrument Processing: Apply granular displacement to synthesizers, guitars, or percussion to create unique tonal variations and rhythmic interest.

Experimental Audio

Micro-temporal Studies: Use the script to explore how small temporal displacements affect audio perception. The controlled parameters allow systematic investigation of temporal processing.
Algorithmic Effects: Combine granular displacement with other processing techniques to create complex, multi-layered effects for experimental music and sound art.

Technical Considerations

Delay Range Limits: Very large delay values (small delay_divisor) combined with high amplitudes can create noticeable echoes or artifacts. The grain_size/delay_divisor calculation ensures delays stay within reasonable bounds.
Amplitude Clipping: amplitude_max values greater than 1.0 can cause amplification and potential clipping. The scale_peak parameter helps prevent this, but extreme values may still cause issues.
Stereo Imaging: The independent left/right processing with slightly different parameters creates natural stereo width without artificial "ping-pong" effects. The differences are subtle enough to maintain mono compatibility.