2 summary:: node proxy definition
3 categories:: Libraries>JITLib>NodeProxy
4 related:: Classes/ProxySpace, Classes/Tdef
7 Reference to a proxy, forms an alternative to link::Classes/ProxySpace::. All methods are inherited from link::Classes/NodeProxy::.
10 Ndef(key) //returns the instance
11 Ndef(key, obj) //stores the object and returns the instance, like Tdef and Pdef.
14 Graphical editor overviewing all current Ndefs: link::Classes/NdefMixer::. A general overview: link::Overviews/JITLib::.
16 subsection::First Example
21 Ndef(\a).play; // play to hardware output.
22 Ndef(\a).fadeTime = 2; // fadeTime specifies crossfade
24 Ndef(\a, { SinOsc.ar([350, 351.3], 0, 0.2) });
25 Ndef(\a, { Pulse.ar([350, 351.3] / 4, 0.4) * 0.2 });
26 Ndef(\a, Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350)));
28 Ndef(\a, { Ringz.ar(Ndef.ar(\b), [350, 351.3] * 8, 0.2) * 4 });
29 Ndef(\b, { Impulse.ar([5, 7]/2, [0, 0.5]) });
31 Ndef.clear(3); // clear all after 3 seconds
41 Return a new node proxy and store it in a global ProxySpace under the key. If there is already an Ndef there, replace its object with the new one. The object can be any supported class, see link::Classes/NodeProxy:: help.
44 If key is an association, it is interpreted as strong::key -> server name::. (order changed in SC3.3 !). If no name is given, it uses the default server that was default when Ndef was first called. (to change it, see link::#*defaultServer::).
47 equivalent to code::*new(key).ar(numChannels, offset):: (see link::Classes/NodeProxy:: help for ar method)
50 equivalent to code::*new(key).kr(numChannels, offset):: (see link::Classes/NodeProxy:: help for kr method)
56 set the default server (default: code::Server.default::)
59 Return the dictionary of all servers, pointing to proxyspaces with Ndefs for each.
66 Return the proxyspace for a given server.
78 Ndef(\sound).fadeTime = 1;
79 Ndef(\sound, { SinOsc.ar([600, 635], 0, SinOsc.kr(2).max(0) * 0.2) });
80 Ndef(\sound, { SinOsc.ar([600, 635] * 3, 0, SinOsc.kr(2 * 3).max(0) * 0.2) });
81 Ndef(\sound, { SinOsc.ar([600, 635] * 2, 0, SinOsc.kr(2 * 3).max(0) * 0.2) });
82 Ndef(\sound, Pbind(\dur, 0.17, \freq, Pfunc({ rrand(300, 700) })) );
84 Ndef(\lfo, { LFNoise1.kr(3, 400, 800) });
85 Ndef(\sound).map(\freq, Ndef(\lfo));
86 Ndef(\sound, { arg freq; SinOsc.ar([600, 635] + freq, 0, SinOsc.kr(2 * 3).max(0) * 0.2) });
87 Ndef(\lfo, { LFNoise1.kr(300, 400, 800) });
89 Ndef.clear; //clear all
92 subsection::Simple audio routing with the <<> operator
98 \in1.ar([0, 0]) * \in2.ar([0, 0]),
105 Ndef(\a, { SinOsc.ar(MouseX.kr(300, 1000, 1) * [1, 1.2], \phase.ar([0, 0]) * 0.2) });
106 Ndef(\b, { LFDNoise3.ar(MouseY.kr(3, 1000, 1) * [1, 1.2]) });
107 Ndef(\c, { LFTri.ar(MouseY.kr(3, 10, 1) * [1, 1.2]).max(0) });
109 Ndef(\sound) <<>.in1 Ndef(\a);
110 Ndef(\sound) <<>.in2 Ndef(\b);
111 Ndef(\sound) <<>.in2 Ndef(\c);
112 Ndef(\a) <<>.phase Ndef(\sound);
113 Ndef(\a) <<>.phase nil; // unmap
114 Ndef.clear(3); // clear all Ndefs
117 subsection::Recursion
119 Ndefs can be used recursively. A structure like the following works:
122 Ndef(\sound, { SinOsc.ar([600, 635], Ndef.ar(\sound) * 10, LFNoise1.kr(2).max(0) * 0.2) });
126 This is because there is a feedback delay (the server's strong::block size::), usually 64 samples, so that calculation can reiterate over its own outputs. For single sample feedback, see:
129 Document.open("Examples/demonstrations/single_sample_feedback.scd")
132 subsection::Using different servers
135 // create a new server
136 a = Server(\foo, NetAddr("127.0.0.1", 57123)).boot.makeWindow;
137 Ndef(\sound, { SinOsc.ar([600, 635]) * SinOsc.kr(2).max(0) * 0.2 }).play; // play on default
138 Ndef(\sound -> \foo, { SinOsc.ar([700, 745]) * SinOsc.kr(2).max(0) * 0.2 }).play;// play on foo
141 Ndef(\sound -> \foo).clear(3);
142 Ndef(\sound).clear(3);
148 // create a window for a given Ndef
151 Ndef(\sound, { |freq = 440, rate = 2|
152 SinOsc.ar(freq * [1, 1.625]) * SinOsc.kr(rate).max(0) * 0.2
156 // set lags for controls:
157 Ndef(\sound).lag(\freq, 0.2, \rate, 0.5);
159 // create a mixer for all Ndefs:
163 subsection::Using Associations
165 For a complete list, see link::Classes/NodeProxy::, and link::Reference/NodeProxy_roles::
171 \setsrc -> Pbind(\source,
173 { LFTri.ar(280 * Line.kr(1.1, 0.4, rrand(2, 3)) + [0,1]) * 0.1 },
174 { Pulse.ar(40 + [0,1]) * 0.1 },
175 { LFTri.ar(LFTri.kr(1).round(1.0.rand) + 1 * 180 + [0,1], 0.04) * 0.3 },
177 \dur, Prand([3, 2, 4], inf)