2 summary:: A one-dimensional random walk over a list of values that are embedded
3 related:: Classes/Pbrown
4 categories:: Streams-Patterns-Events>Patterns>List
11 The items to be walked over.
14 Returns integers that will be used to increment the index into list.
16 argument::directionPattern
17 Used to determine the behavior at boundaries. When the index crosses a boundary, the next direction is drawn from this stream: 1 means use stepPattern as is, -1 means go in the reverse direction. Common patterns:
19 ## 1 || always wrap around to the other boundary.
20 ## Pseq([1, -1], inf) || go forward first, then backward, then forward again.
24 Where to start in the list.
31 Array.series(20, 0, 1), // integers, 0-19
32 // steps up to 2 in either direction, weighted toward positive
33 Pwrand([-2, -1, 0, 1, 2], [0.05, 0.1, 0.15, 1, 0.1].normalizeSum, inf),
34 // reverse direction at boundaries
36 10); // start in the middle
40 200.do({ x.next.post; ", ".post });
42 b = a.copy.directionPattern_(1); // this one will always wrap around
45 200.do({ x.next.post; ", ".post });
49 // non-random walk: easy way to do up-and-down arpeggiation
53 [60, 64, 67, 72, 76, 79, 84].midicps, // C major
55 Pseq([1, -1], inf), // turn around at either end
59 SynthDef(\help_walk, { arg freq;
60 Out.ar(0, Saw.ar([freq, freq+1], 0.5) * EnvGen.kr(Env.perc(0.01, 0.1), doneAction:2))
67 Synth.new(\help_walk, [\freq, x.next]);