This file is indexed.

/usr/share/SuperCollider/SCClassLibrary/JITLib/ProxySpace/wrapForNodeProxy.sc is in supercollider-common 1:3.6.3~repack-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
//these extensions provide means to wrap Objects so that they
//make sense within the server bus system according to a node proxy.

////////////////////// graphs, functions, numericals and arrays //////////////////

+Object {

	//objects can define their own wrapper classes dependant on
	//how they play, stop, build, etc. see SynthDefControl for example
	//the original (wrapped) object can be reached by the .source message
	//for objects that only create ugen graphs, define prepareForProxySynthDef(proxy)

	proxyControlClass {
		^SynthDefControl
	}

	makeProxyControl { arg channelOffset=0;
		^this.proxyControlClass.new(this, channelOffset);
	}


	//any preparations that have to be done to prepare the object
	//implement 'prepareForProxySynthDef' to return a ugen func


	//this method is called from within the Control
	buildForProxy { arg proxy, channelOffset=0, index;
		var argNames;
		argNames = this.argNames;
		^ProxySynthDef(
			SystemSynthDefs.tempNamePrefix ++ proxy.generateUniqueName ++ index,
			this.prepareForProxySynthDef(proxy),
			proxy.nodeMap.ratesFor(argNames),
			nil,
			true,
			channelOffset,
			proxy.numChannels,
			proxy.rate
		);
	}
	prepareForProxySynthDef { ^this.subclassResponsibility(thisMethod) }

	defaultArgs { ^nil }
	argNames { ^nil }

	//support for unop / binop proxy
	isNeutral { ^true }
	initBus { ^true }
	wakeUp {}

}


+Function {
	prepareForProxySynthDef { ^this }
	argNames { ^def.argNames }
	defaultArgs { ^def.prototypeFrame }
}

+AbstractFunction {
	prepareForProxySynthDef { ^{ this.value } }
}

+SimpleNumber {

	prepareForProxySynthDef { arg proxy;
		proxy.initBus(\control, 1);
		^{DC.multiNewList([proxy.rate] ++ this) };
	}
}

+Synth { // better information about common error
	prepareForProxySynthDef { arg proxy;
		Error(
			"A synth is no valid source for a proxy.\n"
			"For instance, ~out = { ... }.play would cause this and should be:\n"
			"~out = { ... }; ~out.play; or (~out = { ... }).play;"
		).throw;
	}
}

+RawArray {
	prepareForProxySynthDef { arg proxy;
		proxy.initBus(\control, this.size);
		^{DC.multiNewList([proxy.rate] ++ this) };
	}
}

+SequenceableCollection {
	prepareForProxySynthDef { arg proxy;
		proxy.initBus(\control, this.size);
		^{ this.collect({ |el| el.prepareForProxySynthDef(proxy).value }) }
		// could use SynthDef.wrap, but needs type check for function.
	}
}

+BusPlug {
	prepareForProxySynthDef { arg proxy;
		proxy.initBus(this.rate, this.numChannels);
		^{ this.value(proxy) }
	}

}

+AbstractOpPlug {
	prepareForProxySynthDef { arg proxy;
		proxy.initBus(this.rate, this.numChannels);
		^{ this.value(proxy) }
	}
}

//needs a visit: lazy init + channelOffset

+Bus {
	prepareForProxySynthDef { arg proxy;
		^BusPlug.for(this).prepareForProxySynthDef(proxy);
	}
}




///////////////////////////// SynthDefs and alike ////////////////////////////////////


+SynthDef {
	buildForProxy {}
	numChannels { ^nil } //don't know
	rate { ^nil }
}



+Symbol {
	buildForProxy {}
	proxyControlClass {
		^SynthControl
	}
}

///////////////////////////// Pattern - Streams ///////////////////////////////////


+Stream {
	proxyControlClass { ^StreamControl }
	buildForProxy { ^PauseStream.new(this) }
}

+PauseStream {
	buildForProxy { ^this }
	proxyControlClass { ^StreamControl }
}

+PatternProxy {
	buildForProxy { "a numerical pattern does not make sense here.".error; ^nil }
}

+TaskProxy {
	proxyControlClass { ^StreamControl }

	buildForProxy {  arg proxy, channelOffset=0;
		^PauseStream(this.endless.asStream
			<> (
				nodeProxy: proxy,
				channelOffset: channelOffset,
				server: { proxy.server },
				out: { proxy.index },
				group: { proxy.group }
			)
		)
	}
}

+EventPatternProxy {
	proxyControlClass { ^PatternControl }

	buildForProxy {  arg proxy, channelOffset=0;
		^this.endless.buildForProxy(proxy, channelOffset)
	}
}


+Pattern {
	proxyControlClass { ^PatternControl }

	buildForProxy { arg proxy, channelOffset=0;
		var player = this.asEventStreamPlayer;
		var event = player.event.buildForProxy(proxy, channelOffset);
		^event !? { player };
	}
}

