Brownian Motion Texture Generator — User Guide

Generates granular textures using Brownian motion for temporal and spatial positioning, creating evolving soundscapes with natural stochastic movement.

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 Brownian motion granular synthesis — a stochastic approach to texture generation using random walks for grain positioning. Unlike regular granular synthesis with fixed spacing, this method uses: (1) Temporal Brownian motion: Grain timing follows random walk with drift. (2) Spatial Brownian motion: Stereo panning follows independent random walk. (3) Natural clustering: Grains naturally cluster and disperse over time. (4) Stochastic density: Irregular spacing creates organic textures. Process extracts short grains from source sound, positions them using Brownian motion in time and space, mixes into evolving stereo texture. Result: natural-sounding textures with emergent patterns and organic movement rather than mechanical repetition.

Key Features:

What is Brownian motion granular synthesis? Traditional granular synthesis: Grains placed at regular intervals or random uniform positions. Brownian motion granular: Grain positions follow random walk (Brownian motion), creating natural clustering behavior. Key characteristics: (1) Memory: Each position depends on previous position + random step. (2) Clustering: Grains tend to cluster rather than spread evenly. (3) Drift: Systematic movement can be added to random walk. (4) Naturalness: Mimics natural phenomena (particle motion, crowd movement). Advantages: (1) Organic textures: Sounds more natural and less mechanical. (2) Emergent patterns: Complex behaviors from simple rules. (3) Controlable randomness: Adjustable step size and drift. (4) Spatial evolution: Stereo field evolves naturally over time. Use cases: Sound design (natural textures, environmental sounds), experimental music (evolving soundscapes), film/TV (background textures), installation art (continuous evolving sound), scientific sonification (particle system visualization).

Technical Implementation: (1) Source preparation: Extract grains from input sound with specified duration. (2) Temporal Brownian motion: Base grain time = regular spacing + accumulated random steps. Random step = Gaussian(mean=time_drift, std=time_step_size). (3) Spatial Brownian motion: Pan position follows independent random walk. Random step = Gaussian(mean=spatial_drift, std=spatial_step_size). (4) Grain processing: Apply fades, amplitude scaling, constant-power panning. (5) Granular mixing: Add grains to output buffer at calculated positions. (6) Final processing: Apply global fade-out, normalize peak. Key insight: Two independent Brownian motions (temporal and spatial) create complex emergent behavior from simple stochastic processes. Clustering occurs naturally due to random walk properties.

Quick start

  1. In Praat, select exactly one Sound object as grain source.
  2. Run script…brownian_motion_texture.praat.
  3. Choose Preset or select "Custom" to specify all parameters manually.
  4. Adjust Grain_duration (typical 0.03-0.15s for texture).
  5. Set Output_duration and Density (grains per second).
  6. Configure Temporal Brownian motion parameters.
  7. Enable/configure Spatial Brownian motion for stereo movement.
  8. Set general parameters (amplitude, fades, grain positioning).
  9. Click OK — texture generated, result named "originalname_brownian".
Quick tip: Start with presets for different texture types — "Dense Cloud" for thick textures, "Sparse Field" for open textures, "Wild Drift" for active movement. Use source sounds with interesting micro-structure — noisy, textured, or complex sounds work best. Adjust grain duration for different effects: shorter (0.02-0.05s) for cloud-like textures, longer (0.1-0.3s) for more recognizable source material. Enable spatial Brownian motion for evolving stereo field. Higher density creates thicker textures but increases processing time. Processing shows progress every 10 grains — large textures (1000+ grains) may take several minutes. Output is stereo with evolving spatialization.
Important: SOURCE SOUND CRITICAL — texture quality depends heavily on source material. Very short sounds (< 0.5s) may not provide enough variety. Very long processing times possible with high density and long output duration (1000+ grains). Large time_step_size values can cause grains to cluster at beginning/end. Extreme spatial_step_size values can cause rapid panning jumps. Random_grain_positions = "no" creates systematic exploration of source sound. Output normalization to 0.99 prevents clipping but may reduce overall level. Always preview results — different source sounds produce dramatically different textures. For best results, use source sounds with rich frequency content and interesting transients.

Brownian Motion Theory

Brownian Motion Fundamentals

Mathematical Definition

Brownian motion (random walk):

