File: Ref.sc

package info (click to toggle)
supercollider 1%3A3.4.5-1wheezy1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 26,972 kB
  • sloc: cpp: 116,645; lisp: 64,914; ansic: 10,725; python: 3,548; perl: 766; ruby: 487; sh: 152; makefile: 117; xml: 13
file content (54 lines) | stat: -rw-r--r-- 1,303 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
50
51
52
53
54

// a Ref is a handle to a value. you can use it to return results by reference
// example:
//		x = Ref.new(nil);
// 		z = obj.method(x); // method puts something in reference
//		x.value.doSomething; // retrieve value
//
// it is also used as a quoting device to insulate from multiChannelPerform in UGens
//
// A special syntax shortcut for Ref.new( expr ) is to use a backquote: `expr

Ref : AbstractFunction
{
	var <>value;
	*new { arg thing; ^super.new.value_(thing) }
	set { arg thing; value = thing }
	get { ^value }
	dereference { ^value }
	asRef { ^this }
	valueArray { ^value }
	valueEnvir { ^value }
	valueArrayEnvir { ^value }

	// behave like a stream
	next { ^value }
//	embedInStream { arg inval;
//		^this.value.embedInStream(inval)
//	}
	// prevent multichannel expansion in ugens
	asUGenInput { ^this }

	printOn { arg stream;
		stream << "`(" << value << ")";
	}
	storeOn { arg stream;
		stream << "`(" <<< value << ")";
	}
	at { | key | ^value.at(key) }
	put  { | key, val | value.put(key, val) }
	seq { | pat | value = pat.embedInStream(this) }
	asControlInput { ^value.asControlInput }

	// Some UGens take Buffer data which
	// the user might want to specify simply as `[0.9, 0.1, 0.3]
	asBufWithValues {
		^LocalBuf.newFrom(value);
	}
}

RefCopy : Ref
{
	next { ^value.copy }
}