2 summary:: Pattern-based conditional expression
3 related:: Classes/Pwhile
4 categories:: Streams-Patterns-Events>Patterns>Language Control
11 A pattern or stream returning a link::Classes/Boolean:: value.
14 This stream is evaluated if the link::Classes/Boolean:: is true.
17 This stream is evaluated if the link::Classes/Boolean:: is false.
20 This value (not stream) is returned if "iftrue" or "iffalse" return nil at any time.
25 p = Pif(Pfunc({ 0.3.coin }), Pwhite(0, 9, inf), Pwhite(100, 109, inf)).asStream;
28 // 7 of the 20 values, or roughly 30%, are in the 0-9 range:
30 [ 105, 107, 107, 8, 100, 3, 105, 5, 107, 106, 1, 104, 8, 102, 102, 4, 108, 8, 109, 101 ]
35 SynthDef(\help_sinegrain,
36 { arg out=0, freq=440, sustain=0.05;
38 env = EnvGen.kr(Env.perc(0.01, sustain, 0.2), doneAction:2);
39 Out.ar(out, SinOsc.ar(freq, 0, env))
46 a = Pif(Pfunc({ 0.3.coin }), Pn(Pseries(0.5, 0.1, 10)), Pn(Pseries(6, -0.1, 10))).asStream;
49 Synth(\help_sinegrain, [\freq, a.next * 600 + 300]);