Random Walk Rhythm — User Guide

A deterministic metric pulse grid whose event frequency follows a bounded random walk on a linear-Hz lattice. Each transition requests up, down, or hold; outward requests at the lattice edges are reflected inward. Every event is rendered as a local-phase decaying sinusoidal pulse, then mapped through one of four spatial modes.

Author: Shai Cohen Affiliation: Department of Music, Bar-Ilan University, Israel Version: 0.4.1 (2026) License: MIT License Repo: Praat AudioTools
Contents:

Scope

Random Walk Rhythm separates timing from pitch-state evolution:

Tempo × StepsPerBeat → fixed rhythmic grid categorical up / down / hold → bounded frequency state frequency state + event kernel → pulse stream pulse stream → selected spatial mapping

The rhythm itself is not random. Event onsets occur on a regular metric lattice. The stochastic process controls only which frequency state is assigned to each grid event.

The frequency states are equally spaced in Hz, not in semitones or logarithmic pitch distance.

Quick start

  1. Run Random_Walk_Rhythm.praat. No input Sound is required.
  2. Choose Custom or one of the eight presets.
  3. Set Duration, Tempo, Steps per beat, Base frequency, Frequency step, Probability up/down, and Spatial mode.
  4. Enable Edit details to set Sample rate, frequency bounds, Event fill, Decay rate, Rotation speed, Output peak, and Random seed.
  5. Run the script. The random-walk state sequence is generated first, then the complete event stream is synthesized and spatialized.

Deterministic timing grid

Tempo and Steps per beat determine the exact grid spacing:

beatsPerSecond = Tempo / 60 beatDuration = 1 / beatsPerSecond stepDuration = beatDuration / StepsPerBeat

The number of events is:

totalSteps = ceil(Duration / stepDuration)

The final step may therefore begin before the requested end time but have less than one complete grid step remaining. The event itself is clipped to the remaining output duration.

There are no random onset offsets, no swing, and no tempo drift.

Event fill

Each event occupies:

eventDuration = stepDuration × EventFill

Because Event fill is restricted to 0 < fill ≤ 1, one event never extends past the onset of the following grid event. Thus there is no intentional event overlap within the mono source stream.

Random walk on a linear-Hz lattice

The base state has index 0 and frequency Base frequency. Reachable neighboring states are spaced by the selected Frequency step:

frequency(index) = BaseFrequency + index × FrequencyStep

The usable integer-index range is derived from Minimum frequency, Maximum frequency, Base frequency, and Frequency step. The resulting lattice can begin slightly above the requested minimum or end slightly below the requested maximum because only exact integer steps around the base are retained.

Categorical transition rule

At every transition, one random number determines the requested direction:

P(request up) = ProbabilityUp P(request down) = ProbabilityDown P(hold) = 1 - ProbabilityUp - ProbabilityDown

The two user probabilities must each lie between 0 and 1, and their sum cannot exceed 1.

An up or down request changes the state by exactly one frequency lattice step. There are no multi-step jumps.

The probabilities describe the requested directions. At a frequency boundary an outward request is reflected, so the realized applied direction can be opposite to the requested direction.

Boundary reflection

The walk does not clamp an illegal move to the edge state.

If an up request occurs at the highest lattice index, it is applied as one step downward. If a down request occurs at the lowest lattice index, it is applied as one step upward.

at upper edge: requested +1 → applied -1 at lower edge: requested -1 → applied +1

The script counts these events as boundary reflections. This prevents an outward random request from becoming an artificial repeated edge state.

A genuine hold occurs only when the categorical draw selects the hold category.

Percussive event kernel

Each grid event is a sine oscillator with local phase, exponential decay, and a cosine closure:

τ = x - eventTime g(τ) = sin(2πfτ) × exp(-DecayRate × τ / D) × [1 + cos(πτ / D)] / 2 0 ≤ τ < D

where D is the realized event duration.

Local phase

The carrier uses τ, so phase restarts at zero for every event. Consecutive events are therefore separate pulses even if the random walk holds the same frequency state.

Envelope

The exponential term creates the percussive decay. The cosine term begins at 1 and reaches zero at the event boundary, ensuring a zero-valued closure at the end of a complete pulse.

The final event is shortened when necessary so the output ends exactly at Duration.

For implementation stability, synthesis is accumulated in chunks of 20 events. Chunking does not alter the timing or random-walk sequence.

Spatial modes

Mono

The synthesized pulse stream remains mono without additional spatial processing.

Stereo Ping-Pong

Complete events alternate between channels:

event 1 → Left event 2 → Right event 3 → Left event 4 → Right ...

Because Event fill never exceeds one grid step, this grid-index routing does not split overlapping events.

Rotating Panorama

The same mono pulse stream is distributed with a continuous constant-power pan trajectory.

pan(t) = 0.5 + 0.5 sin(2π × rotationRate × t) gL = cos(π/2 × pan) gR = sin(π/2 × pan) gL² + gR² = 1

The rotation rate is:

rotationRate = beatsPerSecond × RotationCyclesPerBeat

