Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / HelpSource / Classes / Pindex.schelp
blobf8872d4f9aade0b4c281f7356cd3e69658570640
1 class:: Pindex
2 summary:: pattern that indexes into an array
3 related:: Classes/Pswitch
4 categories:: Streams-Patterns-Events>Patterns>List>Indexing
6 description::
8 This allows an link::Classes/ArrayedCollection:: to be accessed within patterns.
10 ClassMethods::
12 method::new
14 argument::listPat
15 the array. Can be a link::Classes/Pattern::.
17 argument::indexPat
18 the value to retrieve. Can be a link::Classes/Pattern::.
20 argument::repeats
21 specifies the number of repeats.
23 Examples::
25 code::
27 SynthDef(\help_pindex, { | out, amp=0.1, freq=440, gate=1 |
28         var son = Saw.ar(freq * [0.99, 1, 1.01]).mean;
29         son = son * EnvGen.ar(Env.adsr, gate: gate, doneAction:2);
30         Out.ar(out, son.dup * amp);
31 }).add;
35 var data = [7, 13, 12, 2, 2, 2, 5];
36 var indices = [0, 0, 2, 0, 4, 6, 7];
37 Pbind(
38         \instrument, \help_pindex,
39         \choice, Prand(indices, inf),
40         \degree, Pindex(data, Pkey(\choice), inf),
41         \dur, 0.7
42 ).play