File: the_lazy_proxy.schelp

package info (click to toggle)
supercollider 1%3A3.6.6~repack-2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 23,792 kB
  • ctags: 25,269
  • sloc: cpp: 177,129; lisp: 63,421; ansic: 11,297; python: 1,787; perl: 766; yacc: 311; sh: 286; lex: 181; ruby: 173; makefile: 168; xml: 13
file content (112 lines) | stat: -rw-r--r-- 2,785 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
title:: the_lazy_proxy
summary:: the lazy proxy
categories:: Libraries>JITLib>Tutorials
related:: Overviews/JITLib, Classes/NodeProxy, Classes/ProxySpace

The class link::Classes/NodeProxy:: (and link::Classes/BusPlug::) uses a lazy evaluation scheme to derive its appropriate rate and numChannels from the first meaningful input that is assigned to it. see link::Classes/NodeProxy:: and link::Classes/ProxySpace:: helpfiles for basic info. So as long as the source is not set, the proxy is strong::neutral:: :

code::
p = ProxySpace.push;
~x.isNeutral;
::

as soon as the first time the source is set, it derives its bus arguments from that input

code::
~x = { Array.fill(14, { SinOsc.kr(1.0.rand, 0, 100) }) }; //~x is now 14 channels control rate
~x;
::

in order to reset these properties, clear is used:

code::
~x.clear;
//note that no other proxy should be reading from ~x when this is done:
//for simplicity nodeproxy currently does not care for its children, only for its parents.
::

for a quick initialisation, also code::defineBus:: can be used:

code::
~x.defineBus(\control, 5);
// or in another way:
~x.kr(5)
::

the properties are also set when some other proxy reads from it:

code::
~x = { LFPulse.kr * ~b.kr(7) }; //the first arg to kr / ar is the default number of channels
::

if no number of channels is passed in, the default value is used:

code::
~test.ar; // 2
~krtest.kr; // 1
::

the default can be set in the class NodeProxy:

code::
NodeProxy.defaultNumAudio = 3;
NodeProxy.defaultNumControl = 13;

~test3.ar; // 3
~krtest3.kr; // 13

// set them back:
NodeProxy.defaultNumAudio = 2;
NodeProxy.defaultNumControl = 1;
::

also if a proxy is used as a map source, control rate is assumed:

code::
~u;
~x.map(\zzz, ~u);
~u;
::

when unary or binary operations are performed, the highest rate / numChannels is used to initialize all uninitialized proxies:

code::
~x.clear;
~x.defineBus(\control, 5);
~x = ~e + ~f;

~x.clear; ~e.clear; ~f.clear;
~e.defineBus(\audio, 1);
~x = ~e + ~f.squared + ~r;
~x;

~x.clear; ~e.clear; ~f.clear;
~e.defineBus(\audio, 3);
~x = ~e;
::

if a rate-1 proxy is used as rate-2 input, the rate is converted and the channels are expanded in the ususal multichannel expansion pattern:

code::
~f.defineBus(\control);
~f.ar(2);

~f.defineBus(\audio);
~f.kr(2);

// if the number of channels passed in is less, it only uses the first n channels
~f.defineBus(\audio, 8);
~f.ar(2);
::

an offset can be passed in as second argument to ar/kr

code::
//modulate offset:
p = ProxySpace.push(s.boot);

~out.play;
~src = { SinOsc.ar(Array.rand(5, 400, 500.0), SinOsc.ar(Array.exprand(5, 2.1, 500.0)), 0.1) };
~out = { ~src.ar(1, MouseX.kr(0, 5)) };
~out = { Mix(~src.ar(3, MouseX.kr(0, 5))) }; //the wrapping offset is moved accordingly
::