Wondering if anyone has any workarounds for a side effect of the EnvGen initialization fix.
Creates a bit of a challenge for my Plug modulation approach.
So… you’ve got, for instance, a filter frequency input that is control rate.
Then you want to modulate this by a kr synth. (You don’t even have to use Plug specifically – just make a bundle playing both synths, and put a bus-mapping token in for filter frequency.)
The modulation synth maps an Env.perc onto a valid range for filter frequency, e.g. ffreq * (1 + (modFactor * eg))
. And, for flexibility, there is an attack and a release time parameter, so that you could do slow swells or attack-spike envelopes.
The envelope used to start too high – which was (oddly enough) an advantage for generating attack spikes.
Now I’m getting two samples of the initial value, not just one, and then the ramp up to the peak. For filter frequency, this quite dramatically alters the timbre at note onset.
And – I guess the thing that I’m really complaining about – is that there is no way to avoid this behavior by setting attack = 0.
(
p = {
var egs = [
EnvGen.kr(Env([1, 0], [0.081])),
EnvGen.kr(Env.perc(0, 0.08)),
EnvGen.kr(Env.perc(0.001, 0.08)),
// even A2K on an ar envelope doesn't fix this!
A2K.kr(EnvGen.ar(Env.perc(0.001, 0.08)))
];
var modFactor = 8;
var freq = 500;
var initPulse = Impulse.kr(0);
var freqs = freq * (1 + (modFactor * egs));
var sig = RLPF.ar(Saw.ar(100), freqs, 0.3);
freqs.poll(initPulse);
[freqs, sig].lace(egs.size * 2)
}.plot(0.025);
{ p.specs = [[0, 5000], [-1, 1]].dup(4).flatten(1) }.defer(1)
)
Do I need, then, two synthdefs, one where the envelope begins at 1, and the other that begins at 0? OK, I guess, but then choosing the wrong synthdef is just another potential mistake to make in a live coding context – more user-friendly to reuse the structure and adjust parameters, than it is to have multiple structures because EnvGen ramps up too slowly.
Or I’m required to pass in the full envelope all the time, every time? Again, that kinda works against streamlining a live coding workflow.
BTW I also tried EnvGen.ar and then demoting it by A2K. Unfortunately this didn’t improve the sound.
I note in the PR comment “a one-sample phase change from previously” – I’m curious why the envelope needs to have two samples at the initial value? I think I can imagine the rationale from a programmer’s perspective, but from a musician’s perspective, this is not quite expected behavior. Any chance of improving it?
hjh