Granular Displacement — User Guide
Temporal micro-shifting: applies different delay offsets to audio segments creating complex phasing, flanging, and micro-temporal effects.
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:
- 4 Displacement Presets — From subtle phasing to extreme temporal distortion
- Granular Segmentation — Audio divided into configurable number of grains
- Random Delay Offsets — Each grain receives unique delay timing
- Amplitude Modulation — Individual grain level control
- Stereo Processing — Independent left/right channel treatment
- Clean Mixing — Mathematical displacement formula prevents artifacts
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
- Select Sound object in Praat
- Run
granular_displacement.praat
- Choose preset for pre-configured displacement characters
- Or adjust number_of_grains for segment density
- Set delay_min and delay_divisor for timing range
- Configure amplitude_min/max for effect intensity
- 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
| Channel | Delay Range | Amplitude Range | Effect |
| Left Channel | delay_min to grain_size/delay_divisor | amplitude_min to amplitude_max | Primary displacement character |
| Right Channel | 15 to grain_size/3.5 | 0.15 to 0.75 | Slightly different parameters for stereo width |
| Mono Source | Same as left channel | Same as left channel | Processed 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
| Preset | Grains | Min Delay | Delay Divisor | Amp Min | Amp Max | Character |
| Subtle Granular | 5 | 8 | 5 | 0.15 | 0.6 | Gentle phasing, barely noticeable |
| Medium Granular | 8 | 10 | 4 | 0.2 | 0.8 | Balanced flanging effects |
| Heavy Granular | 12 | 12 | 3 | 0.25 | 0.95 | Pronounced temporal distortion |
| Extreme Granular | 18 | 15 | 2.5 | 0.3 | 1.1 | Intense, 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.