Brownian Motion Texture Generator — User Guide

Granular texture generation driven by two cumulative Gaussian random walks: one perturbs output-event time and the other moves stereo position. Grains can be read randomly, sequentially, or from a frozen source position.

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

What this does

Brownian Motion Texture Generator turns one selected Sound into a stereo grain texture. The source is first converted to mono. A fixed number of equal-duration grains is then scheduled over a requested output duration.

Two stateful stochastic processes control the cloud:

Because each new state depends on the previous one, the result differs from independently randomizing every grain. The trajectories wander, accumulate drift, and interact with their boundaries.

Important: this is a discrete Gaussian random walk with drift, used as a Brownian-motion model. It is not a physical simulation of particles suspended in fluid.

What is Brownian motion?

Brownian motion describes irregular wandering in which each new position develops from the previous position plus a random increment. In a discrete random-walk model:

X[n] = X[n-1] + drift + randomGaussian(0, stepSize)

The key idea is memory: positions are not drawn independently. A sequence of small random changes creates a continuous-looking wandering path, while non-zero drift biases the walk in one direction.

In this script the idea is used twice. Output timing follows a moving temporal reference plus a cumulative random offset, while stereo pan follows a direct random walk around its previous pan position. Both walks are constrained by selectable boundary rules.

Quick start

  1. Select exactly one Sound object.
  2. Run Brownian_Motion_Texture_Generator.praat.
  3. Choose a preset or keep Custom.
  4. Set grain duration, output duration, and density.
  5. Use Time_step_size_s and Time_drift for temporal wandering.
  6. Use Spatial_step_size and Spatial_drift for stereo wandering.
  7. Choose Clamp, Reflect, or Reject independently for temporal and spatial boundaries.
  8. Choose Random, Sequential, or Frozen centre for source reading.
  9. Leave Allow_overlap on for a true overlapping grain cloud.
  10. Run the script. The result is a new stereo Sound named <source>_brownian_<preset>.

Temporal Brownian walk

The script begins with a regular density grid:

baseTime[i] = (i - 1) / density

The base position is limited to the latest legal grain start, outputDuration - grainDuration. A cumulative stochastic offset is then added. Away from the boundaries, consecutive states are equivalent to:

grainTime[i] ≈ grainTime[i-1] + 1 / density + randomGaussian(timeDrift, timeStepSize)

Time_step_size_s is the standard deviation of each random temporal increment. Time_drift is the mean increment per grain. Positive drift biases the path later; negative drift biases it earlier.

Temporal boundary handling

ModeBehavior
ClampValues outside the valid start-time interval are pinned to the nearest boundary, and the internal temporal state is updated to that legal position.
ReflectOvershoots are mirrored back into the valid interval. The implementation uses periodic reflection, so even very large overshoots remain valid.
RejectAn out-of-range proposal is re-drawn, up to 30 attempts. If no proposal succeeds, the current legal state is retained/clamped.
The default temporal boundary mode is Reflect.

Spatial Brownian walk

Pan starts at the centre, 0.5. When spatial Brownian motion is enabled, each grain proposes:

pan[i] = pan[i-1] + randomGaussian(spatialDrift, spatialStepSize)

The legal pan interval is 0–1, where 0 is left, 0.5 is centre, and 1 is right.

ModeBehavior
ClampPins overshoots to 0 or 1.
ReflectBounces overshoots back through the stereo interval.
RejectRe-draws an invalid step up to 30 times; if all proposals fail, the previous pan position is kept.

Stereo gains use constant-power panning:

gainL = sqrt(1 - pan) gainR = sqrt(pan)

If Enable_spatial_brownian is off, every grain is placed at pan = 0.5.

Source-position modes

The Brownian walks control where grains are rendered, not necessarily where they are read from the source. Source reading is selected separately:

ModeSource start positions
RandomEach grain reads from an independent uniform random position within the valid source-start range.
SequentialGrain starts traverse linearly from the first valid source position to the last, including both endpoints.
Frozen centreEvery grain reads from the same centre position of the valid source-start range.
Frozen Moment uses Frozen centre. It is therefore a repeated granulation of one source region, not merely a slow random traversal.

Presets

PresetGrainOutputDensityTime step / driftSpatial step / driftSourceGain
Dense Cloud30 ms8 s40/s0.08 / 00.20 / 0Random0.50
Sparse Field150 ms15 s8/s0.20 / 00.10 / 0Random0.80
Wild Drift60 ms12 s25/s0.25 / +0.020.30 / +0.01Random0.60
Subtle Shimmer40 ms10 s30/s0.05 / 00.08 / 0Random0.60
Rhythmic Pulse80 ms10 s15/s0.02 / 00.25 / 0Sequential0.75
Frozen Moment400 ms20 s6/s0.15 / 00.12 / 0Frozen centre0.85

Presets also set grain-edge fade and final fade-out values. They do not change the selected temporal boundary mode, spatial boundary mode, Allow_overlap, visualization, or playback switches.

Parameters

ParameterDefaultMeaning
PresetCustomCustom plus six named settings.
Grain_duration_s0.05Fixed duration of every grain.
Output_duration_s10.0Requested canvas duration when overlap mode is on.
Density_grains_per_sec20Requested grain rate; grain count = round(density × output duration).
Time_step_size_s0.1Temporal Gaussian step standard deviation, in seconds.
Time_drift0.0Mean temporal increment per grain, in seconds.
Temporal_boundary_handlingReflectClamp, Reflect, or Reject for legal output-start times.
Enable_spatial_brownianOnEnables the stereo random walk.
Spatial_step_size0.15Spatial Gaussian step standard deviation in pan units.
Spatial_drift0.0Mean pan increment per grain.
Boundary_handlingClampSpatial Clamp, Reflect, or Reject.
Amplitude_scaling0.7Global multiplier applied to every grain before mixing.
Source_position_modeRandomRandom, Sequential, or Frozen centre source reading.
Fade_duration_s0.005Raised-cosine fade applied independently at each grain edge.
Fade_out_s2.0Raised-cosine fade over the final part of the completed output.
Allow_overlapOnSum grains at their scheduled times; Off serializes colliding grains.
Draw_visualizationOnDraw Source → Brownian state map → Output → Summary.
Play_resultOnPlay the created Sound.

Overlap & rendering

The requested grain count is:

totalGrains = round(density × requestedOutputDuration)

The script allows up to 5,000 grains.

Allow_overlap = On

Grains are written directly at their sorted scheduled start times into one stereo canvas. Simultaneous grains are summed, so dense settings produce a genuine overlapping grain cloud. The canvas duration is exactly Output_duration_s.

Allow_overlap = Off

Each grain is pushed forward when necessary so that it begins no earlier than the end of the preceding rendered grain. This serializes the texture. If the resulting schedule extends beyond the requested output duration, the output canvas is enlarged to contain it rather than truncating the final grains.

Density × grain duration is reported as an overlap diagnostic. Values near or above 1 indicate that a regular schedule would already contain substantial temporal overlap.

Visualization

When enabled, the Picture window shows:

The Brownian map uses the unsorted generated path, so it shows the stochastic trajectory itself rather than the chronological render order. Source and Output use a shared amplitude scale.

Output behavior & limits

Level handling

Amplitude_scaling remains meaningful because the script does not normalize every result. After mixing and the final fade-out, it measures the sample peak. Only if the peak exceeds 0.95 is the result scaled down to 0.95. Quiet results are left quiet.

This is an attenuate-only safety limiter, not peak normalization.

The result is named <source>_brownian_<presetName>.