A value of 0.5 cycles per beat therefore completes one L→R→L excursion every two beats.

Dual-Band AM

This mode starts from the same mono pulse stream, creates two copies, filters them differently, and applies slow independent amplitude modulation:

ChannelBandGain modulation
Left80 Hz to min(2500 Hz, 90% Nyquist)0.8 + 0.1 sin(2π × 0.3t)
Right120 Hz to min(4000 Hz, 90% Nyquist)0.7 + 0.2 cos(2π × 0.4t)
This is not a binaural-beat generator. It is a dual-band, independently amplitude-modulated stereo treatment of the same pulse stream.

Controls

Main page

ControlDefaultBehavior
PresetCustomCustom plus eight timing/frequency-walk configurations.
Duration6 sRequested final Sound duration.
Tempo120 BPMDefines beat duration.
Steps per beat4Subdivides each beat into the event grid.
Base frequency180 HzFrequency of random-walk index 0.
Frequency step50 HzLinear frequency change for every applied up/down transition.
Probability up.40Probability of requesting a +1 step.
Probability down.40Probability of requesting a -1 step.
Spatial modeMonoMono, Ping-Pong, Rotating Panorama, or Dual-Band AM.
Edit detailsoffOpens synthesis/safety/reproducibility controls.

Details page

ControlDefaultBehavior
Sample rate44100 HzDirect synthesis and final output rate; minimum 1000 Hz.
Minimum frequency80 HzLower requested limit used to construct the reachable frequency lattice.
Maximum frequency1500 HzUpper requested limit used to construct the reachable frequency lattice.
Event fill.80Fraction of each grid step occupied by its event; >0…1.
Exponential decay rate15Controls decay inside each event kernel.
Rotation cycles per beat.50Used only by Rotating Panorama.
Output peak.90Final target peak normalization; >0…1.
Random seed00 = unpredictable; positive = reproducible walk.

Presets

Presets override Tempo, Steps per beat, Base frequency, Frequency step, Probability up, and Probability down. Duration, Spatial mode, and Details-page controls remain user-controlled.

PresetTempoSteps/beatBase / stepUp / down / hold
Gentle Bounce902150 / 30 Hz.50 / .30 / .20
Chaotic Dance1608200 / 80 Hz.40 / .40 / .20
Steady Climb1004120 / 40 Hz.60 / .20 / .20
Falling Steps804200 / 60 Hz.30 / .50 / .20
Pulsing Heart602100 / 20 Hz.40 / .40 / .20
Nervous Ticks14016180 / 100 Hz.45 / .45 / .10
Ocean Waves703130 / 25 Hz.50 / .30 / .20
Machine Pulse1104160 / 35 Hz.40 / .40 / .20

Safety and derived limits

Frequency lattice

The base frequency must lie inside the requested min/max bounds. The Frequency step must allow at least two reachable integer lattice states.

The highest reachable lattice frequency must remain below:

0.95 × Nyquist

The scale is not compressed or rescaled automatically. Unsafe settings stop with an error.

Minimum event resolution

The nominal Event duration must contain at least eight samples at the selected sample rate.

Runtime guard

Version 0.4.1 limits the metric grid to:

maximum events = 12,000

If Duration, Tempo, and Steps per beat would create more than 12,000 grid events, the script stops before allocating the event arrays or beginning synthesis.

Randomness and reproducibility

The random walk uses one categorical draw per transition. Timing, event-envelope shape, spatial formulas, and level normalization are deterministic.

Random seed = 0 uses Praat's unpredictable random state. A positive seed makes the requested direction sequence reproducible.

After a fixed-seed walk is complete, the script restores Praat's global RNG to an unpredictable state.

Output and level

PropertyBehavior
InputNo input Sound required.
DurationExactly the requested Duration.
Sample rateExactly the Details-page Sample rate.
ChannelsMono in Mono mode; stereo in Ping-Pong, Rotating Panorama, and Dual-Band AM.
Event overlapNone intentionally because Event fill ≤ 1.
Global fadeNone; every event already has a smooth local closure.
NormalizationEvery non-silent result is peak-scaled once to Output peak. This is target normalization, not a down-only ceiling.
Object nameswalk_rhythm_<preset>, with _pingpong, _rotating, or _dualband added for the three stereo modes.

Visualization and QC

The visualization explains the generating mechanism first and shows the measured waveform only at the end.

PanelWhat it shows
A — Walk decisionsRequested up/down/hold directions and the opposite applied step when a boundary request is reflected.
B — Frequency stateThe realized piecewise-constant frequency trajectory inside the bounded linear-Hz lattice, with the base-frequency reference.
C — Event timing/kernel and spatial mappingLeft: one grid step, active event interval, and analytical decay/closure envelope. Right: the gain structure of the selected spatial mode.
D — Measured outputFinal mono waveform or separate left/right stereo waveforms after spatial processing and target normalization.

The QC bar reports Tempo, step duration, Event fill, event count, target and realized requested up/down/hold probabilities, reflection count, lattice range, realized frequency range, event duration, Decay rate, local-phase status, spatial mode, and final peak/RMS.