ProxySpace:
Filter:
Classes | Libraries > JITLib > Environments | Live Coding | Collections > Unordered

ProxySpace : LazyEnvir : EnvironmentRedirect : Object

an environment of references on a server

Description

Generally a proxy is a placeholder for something. A node proxy is a placeholder for something playing on a server that writes to a limited number of busses (e.g. a synth or an event stream). NodeProxy objects can be replaced and recombined while they play. Also they can be used to build a larger structure which is used and modified later on. Overview: JITLib

When accessed, ProxySpace returns a NodeProxy. A similar class without environment: Ndef

For more examples see: ProxySpace examples, jitlib_basic_concepts_01

For GUI overview, see ProxyMixer. See NodeProxy for many relevant methods.

First Example

s.boot;

p = ProxySpace.new;
p.fadeTime = 2; // fadeTime specifies crossfade
p[\out].play; // monitor an empty placeholder through hardware output
// set its source
p[\out] = { SinOsc.ar([350, 351.3], 0, 0.2) };
p[\out] = { Pulse.ar([350, 351.3] / 4, 0.4) * 0.2 };
p[\out] = Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350));

// route one proxy through another:
p[\out] = { Ringz.ar(p[\in].ar, [350, 351.3] * 8, 0.2) * 4 };
p[\in] = { Impulse.ar([5, 7]/2, [0, 0.5]) };

a.clear(3); // clear after 3 seconds
b.clear(3);

Class Methods

Creation

ProxySpace.new(server, name, clock)

Arguments:

server

a Server object. Note that on remote computers the clock must be in sync.

name

a Symbol. If a name is given, the proxy space is stored in ProxySpace.all under this name.

clock

for event-based or beat-sync playing use a TempoClock.

ProxySpace.push(server, name, clock)

replace the currentEnvironment with a new ProxySpace and clear the current one, if it is a ProxySpace (this is to avoid piling up proxy spaces).

In order to move to another ProxySpace while keeping the current, use pop and then push a new one. To have multiple levels of proxy spaces, use .new.push;

ProxySpace.pop

From superclass: EnvironmentRedirect

restore the previous currentEnvironment

ProxySpace.clearAll

clear all registered spaces

Inherited class methods

Undocumented class methods

ProxySpace.all

ProxySpace.all = value

ProxySpace.findSpace(proxy, getCode: false)

Instance Methods

Play back and access

.play(key: 'out', out: 0, numChannels: 2)

returns a group that plays the NodeProxy at that key.

Arguments:

key

a Symbol

out

output channel offset

numChannels

play this number of channels.

.record(key, path, headerFormat: "aiff", sampleFormat: "int16")

returns a RecNodeProxy that records the NodeProxy at that key.

.ar(key: 'out', numChannels, offset: 0)

.kr(key: 'out', numChannels, offset: 0)

returns a NodeProxy output that plays the NodeProxy at that key, to be used within a function used as input to a node proxy

.wakeUp

when the proxyspace is created without a running server this method can be used. To run it (internally this is done by -play as well).

.fadeTime

.fadeTime = dt

set the fadetime of all proxies as well as the default fade time

.clock

.clock = aClock

set the clock of all proxies as well as the default clock.

.quant

.quant = val

set the quant of all proxies as well as the default quant.

.free(fadeTime)

free all proxies (i.e. free also the groups, do not stop the monitors)

.release(fadeTime)

release all proxies (i.e. keep the groups running)

.stop(fadeTime)

stop all proxies (stop only monitors, do not stop synths)

.end(fadeTime)

end all proxies (free and stop the monitors)

.clear(fadeTime)

clear the node proxy and remove it from the environment. this frees all buses. If a fadeTime is given, first fade out, then clear.

.add

add the ProxySpace to the repository (name required)

.remove

remove the ProxySpace from the repository

Setting the sources

The rate and numChannels of the NodeProxy determined in a lazy way from the first object put into this environment (see helpfile). Once it is created it can only be set to a function that returns the same rate and a number of channels equal to the intial one or smaller. For details, see the_lazy_proxy.

