Possible with data sharing between patterns in ProxySpace?

I tried this:

~proxyspace = Pbind(\instrument,…).collect({|ev| ~event = ev});
~proxyspace.play;

There is activity in the node tree but no sound. Not sure how to go about if I want to “communicate” between patterns

What you’re doing is totally correct - if you have no sound, the problem isn’t related to what you’re posting. If I do the above with a basic Pbind like:

Pbind(\instrument, \default)

I hear notes when playing this - maybe you can diagnose by starting with that, and then introducing keys from your original pattern until you stop hearing sound?

You may also be having problems if you’re using ProxySpace (guessing because of the variable name :slight_smile: ). ProxySpace converts everything assigned to an ~environmentVariable into a Synth - this SHOULD work with a Pbind, but there may be some unexpected behavior details that change vs a “plain” Pbind play case. And, your ~event = assignment when using a ProxySpace is almost definitely not going to work as you want it to - you simply can’t really use ~environmentVariables as regular value “storage” when using ProxySpace.

Regarding sharing between patterns: your approach is exactly correct. You can also use Pchain / the compose operator <> to write this — as an example:

~eventLog = List();
~processEvent = Pfunc({
    |ev|
    ~eventLog.add(ev);
    ev;
});

~patternA = ~processEvent <> Pbind(...);
~patternB = ~processEvent <> Pbind(...);
~patternA.play; ~patternB.play;

Thanks for the reply. Sorry if I wasn’t making myself clear. The naming of the variable was just a
stupid effort to show that I wanted this to work in proxyspace.
I can get it to work outside of ProxySpace. Not sure if I understand your example correctly.
Is this in ProxySpace? And how do I get access to a certain arg from another pattern?

If you want this to work in a ProxySpace, you’ll need to store your values like ~event somewhere other then in the ProxySpace. This becomes a little difficult, since ProxySpace takes over all ~environmentVariable get/sets while it is active.

One solution: you can make use of the single-letter “global” interpreter variables to keep track of another environment, and use this to store your data. This example assumes you’re in a ProxySpace, and should work correctly.

e = (); // an Event

~pattern1 = Pbind().collect({
    |ev|
    e[\lastEvent] = ev;
});

// And from another pattern
~pattern2 = Pbind().collect({
   |ev|
   ev[\octave] = e[\lastEvent][\octave] // set the oct of pattern2 to the last oct of pattern1
});

The use syntax makes it possible to use ~environmentVariable notation for this also:

e.use { ~lastEvent = ev }

This works because use temporarily makes e the current environment instead of your ProxySpace.

Incidentally, the fact that you lose the ability to use ~environmentVariables “normally” when using ProxySpaces is the reason I originally stopped using them. If you’re not totally set on ProxySpace’s, Pdef provides exactly the same behavior and a syntax that is 95% as simple, but without the problem of losing env vars.

I don’t have enough skills to decide which is the best. I am pretty comfortable with Pbinds but routing to effects gets pretty messy even if I know how. That’s what I like in ProxySpace, that It takes care of the headache of routing and lets one be more spontaneous. And everything is in sync. But maybe I should just put in some more time working with Pdef. Just curious why did you choose Pdefs instead of Pbindefs?

If you’re open to trying out quarks and extensions, I’d recommend looking into Alga. It’s sort of like a cross between regular and ProxySpace. It allows for pretty easy node creation and parameter/modulation mapping by handling the routing behind the scenes, and has full interpolation when changing settings. It also has good pattern abilities, allowing for mixing node work with typical pattern use and routing and etc, though in in a slightly different format than Pbind.

I’ve only just begun using it, but it seems to allow for very straight forward data sharing between nodes and patterns.

2 Likes

Instead of ProxySpace, you can also use Ndef for named nodeproxies,
then they work like Pdef and Tdef, and you can use environment variables normally.

thanks will look into it! But not sure if I want to introduce another language

Maybe I should go back trying to learn Ndef again, it looked quite similar to ProxySpace

you can create and use a ProxySpace without pushing it to the current environment

the first example in the help file shows how to use a ProxySpace object like any other object in sc
https://doc.sccode.org/Classes/ProxySpace.html

These are exactly the same, just different ways of writing them:

// inside a pushed proxy space:
p = ProxySpace.new.push;
~out.play; // monitor an empty placeholder through hardware output
// set its source
~out = { SinOsc.ar([350, 351.3], 0, 0.2) };
~out = { Pulse.ar([350, 351.3] / 4, 0.4) * 0.2 };
~out = Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350));

p.clear.pop; // pop to leave

// same with Ndef
Ndef(\a).play; // play to hardware output.
Ndef(\a).fadeTime = 2; // fadeTime specifies crossfade
// set the source
Ndef(\a, { SinOsc.ar([350, 351.3], 0, 0.2) });
Ndef(\a, { Pulse.ar([350, 351.3] / 4, 0.4, 0.2) });
Ndef(\a, Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350)));

// proxyspace with at, put ( pushed or not)
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));

p.clear;

// plain nodeproxy outside proxyspace

a = NodeProxy.new.play; // play to hardware output.
a.fadeTime = 2; // fadeTime specifies crossfade
// set the source
a.source = { SinOsc.ar([350, 351.3], 0, 0.2) };
a.source = { Pulse.ar([350, 351.3] / 4, 0.4) * 0.2 };
a.source = Pbind(\dur, 0.03, \freq, Pbrown(0, 1, 0.1, inf).linexp(0, 1, 200, 350));