How to retreive values from a specific pair in a running Pbind by referng to it by its key?

I have a pbind running and would like to access the values from a part of the Stream only and not the whole Pbind. In the example below I want only the values of the substream “\x”. When evaluating “” it returns all 3 values of \x \y and \zzz. How could I access only the values from a desired pair by using the key?

a = Pbind(\x, Pseq([1, 2, 3]), \y, Prand([100, 300, 200], inf), \zzz, 99);
x = a.asStream;

Ideally something like what; does but not returnign all pairs just the desired pair \x so I can then use the results of the Pseq([1, 2, 3])
indent preformatted text by 4 spaces
thank you

This returns the event (a bit confusing as you named the Stream like the key value you want to get). To get the value from the Event use the ‘at’ method, e.g.[\x]

Then the other key streams are forwarded as well though.

@dkmayer Thank you for your answer, that was really helpful but I realized it wasn’t exactly what I needed! Also sorry for naming the stream the same as the key-value btw, that was indeed confusing…

Would it be possible to retrieve multiple values from the same event without the other key streams being forwarded as well?

basically what I want to do is the following:

I have a Synthdef/Ndef with some arg as inputs.
I would like to use a pbind to change the Synthdef/Ndef’s arguments using “set” so I need to access the values of all the key streams at the same time. “[\x]” gives access but as you said it forwards the other streams as well since a new event is being made. Ideally, I need separate access to the other key streams of the same event and when retrieved, then move to the next event to then again retrieve the next values and so on… Is there a way for this? Basically, I want to use Pbind just to generate numbers and then use those numbers to set arguments of Synths. I do not want to connect the Pbind to the Synth directly, I just need to pass key values from the same event of a Pbind to a synth

thank you!

No, not with Pbind. It simply isn’t designed for random access. I think Pbind will never support your intended use case.

I think there’s no class for this in the main library. Maybe someone has written an extension. Otherwise, you’d have to write your own class.


What about an Event of Streams?

d = (
	x: Pseq([1, 2, 3], inf),
	y: Pseq([4, 5, 6], inf),
	z: 99

#[x, y].collect { |v| d[v].next }

The values could itself be event streams.

thank you @dkmayer and @jamshark70 for your answers!
The Event of Streams seems to work on itself but when I try to use it for “set” on a synth and add some more streams there is a weird behaviour with the synth. I will try to sort it out!

thanx again!