Explicitly include a boost "windows" folder even on linux
[supercollider.git] / HelpSource / Classes / Fdef.schelp
bloba711bfe3eff64e1000fbe587142e67abe0ffa7df
1 class:: Fdef
2 summary:: lazy function proxy
3 categories:: Libraries>JITLib>Patterns
4 related:: Classes/Pdef, Classes/Tdef, Classes/Pdefn, Classes/Ndef
6 description::
7 Placeholder for functions to calculate with.
9 See also: link::Classes/Maybe:: and the link::Overviews/JITLib:: overview.
11 ClassMethods::
13 private::initClass
15 method::new
17 argument::name
18 if no instance exists with this name, create a new one, otherwise return the existing one.
20 argument::func
21 If func is given, replace the old func with the new one.
23 Examples::
25 code::
26 Fdef(\x, { 8 + 9 });
28 Fdef(\y, Fdef(\x) - 3);
30 Fdef(\y).value;
32 Fdef(\x, 3);
34 Fdef(\y).value;
36 Fdef(\x, { |x=0| x });
39 Fdef(\x).value(8);
41 Fdef(\y).value(8);
44 z = Fdef(\x) * Fdef(\y) + { 1.0.rand };
46 z.value;
47 z.value(400);
50 code::
51 // sound example
53 s.boot;
54 SynthDef("gpdef",
55         { arg out=0, freq=440, sustain=0.05, amp=0.1;
56                 var env;
57                 env = EnvGen.kr(Env.perc(0.01, sustain), doneAction:2) * amp;
58                 Out.ar(out, SinOsc.ar(freq, 0, env))
59         }).add;
62 // fork a thread that plays some sounds
64 Fdef(\freq, 440);
65 Fdef(\dur, 0.2);
67 fork {
68         loop {
69                 s.sendMsg("/s_new", "gpdef", -1, 1,1, \freq, Fdef(\freq).value);
70                 Fdef(\dur).value.wait;
71         }
75 // some modifications
77 Fdef(\freq, Fdef(\midinote, 60).midicps);
78 Fdef(\midinote, { [67, 64, 65].choose });
79 Fdef(\midinote, { [67, 64, 65].choose } + Fdef(\offset));
80 Fdef(\offset, { 4.rand });
81 Fdef(\dur, 0.23);