+ Event {
	proxyControlClass { ^StreamControl }
	buildForProxy { arg proxy, channelOffset=0;
		var ok, index, server, numChannels, rate, finish;
		ok = if(proxy.isNeutral) {
			rate = this.at(\rate) ? 'audio';
			numChannels = this.at(\numChannels) ? NodeProxy.defaultNumAudio;
			proxy.initBus(rate, numChannels);
		} {
			rate = proxy.rate; // if proxy is initialized, it is user's responsibility
			numChannels = proxy.numChannels;
			true
		};
		^if(ok) {
				index = proxy.index;
				server = proxy.server;
				this.use({
					~channelOffset = channelOffset; // default value
					~out = { ~channelOffset % numChannels + index };
					~server = server; // not safe for server changes yet
					finish = ~finish;
					~group = { proxy.group.asNodeID };
					~finish = {
						finish.value;
						proxy.nodeMap.addToEvent(currentEnvironment);
						~group = ~group.value;
						~out = ~out.value;
					}
				});
				this
		} { nil }
	}
}



/////////// pluggable associations //////////////


+Association {
	buildForProxy { arg proxy, channelOffset=0, index;
		^AbstractPlayControl.buildMethods[key].value(value, proxy, channelOffset, index)
	}
	proxyControlClass {
		^AbstractPlayControl.proxyControlClasses[key] ? SynthDefControl
	}
}

+AbstractPlayControl {
	makeProxyControl { ^this.deepCopy } //already wrapped, but needs to be copied

	/* these adverbial extendible interfaces are for supporting different role schemes.
	it is called by Association, so ~out = \filter -> ... will call this. The first arg passed is 	the value of the association */

	*initClass {
		proxyControlClasses = (
			filter: SynthDefControl,
			xset: StreamControl,
			set: StreamControl,
			stream: PatternControl,
			setbus: StreamControl,
			setsrc: StreamControl
		);

		buildMethods = (

		filter: #{ arg func, proxy, channelOffset=0, index;
			var ok, ugen;
			if(proxy.isNeutral) {
				ugen = func.value(Silent.ar);
				ok = proxy.initBus(ugen.rate, ugen.numChannels);
				if(ok.not) { Error("NodeProxy input: wrong rate/numChannels").throw }
			};

			{ arg out;
				var e;
				e = EnvGate.new * Control.names(["wet"++(index ? 0)]).kr(1.0);
				if(proxy.rate === 'audio') {
					XOut.ar(out, e, SynthDef.wrap(func, nil, [In.ar(out, proxy.numChannels)]))
				} {
					XOut.kr(out, e, SynthDef.wrap(func, nil, [In.kr(out, proxy.numChannels)]))				};
			}.buildForProxy( proxy, channelOffset, index )

		},
		set: #{ arg pattern, proxy, channelOffset=0, index;
			var args;
			args = proxy.controlNames.collect(_.name);
			Pbindf(
				pattern,
				\type, \set,
				\id, Pfunc { proxy.group.nodeID },
				\args, args
			).buildForProxy( proxy, channelOffset, index )
		},
		xset: #{ arg pattern, proxy, channelOffset=0, index;
			Pbindf(
				pattern,
				\play, { proxy.xset(*proxy.controlNames.collect(_.name).envirPairs) }
			).buildForProxy( proxy, channelOffset, index )
		},
		setbus: #{ arg pattern, proxy, channelOffset=0, index;
			var ok = proxy.initBus(\control);
			if(ok.not) { Error("NodeProxy input: wrong rate").throw };
			Pbindf(
				pattern,
				\type, \bus,
				\id, Pfunc { proxy.group.nodeID },
				\array, Pkey(\value).collect { |x| x.keep(proxy.numChannels) },
				\out, Pfunc { proxy.index }
			).buildForProxy( proxy, channelOffset, index )
		},
		setsrc: #{ arg pattern, proxy, channelOffset=0, index=0;
			pattern.collect { |event|
				event[\type] = \rest;
				proxy.put(index + 1, event[\source]);
				event
			}.buildForProxy( proxy, channelOffset, index );
		},
		control: #{ arg values, proxy, channelOffset=0, index;
			{ Control.kr(values) }.buildForProxy( proxy, channelOffset, index );
		},
		filterIn: #{ arg func, proxy, channelOffset=0, index;
			var ok, ugen;
			if(proxy.isNeutral) {
				ugen = func.value(Silent.ar);
				ok = proxy.initBus(ugen.rate, ugen.numChannels);
				if(ok.not) { Error("NodeProxy input: wrong rate/numChannels").throw }
			};

			{ arg out;
				var in;
				var egate = EnvGate.new;
				var wetamp = Control.names(["wet"++(index ? 0)]).kr(1.0);
				var dryamp = 1 - wetamp;
				if(proxy.rate === 'audio') {
					in = In.ar(out, proxy.numChannels);
					XOut.ar(out, egate, SynthDef.wrap(func, nil,
						[in * wetamp]) + (dryamp * in))
				} {
					in = In.kr(out, proxy.numChannels);
					XOut.kr(out, egate, SynthDef.wrap(func, nil,
						[in * wetamp]) + (dryamp * in))
				};
			}.buildForProxy( proxy, channelOffset, index )
		},

		mix: #{ arg func, proxy, channelOffset=0, index;

			{ var e = EnvGate.new * Control.names(["mix"++(index ? 0)]).kr(1.0);
				e * SynthDef.wrap(func);
			}.buildForProxy( proxy, channelOffset, index )
		};

		)
	}
}