.put(key, obj)

From superclass: LazyEnvir

Gets the NodeProxy at key (if none exists, returns a new one) and sets its source to obj. For how this works, see also LazyEnvir and NodeProxy.

.at(key)

From superclass: LazyEnvir

Return the proxy source object at that key.

garbage collecting

.clean(excluding)

free and remove all proxies that are not needed in order to play the ones passed in with 'exclude'. if none are passed in, all proxies that are monitoring (with the .play message) are kept as well as their parents etc.

.reduce(excluding, method: 'end')

free all proxies that are not needed in order to play the ones passed in with 'to'. if none are passed in, all proxies that are monitored (with the play message) are kept as well as their parents etc.

making copies

.copy

Copies the environment into a new one, with each proxy being copied as well (See: NodeProxy: -copy). Also the instance variables that determine the ProxySpace behaviour are included, such as server, fadeTime, quant, reshaping (this happens in the copyState method).

p = ProxySpace.push(s.boot);
p.reshaping = \elastic;
~out.play;
~out = { Blip.ar(~freq, ~numharm) };
~freq = 70;
~numharm = { MouseX.kr(2, 100, 1) };

q = p.copy; p.pop; q.push;

q.reshaping.postln; // also elastic
~out.play;
~freq = { MouseY.kr(2, 1000, 1) * [1, 1.2] };

p.end; q.end;

Writing code

.document(keys, onlyAudibleOutput: false, includeSettings: true)

From extension in /Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/JITLib/ProxySpace/extStoreOn.sc

creates a new document with the current proxyspace state. This does not allow open functions as proxy sources. see: jitlib_asCompileString.

Arguments:

keys

list of keys to document a subset of proxies

onlyAudibleOutput

a boolean.

includeSettings

a boolean.

Inherited instance methods

Undocumented instance methods

.activeProxies

.arProxyNames(func: true)

.asCode

From extension in /Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/JITLib/ProxySpace/extStoreOn.sc

.awake

.awake = flag

.copyState(proxySpace)

.doFunctionPerform(selector)

.doOnServerBoot(server)

.doOnServerQuit(server)

.documentOutput

From extension in /Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/JITLib/ProxySpace/extStoreOn.sc

.existingProxies

.gcList(excluding)

.getStructure(keys, excluding)

.group

.group = node

.gui(numItems, bounds, preset)

From extension in /Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/JITLib/GUI/extJITgui.sc

.includes(proxy)

.initProxy(proxy)

.krProxyNames(func: true)

.makeProxy

.makeTempoClock(tempo: 1, beats, seconds)

.monitors

.name

.name = argName

.playingProxies

.postln

.proxyNames(rate, func: true)

.registerServer

.removeNeutral

.reshaping

.reshaping = val

.server

.size

.unregisterServer

Examples

// ProxySpace returns instances of NodeProxy:
a = NodeProxy(s)     is equivalent to ~a;
a.source = ...        is equivalent to ~a = ...
a[3] = ...        is equivalent to ~a[3] = ...

// the two expressions are equivalent:
~out = something;
currentEnvironment.put(\out, something);
// examples

p = ProxySpace.push(s.boot); // use ProxySpace as current environment.

~out.play;

~out = { SinOsc.ar([400, 407] * 0.9, 0, 0.2) };

~out = { SinOsc.ar([400, 437] * 0.9, 0, 0.2) * LFPulse.kr([1, 1.3]) };

~out = { SinOsc.ar([400, 437] * 0.9, 0, 0.2) * ~x.kr(2) };

~x = { LFPulse.kr([1, 1.3] * MouseX.kr(1, 30, 1)) };

~out = { SinOsc.ar([400, 437] * Lag.kr(0.1 + ~x, 0.3), 0, 0.2) * ~x };

p.fadeTime = 5;

~out = { SinOsc.ar([400, 437] * 1.1, 0, 0.2) * ~x.kr(2) };

p.clear(8); // end and clear all in 8 sec.


p.pop; // move out.