Pbrown implements a bounded random walk that moves musical parameters in small steps
Pbrown(lo, hi, step, repeats) generates a bounded random walk: each value is the previous value plus a uniform random amount in ±step, clipped to [lo, hi]. This produces smooth, locally coherent motion — useful for pitch, amplitude, panning, or any musical parameter where abrupt jumps would sound jarring. The walk is bounded so it never leaves the stated range but tends to explore it gradually. Pbrown can be combined with other patterns: e.g., \dur, Pbrown(0.1, 0.5, 0.05) gives rhythmically slightly varying durations. Stochastic chapter examples (Ch 19) show Pbrown applied to pitch sieves, microtonal steps, and duration envelopes.
Examples
Pbind( \midinote, Pbrown(84.0, 108.0, 0.25, inf), \dur, 1/25, \db, Pbrown(-57.0, -21.0, 6.0), \pan, Pbrown(-1, 1, 0.1), \instrument, \sine ).play
Assessment
Write a Pbind using Pbrown for pitch (range 60–80 semitones, step 2) and Pbrown for duration (0.1–0.5 s, step 0.05). Explain how you would add an elastic barrier so the walk reverses direction at boundaries rather than clipping.