That’s actually how it works now, except it has to keep processing until the ADSR expires. The problem is leftover sound from when the pedal was down earlier, still processing through the convolution, and the ADSR opens up to the very short attack phase.
I think the solution is to keep a pair of convolvers, each with its own ADSR. One is active, one is standby. Whenever the pedal goes down, switch to the standby and reset the new current one. No input goes to the standby, but its output continues to be processed.
One problem is that it would increase CPU, which is already an issue on Zynthian (Raspberry Pi.) I can’t just stop processing the standby convolver, as it could be in its ADSR release phase. (This is the only time we get the glitch, because it drops to zero from nonzero on reset.)
The CPU penalty could be minimized a bit by stopping processing the standby when it’s no longer in the release phase.
But I probably have a few mistakes above. Re-pedaling is tricky. I suspect the application of ADSRs isn’t correct as described above. Maybe rather than reset as described, I attach a fast release (separate ADSR) and when that expires reset the (standby) convolution and stop processing it. No doubt that could get messed up with rapid re-pedaling too, in which case the theoretically ideal solution might be to have as many convolvers as are needed, but that’s probably not practical.
I don’t plan to make pedaling sample-accurate. I think per-buffer is plenty good enough. I’d appreciate any input on what you think should be improved otherwise.
BTW, some code on Zynthian was still debug mode. (The Projucer’s makefile clean doesn’t work well at all, but it’s easily fixed by deleting the build folder, and in some cases, other build artifacts.) It now runs well on a Pi5 with two 256-byte buffers. I’ll be looking into the convolver you mentioned, though, since the default is two 128-byte buffers at 48000 samples per second and I’d like to avoid overruns with the default settings. Little hope on Pi4, I suspect.