I should add here that PLbindef
from misc lib implements this sort of “duality” between events/environments and Pbinds. Quoting some example from its help page:
(
PLbindef(\x,
\instrument, \sin_grain,
\dur, 0.2,
\midinote, Pwhite(60, 90)
)
)
// PLbindefEnvironment has been made and assigned to the variable ~x in currentEnvironment, check
~x
// now the PLbindefEnvironment can also be treated as a player
~x.play
// set params while playing
~x.att = Pwhite(0.01, 0.2)
Implementation-wise
PLbindefEnvironment : Environment { var <name, <plbindef; //...
PLbindef : Pbindef { var <sourceEnvir, <refEnvir; //...
where sourceEnvir
is a PLbindefEnvironment
.
PLbindefEnvironment
is actually affected by the bug/feature/optimization discussed here if one were to actually access those sub-fields via use
(i.e. ~x.use { ~att = ... }
. But the help example[s] don’t do that, instead they “save typing” by using one-letter environment variables for the PLbindefEnvironments… (which of course isn’t saving typing compared to use
if there are more than a couple of fields to set.)
As far as I can tell, there’s no direct composition implemented for PLbindefEnvironment
s, one has to do it via the PLbindef
s.