Discrete Brownian motion: X₀ = initial_position Xₙ = Xₙ₋₁ + ΔXₙ Where ΔXₙ ~ Normal(mean=drift, variance=step_size²) i.e., ΔXₙ = drift + randomNormal(0, step_size) In this implementation: Temporal Brownian motion: time_offset₀ = 0 time_offsetₙ = time_offsetₙ₋₁ + randomGauss(time_drift, time_step_size) grain_timeₙ = base_timeₙ + time_offsetₙ Spatial Brownian motion: pan_position₀ = 0.5 (center) pan_positionₙ = pan_positionₙ₋₁ + randomGauss(spatial_drift, spatial_step_size) Clamped to [0, 1] range Key properties: - Memory: Current position depends on all previous steps - Clustering: Positions tend to cluster rather than spread evenly - Diffusion: Variance grows linearly with time (steps) - Drift: Systematic movement in specified direction

Why Brownian Motion for Granular Synthesis?

Natural clustering behavior:

Vs other random distributions:

Temporal Brownian Motion

Time Positioning Algorithm

Grain timing calculation:

Base timeline (regular spacing): base_timeₙ = (n - 1) / density Example: density = 20 Hz, n = 1 → 0.0s, n = 2 → 0.05s, n = 3 → 0.1s Brownian displacement: time_stepₙ = randomGauss(time_drift, time_step_size) time_offsetₙ = time_offsetₙ₋₁ + time_stepₙ Actual grain time: grain_timeₙ = base_timeₙ + time_offsetₙ Clamping: IF grain_timeₙ < 0 → grain_timeₙ = 0 IF grain_timeₙ > output_duration - grain_duration → grain_timeₙ = output_duration - grain_duration Parameter effects: time_drift > 0: gradual shift to later times time_drift < 0: gradual shift to earlier times time_step_size: controls clustering intensity

Temporal Clustering Behavior

Emergent temporal patterns:

Small time_step_size (0.02-0.05):
Gentle clustering, mostly regular spacing with slight variations
Result: Smooth texture with subtle density variations

Medium time_step_size (0.1-0.2):
Clear clustering, distinct dense and sparse regions
Result: Pulsating texture with evolving density

Large time_step_size (0.3+):
Strong clustering, most grains in beginning/end
Result: Burst-like texture with central void

With time_drift ≠ 0:
Systematic migration of clusters over time
Result: Evolving texture with directional movement

Spatial Brownian Motion

Stereo Panning Algorithm

Spatial positioning calculation:

Brownian pan motion: spatial_stepₙ = randomGauss(spatial_drift, spatial_step_size) pan_positionₙ = pan_positionₙ₋₁ + spatial_stepₙ Range clamping: IF pan_positionₙ < 0 → pan_positionₙ = 0 IF pan_positionₙ > 1 → pan_positionₙ = 1 Constant-power panning: gain_left = sqrt(1 - pan_positionₙ) gain_right = sqrt(pan_positionₙ) Stereo grain creation: grain_stereo = [grain_mono × gain_left, grain_mono × gain_right] Parameter effects: spatial_drift > 0: gradual shift to right spatial_drift < 0: gradual shift to left spatial_step_size: controls panning movement speed

Spatial Evolution Patterns

Stereo field behavior:

Small spatial_step_size (0.05-0.1):
Gentle panning movement, mostly centered with slight wandering
Result: Subtle stereo animation, stable image

Medium spatial_step_size (0.15-0.25):
Clear panning movement, explores stereo field naturally
Result: Organic spatial evolution, natural movement

Large spatial_step_size (0.3+):
Rapid panning jumps, extreme left-right movements
Result: Dramatic spatial effects, potentially disorienting

With spatial_drift ≠ 0:
Systematic migration across stereo field
Result: Panoramic sweeps, directional spatial movement

Complete Processing Pipeline

SETUP: Select Sound object as grain source Choose preset or custom parameters Calculate total_grains = density × output_duration INITIALIZATION: Create empty stereo output (duration = output_duration) Initialize time_offset = 0, pan_position = 0.5 GRAIN GENERATION LOOP (for n = 1 to total_grains): STEP 1: Temporal Brownian motion base_time = (n - 1) / density time_step = randomGauss(time_drift, time_step_size) time_offset = time_offset + time_step grain_time = base_time + time_offset Clamp grain_time to valid range [0, output_duration-grain_duration] STEP 2: Spatial Brownian motion IF enable_spatial_brownian: spatial_step = randomGauss(spatial_drift, spatial_step_size) pan_position = pan_position + spatial_step Clamp pan_position to [0, 1] ELSE: pan_position = 0.5 Calculate stereo gains: gain_L = √(1-pan), gain_R = √(pan) STEP 3: Grain extraction IF random_grain_positions: grain_start = randomUniform(0, input_duration - grain_duration) ELSE: grain_start = (n / total_grains) × (input_duration - grain_duration) Extract grain from source [grain_start, grain_start+grain_duration] STEP 4: Grain processing Apply fades (fade_duration) Scale amplitude (amplitude_scaling) Apply stereo panning (gain_L, gain_R) STEP 5: Mixing Add stereo grain to output at grain_time Progress display every 10 grains FINAL PROCESSING: Apply global fade-out (fade_out_time) Normalize peak to 0.99 Rename output: "originalname_brownian" OUTPUT: Stereo texture with Brownian motion temporal/spatial evolution

