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.
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:
- Temporal walk: a cumulative Gaussian random-walk offset perturbs the regular density grid.
- Spatial walk: stereo pan moves cumulatively across the range 0–1.
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.
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:
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
- Select exactly one Sound object.
- Run
Brownian_Motion_Texture_Generator.praat. - Choose a preset or keep Custom.
- Set grain duration, output duration, and density.
- Use Time_step_size_s and Time_drift for temporal wandering.
- Use Spatial_step_size and Spatial_drift for stereo wandering.
- Choose Clamp, Reflect, or Reject independently for temporal and spatial boundaries.
- Choose Random, Sequential, or Frozen centre for source reading.
- Leave Allow_overlap on for a true overlapping grain cloud.
- 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:
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:
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
| Mode | Behavior |
|---|---|
| Clamp | Values outside the valid start-time interval are pinned to the nearest boundary, and the internal temporal state is updated to that legal position. |
| Reflect | Overshoots are mirrored back into the valid interval. The implementation uses periodic reflection, so even very large overshoots remain valid. |
| Reject | An out-of-range proposal is re-drawn, up to 30 attempts. If no proposal succeeds, the current legal state is retained/clamped. |
Spatial Brownian walk
Pan starts at the centre, 0.5. When spatial Brownian motion is enabled, each grain proposes:
The legal pan interval is 0–1, where 0 is left, 0.5 is centre, and 1 is right.
| Mode | Behavior |
|---|---|
| Clamp | Pins overshoots to 0 or 1. |
| Reflect | Bounces overshoots back through the stereo interval. |
| Reject | Re-draws an invalid step up to 30 times; if all proposals fail, the previous pan position is kept. |
Stereo gains use constant-power panning:
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:
| Mode | Source start positions |
|---|---|
| Random | Each grain reads from an independent uniform random position within the valid source-start range. |
| Sequential | Grain starts traverse linearly from the first valid source position to the last, including both endpoints. |
| Frozen centre | Every grain reads from the same centre position of the valid source-start range. |
Presets
| Preset | Grain | Output | Density | Time step / drift | Spatial step / drift | Source | Gain |
|---|---|---|---|---|---|---|---|
| Dense Cloud | 30 ms | 8 s | 40/s | 0.08 / 0 | 0.20 / 0 | Random | 0.50 |
| Sparse Field | 150 ms | 15 s | 8/s | 0.20 / 0 | 0.10 / 0 | Random | 0.80 |
| Wild Drift | 60 ms | 12 s | 25/s | 0.25 / +0.02 | 0.30 / +0.01 | Random | 0.60 |
| Subtle Shimmer | 40 ms | 10 s | 30/s | 0.05 / 0 | 0.08 / 0 | Random | 0.60 |
| Rhythmic Pulse | 80 ms | 10 s | 15/s | 0.02 / 0 | 0.25 / 0 | Sequential | 0.75 |
| Frozen Moment | 400 ms | 20 s | 6/s | 0.15 / 0 | 0.12 / 0 | Frozen centre | 0.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
| Parameter | Default | Meaning |
|---|---|---|
| Preset | Custom | Custom plus six named settings. |
| Grain_duration_s | 0.05 | Fixed duration of every grain. |
| Output_duration_s | 10.0 | Requested canvas duration when overlap mode is on. |
| Density_grains_per_sec | 20 | Requested grain rate; grain count = round(density × output duration). |
| Time_step_size_s | 0.1 | Temporal Gaussian step standard deviation, in seconds. |
| Time_drift | 0.0 | Mean temporal increment per grain, in seconds. |
| Temporal_boundary_handling | Reflect | Clamp, Reflect, or Reject for legal output-start times. |
| Enable_spatial_brownian | On | Enables the stereo random walk. |
| Spatial_step_size | 0.15 | Spatial Gaussian step standard deviation in pan units. |
| Spatial_drift | 0.0 | Mean pan increment per grain. |
| Boundary_handling | Clamp | Spatial Clamp, Reflect, or Reject. |
| Amplitude_scaling | 0.7 | Global multiplier applied to every grain before mixing. |
| Source_position_mode | Random | Random, Sequential, or Frozen centre source reading. |
| Fade_duration_s | 0.005 | Raised-cosine fade applied independently at each grain edge. |
| Fade_out_s | 2.0 | Raised-cosine fade over the final part of the completed output. |
| Allow_overlap | On | Sum grains at their scheduled times; Off serializes colliding grains. |
| Draw_visualization | On | Draw Source → Brownian state map → Output → Summary. |
| Play_result | On | Play the created Sound. |
Overlap & rendering
The requested grain count is:
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.
Visualization
When enabled, the Picture window shows:
- Source: the mono source used for grain reading.
- Brownian state map: an upper temporal track showing the generated output-time path against the no-drift reference, and a lower pan track showing the spatial walk around centre.
- Output: left and right output waveforms, blue and orange.
- Summary: preset, grain count, density, grain duration, temporal/spatial step sizes, boundary modes, source mode, overlap/serial mode, fade-out, output duration, and final peak.
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
- The input is converted to mono for grain reading.
- The output is always stereo.
- Input and requested output durations must each be at least one grain duration.
- Temporal and spatial step sizes may be zero but not negative.
- Grain-edge fade may not exceed half the grain duration.
- Final fade-out is limited automatically to the actual output duration.
- A memory guard rejects outputs exceeding 50 million stereo samples.
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.
The result is named <source>_brownian_<presetName>.