File: jitlib_asCompileString.schelp

package info (click to toggle)
supercollider 1%3A3.10.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 45,496 kB
  • sloc: cpp: 283,513; lisp: 74,040; ansic: 72,252; sh: 23,016; python: 7,175; makefile: 1,087; perl: 766; java: 677; yacc: 314; lex: 175; ruby: 136; objc: 65; xml: 15
file content (49 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download
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
title:: jitlib_asCompileString
summary:: asCompileString in JITLib
categories:: JITLib>Tutorials

code::
{ 10 + 6 * ~harry }.asCompileString;
::

many objects understand strong::.storeOn::, which a way to post their string that is needed to reproduce them by compilation. sometimes one wants to store a certain configuration of a proxy space, which can be done
if all functions used are closed functions.

code::
// an example how ProxySpace can document its current state:

p = ProxySpace.push(s);


(
~ctl1 = {
	var z = 1;
	4.do { |i| z = z * SinOsc.kr(i.sqrt, i+[0,0.2]) };
	z
};

~ctl2[0] = { LFNoise2.kr([20,20],20) };
~ctl2[1] = {
	LFNoise2.kr([20,20],20) * LFNoise0.kr([20,20],20)
};

~out = {
	SinOsc.ar(~freq.kr, 0, 0.1)
};

~freq[0] = { ~ctl1.kr(2) + ~ctl2.kr(2) + 400 };
~freq[5] = ~ctl1.wrap2(~ctl2) * ~ctl1 / (~ctl2 + ~ctl1);

~pat = Pbind(\freq, Pfunc({ 1.2.rand }));
~z = 9;
~out.set(\freq, 760, \ffreq, 20);
)

p.asCompileString;

// the document message creates a new document which it posts the code into

p.document;		// document everything
p.document([\out]); 	// document all dependants of ~out
p.document([\ctl1]);	// document all dependants of ~ctl1
::