Texture Presets

Preset Characteristics

🌫️ Texture Type Selection

Range: Dense cloud-like to sparse open textures

Character: Pre-configured combinations for specific texture types

Best for: Quick exploration, consistent texture qualities

Built-in presets:

PresetGrain DurationDensityTime StepSpatial StepTexture Character
Dense Cloud0.03s40 Hz0.080.20Thick, cloud-like, active stereo
Sparse Field0.15s8 Hz0.200.10Open, spacious, gentle movement
Wild Drift0.06s25 Hz0.250.30Active, unpredictable, dramatic pans
Subtle Shimmer0.04s30 Hz0.050.08Delicate, shimmering, subtle motion
Rhythmic Pulse0.08s15 Hz0.020.25Pulsing, rhythmic, spatial jumps
Frozen Moment0.40s6 Hz0.150.12Long grains, sparse, glacial movement
CustomUserUserUserUserFull parameter control

Preset Applications

🎵 Sound Design Applications

Dense Cloud: Thick backgrounds, atmospheric pads, noise textures

Sparse Field: Ambient spaces, environmental backgrounds, subtle atmospheres

Wild Drift: Experimental textures, chaotic environments, special effects

Subtle Shimmer: Delicate accents, magical effects, light reflections

Rhythmic Pulse: Rhythmic textures, percussive backgrounds, pulse waves

Frozen Moment: Drone textures, frozen time effects, ambient drones

Parameters

Basic Parameters

ParameterTypeDefaultDescription
PresetoptionCustom6 texture presets + Custom
Grain_duration_(s)positive0.05Duration of individual grains
Output_duration_(s)positive10.0Total duration of output texture
Density_(grains/s)positive20Grains per second (base density)

Temporal Brownian Motion

ParameterTypeDefaultDescription
Time_step_size_(s)positive0.1Standard deviation of time steps
Time_driftreal0.0Systematic drift in time (s/step)

Spatial Brownian Motion

ParameterTypeDefaultDescription
Enable_spatial_brownianboolean1 (on)Enable stereo panning Brownian motion
Spatial_step_sizepositive0.15Standard deviation of pan steps
Spatial_driftreal0.0Systematic drift in pan position

General Parameters

ParameterTypeDefaultDescription
Amplitude_scalingpositive0.7Grain amplitude multiplier
Random_grain_positionsboolean1 (on)Random vs systematic source exploration
Fade_duration_(s)positive0.005Grain fade in/out duration
Fade_out_time_(s)positive2.0Global output fade-out duration

Applications

Sound Design Textures

Use case: Creating evolving background textures and atmospheres

Technique: Use noisy or complex sounds as source with medium-high density

Example: "Dense Cloud" with noise source for thick atmospheric pad

Environmental Soundscapes

Use case: Naturalistic environmental backgrounds

Technique: Use field recordings with sparse settings

Example: "Sparse Field" with forest recording for ambient background

Experimental Music

Use case: Evolving texture-based compositions

Technique: Multiple layers with different Brownian parameters

Workflow:

Film and Game Audio

Use case: Dynamic background textures for scenes/environments

Advantages:

Example: Spaceship interior with mechanical source sounds

Installation Art

Use case: Continuous evolving sound for spaces

Technique: Long output durations with subtle parameters

Application: Gallery soundscapes, architectural sound

Practical Workflow Examples

🎬 Sci-Fi Spaceship Interior

Goal: Complex mechanical background with spatial movement

Settings:

  • Source: Mechanical sounds, servo motors, electrical hum
  • Preset: Dense Cloud (modified)
  • Grain duration: 0.04s
  • Density: 35 Hz
  • Time step: 0.12 (moderate clustering)
  • Spatial step: 0.18 (active but controlled movement)
  • Output: 30.0s (loopable)

Result: Believable spaceship interior atmosphere

🌲 Forest Ambience

Goal: Natural forest background with subtle movement

Settings:

  • Source: Forest recording with birds, leaves, distant sounds
  • Preset: Sparse Field
  • Grain duration: 0.2s (longer for recognizability)
  • Density: 6 Hz (very sparse)
  • Time step: 0.25 (strong clustering for natural distribution)
  • Spatial step: 0.08 (gentle stereo movement)
  • Output: 60.0s (extended ambience)

