I have two synths that make use of the DynKlank UGen. In the first, the resonant frequencies, amplitudes and ring times are fixed; in the second the synth is initialised with empty arrays. At the moment both these synths are addressed each by its own Pbind. The two Pbinds are very similar except that in the second the resonant frequencies, amplitudes and ring times are supplied within its respective pattern.
For the sake of brevity I would like to combine the two patterns; this is proving to be a challenge. Put simply: I would like to bind or leave out pattern parameters according to the result of a conditional thus:
Pbind(
\instrument [instA, instB].choose,
\param2, value,
\param3, value,
\param4, value,
\resonantFreqs, Pfunc(|e| (e[\instrument] == instA).if{
\dkFreqs, value;
\dkAmps, value;
\dkRT, value}{'return dummy value'},
\param6, value,
etc........
})
When I’ve tried the above I have not been able to get the results of the conditional to return their values. i.e.in the above example dkFreqs returns nil. I have tried various method to accomplish this including inserting variables into the environment at a higher level but everything I’ve come with results in more complications than simply repeating the two Pbinds in full. I want to code DRY. Is there an elegant way of achieving this? Thanks…