File: Neuromodules.sc

package info (click to toggle)
supercollider-sc3-plugins 3.13.0~repack-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 20,104 kB
  • sloc: cpp: 303,352; lisp: 9,589; ansic: 3,547; sh: 96; makefile: 87; haskell: 21
file content (58 lines) | stat: -rw-r--r-- 1,365 bytes parent folder | download | duplicates (5)
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
MultiOutDemandUGen : DUGen {
	// a class for UGens with multiple outputs
	var <channels;

	*newFromDesc { arg rate, numOutputs, inputs;
		^super.new.rate_(rate).inputs_(inputs).initOutputs(numOutputs, rate)
	}

	initOutputs { arg numChannels, rate;
		if(numChannels.isNil or: { numChannels < 1 }, {
			Error("%: wrong number of channels (%)".format(this, numChannels)).throw
		});
		channels = Array.fill(numChannels, { arg i;
			OutputProxy(rate, this, i);
		});
		if (numChannels == 1, {
			^channels.at(0)
		});
		^channels
	}

	numOutputs { ^channels.size }
	writeOutputSpecs { arg file;
		channels.do({ arg output; output.writeOutputSpec(file); });
	}
	synthIndex_ { arg index;
		synthIndex = index;
		channels.do({ arg output; output.synthIndex_(index); });
	}
}


Dneuromodule : MultiOutDemandUGen {

	*new { |numChannels, theta, x, weights|
		^super.multiNew(\demand, *[numChannels] ++ theta ++ x ++ weights )
	}

	*ar { |dt, numChannels, theta, x, weights|
		^Duty.ar(dt, 0, this.new(numChannels, theta, x, weights))
	}

	*kr { |dt, numChannels, theta, x, weights|
		^Duty.ar(dt, 0, this.new(numChannels, theta, x, weights))
	}

	init { arg numChannels ... theInputs;
		inputs = [numChannels] ++ theInputs;
		channels = numChannels.collect { |i|
			OutputProxy(rate, this, i)
		};
		^channels
	}
	checkInputs { ^this.checkNInputs(1) } // TODO: check.

}