linux: shared memory interface - link with librt
[supercollider.git] / HelpSource / Classes / Prewrite.schelp
blobb8b7e8f5bf50056723154bc5afc0a4b1d6878e55
1 class:: Prewrite
2 summary:: rewriting system
3 related:: Classes/Pfsm
4 categories:: Streams-Patterns-Events>Patterns>List>Indexing
6 description::
8 Lindenmayer system pattern for selfsimilar structures. Its strong::dictionary (or event):: maps one element to an array of child elements. The algorithm replaces iteratively (strong::levels:: deep) elements by arrays of elements starting with the values in the strong::pattern::.
10 ClassMethods::
12 method::new
14 argument::dict
15 a dictionary or an event.
17 code::
18 IdentityDictionary[
19         elem1 -> [ otherElements ],
20         elem2 -> [ otherElements ],
21         elem2 -> [ otherElements ]
25 Examples::
27 The examples use the code::():: shortcut for link::Classes/Event::.
29 code::
31 a = Prewrite(0, // start with 0
32                 (       0: #[2,0],
33                         1: #[0,0,1],
34                         2: #[1,0,1]
35                 ), 4);
36 x = a.asStream;
37 30.do({ x.next.postln });
41 //Prewrite used as a sequence of pitches:
44 SynthDef(\help_sinegrain,
45         { arg out=0, freq=440, sustain=0.05;
46                 var env;
47                 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
48                 Out.ar(out, SinOsc.ar(freq, 0, env))
49         }).add;
53 a = Prewrite(0, (
54         0: #[2,0],
55         1: #[0,0,1],
56         2: #[1,0,1]
57 ), 4).asStream;
58 Routine({
59         loop({
60                 Synth(\help_sinegrain, [\freq, (a.next * 5 + 70).midicps]);
61                 0.1.wait;
62         })
63 }).play;