Result: Naturalistic forest environment

⚡ Experimental Texture

Goal: Unpredictable, evolving texture for experimental music

Settings:

  • Source: Complex synthesized sounds, noise bursts
  • Preset: Wild Drift
  • Grain duration: 0.1s
  • Density: 20 Hz
  • Time step: 0.4 (extreme clustering)
  • Spatial step: 0.35 (rapid panning movement)
  • Time drift: 0.01 (gradual forward movement)
  • Output: 15.0s

Result: Dynamic, unpredictable texture with directional evolution

Advanced Techniques

Source sound selection strategies:
  • Noisy sounds: Create cloud-like textures (noise, wind, water)
  • Transient-rich sounds: Create rhythmic textures (percussion, clicks)
  • Tonal sounds: Create harmonic clouds (sustained instruments)
  • Complex sounds: Create rich textures (field recordings, complex synths)
  • Short sounds: Work best for high-density textures
  • Long sounds: Provide more variety but may need longer grain durations

Different source types produce dramatically different textures

Parameter interaction strategies:
  • High density + small time step: Thick, smooth texture
  • Low density + large time step: Sparse, clustered events
  • Short grains + high density: Cloud-like texture
  • Long grains + low density: Event-based texture
  • Time drift ≠ 0: Directional texture evolution
  • Spatial drift ≠ 0: Panoramic sweeps

Troubleshooting Common Issues

Problem: Texture too dense/muddy
Cause: High density with long grains or small time step
Solution: Reduce density, shorten grain duration, increase time step size
Problem: Texture too sparse/empty
Cause: Low density, large time step causing extreme clustering
Solution: Increase density, reduce time step size, check grain clamping
Problem: Grains clustered at beginning/end
Cause: Large time step size with drift
Solution: Reduce time step size, set time_drift closer to zero
Problem: Panning too extreme/jumpy
Cause: Large spatial step size
Solution: Reduce spatial step size, enable spatial clamping check

Mathematical Deep Dive

Brownian Motion Properties

Statistical Characteristics

For Brownian motion with drift:

Position after n steps: Xₙ = X₀ + n×μ + Σεᵢ Where εᵢ ~ Normal(0, σ²), μ = drift, σ = step_size Expected value (mean): E[Xₙ] = X₀ + n×μ Variance: Var[Xₙ] = n×σ² Standard deviation: SD[Xₙ] = σ×√n In this implementation: Temporal Brownian motion: E[time_offsetₙ] = n×time_drift SD[time_offsetₙ] = time_step_size×√n Spatial Brownian motion: E[pan_positionₙ] = 0.5 + n×spatial_drift SD[pan_positionₙ] = spatial_step_size×√n Clustering behavior: Probability of returning to origin decreases with √n Creates natural clustering over time

Diffusion and Clustering

Why clustering occurs:

Random walk properties: - Probability density spreads like heat diffusion - Standard deviation grows with √n - Particles tend to revisit previous regions - Creates natural clustering behavior Mathematical insight: For unbiased Brownian motion (drift = 0): Expected number of distinct positions ≈ √n Most positions are revisited multiple times Creates dense clusters separated by voids Practical implication for textures: - Small step_size: Gentle clustering, mostly uniform - Medium step_size: Clear clusters and voids - Large step_size: Extreme clustering at boundaries - With drift: Systematic migration of clusters Optimal range for textures: time_step_size ≈ 0.1-0.3 × (1/density) Creates noticeable but not extreme clustering

Grain Distribution Analysis

Temporal Distribution Patterns

Different parameter combinations:

Case 1: Small step_size, no drift time_step_size ≈ 0.05, time_drift = 0 Clustering: Gentle, mostly uniform distribution Texture: Smooth, cloud-like, minimal density variation Use: Foundation textures, smooth backgrounds Case 2: Medium step_size, no drift time_step_size ≈ 0.15, time_drift = 0 Clustering: Clear clusters and voids Texture: Pulsating, evolving density Use: Active backgrounds, rhythmic textures Case 3: Large step_size, no drift time_step_size ≈ 0.4, time_drift = 0 Clustering: Extreme, most grains at boundaries Texture: Burst-like, sparse center Use: Special effects, dramatic textures Case 4: With positive drift time_drift > 0 (e.g., 0.01) Behavior: Systematic migration to later times Texture: Gradual build-up, forward movement Use: Directional textures, evolving structures Case 5: With negative drift time_drift < 0 (e.g., -0.01) Behavior: Systematic migration to earlier times Texture: Gradual decay, backward movement Use: Dissolving textures, reverse evolution