I’m looking for the right way to repeat input stream values until shifting Pseg reaches the end of its Env. It may not be very clear from the question what I mean, so below is a specific example. Сan someone guide me to do that? Thx
(
p = Pbind(
\instrument, \default,
\dur, Pseg(
[0.2, 0.4, 0.2],
[3.0, Pwhite(5.0, 10.0, inf)],
'cubed', inf),
\freq, ? // There should be a pattern here that produces the same value n times until Pseg reaches its end, and then the value changes on the next cycle
);
)
p.play;
Fantasize of something like Pdup but instead of the number of repetitions, it repeats value for a certain time.
Here’s another approach (not better or worse, just different): Pseg plays once. This goes into a Pbind with \freq – so now, when Pseg ends, so does \freq. Then \freq can be defined with a forever sample-and-hold pattern – “forever,” but it will be interrupted when Pseg ends. The asStream maintains continuity of the frequency stream across Pseg cycles.
Then you can Pchain other parameters onto that.
(
p = Pchain(
Pbind(
\instrument, \default,
// just to show that this stream is independent
// of the dur-freq grouping
\pan, Pseq([-0.6, 0.6], inf)
),
Pn(
Pbind(
\dur, Pseg(
[0.2, 0.4, 0.2],
[3.0, Pwhite(5.0, 10.0, inf)],
'cubed', 1
),
\freq, Pstep(Pseries(100, 50, inf).asStream, inf, inf)
),
inf
)
).play;
)
(Note that I moved play – IMO it’s not a good habit to have a freestanding p.play because you lose access to the EventStreamPlayer – you can no longer stop it in code. The result of .play should be saved in the variable, rather than the source.)
Thank you all @droptableuser, @PitchTrebler, @jamshark70. All of these solutions are practicable and I will definitely remember them for improving my toolset.
This is a good advice @jamshark70. Thanks for pointing out. That habit comes from using ~p = Pbind in ProxySpace, where it wraps into NodeProxy.