FWIW – I just added temporary SynthDef caching for Plugs based on functions.
Before today’s change, the following pattern would generate a new SynthDef for the Plug for every event. With the change, only the first event creates a SynthDef and the rest reuse the same one.
(
p = Pbind(
\type, \syn,
\instrument, \default,
\freq, Pexprand(200, 500, inf),
\freqPlug, { |freq|
// closed function here, possible to hit cache
Plug({ |freqSynthArg|
freqSynthArg * LFDNoise3.kr(3).exprange(0.95, 1.05)
}, [freqSynthArg: freq])
},
\dur, Pexprand(0.2, 0.8, inf),
\legato, Pexprand(0.7, 1.4, inf)
).play;
)
p.stop;
One usage had to be deprecated, though:
(
p = Pbind(
\type, \syn,
\instrument, \default,
\freq, Plug {
exprand(200, 500) * LFDNoise3.kr(3).exprange(0.95, 1.05)
},
\dur, Pexprand(0.2, 0.8, inf),
\legato, Pexprand(0.7, 1.4, inf)
).play;
)
Without caching, there’s a new exprand value per event. Now there’s only one, the first time. I think it’s a good trade-off, though, because, when Jordan’s improved SynthDefs optimizations land, it will be more expensive to build the same SynthDef repeatedly. Now it will skip the rebuild in common sequencing cases.
hjh