1 // a Ref is a handle to a value. you can use it to return results by reference
4 // z = obj.method(x); // method puts something in reference
5 // x.value.doSomething; // retrieve value
7 // it is also used as a quoting device to insulate from multiChannelPerform in UGens
9 // A special syntax shortcut for Ref.new( expr ) is to use a backquote: `expr
11 Ref : AbstractFunction
14 *new { arg thing; ^super.new.value_(thing) }
15 set { arg thing; value = thing }
17 dereference { ^value }
21 valueArrayEnvir { ^value }
23 // behave like a stream
25 // embedInStream { arg inval;
26 // ^this.value.embedInStream(inval)
28 // prevent multichannel expansion in ugens
32 stream << "`(" << value << ")";
35 stream << "`(" <<< value << ")";
37 at { | key | ^value.at(key) }
38 put { | key, val | value.put(key, val) }
39 seq { | pat | value = pat.embedInStream(this) }
40 asControlInput { ^value.asControlInput }
42 // Some UGens take Buffer data which
43 // the user might want to specify simply as `[0.9, 0.1, 0.3]
45 ^LocalBuf.newFrom(value);
48 // Allow to multichannel expand ugen specs, like those of Klank,
49 // in the case of which two is the rank, but could be otherwise.
50 multichannelExpandRef { |rank|
52 array = this.value.asArray;
53 if(array.maxSizeAtDepth(rank) <= 1) { ^this }; // no need to expand
54 refarray = array.flopDeep(rank).collect { |item| this.class.new(item) };