Sound library Env causes clicks

Playing a steady-state oscillator using the Sound library works just fine. But attempting to add an envelope (Env) results in distorted clicks as the sound starts and stops.

This can be demonstrated using the Libraries > Sound > Env > Envelopes example.

Any insights or fixes?

SYSTEM: Windows 11 Pro, RME Fireface UCX, Processing 4.3

Hi @esc746
Is the distorted clicks you’re talking about somewhat intermittent, or is it on every note? If you change the attack time to something like .06 does it get better or worse? Or does it only happen when the loop repeats?

I tried the Envelopes example you referenced and what I’m hearing is a phase issue with the oscillator not the envelope generator. Usually with a synthesizer you want to reset the phase of the oscillator to the beginning of its phase for each new envelope generation which for a sine wave or triangle wave (depending on how its created) should be 0. If you don’t then there will be times where oscillator could be at the peak of its phase, or 1, and this would cause the envelope generator to have some distortion, especially at fast attack times.

The best practice is to reset the phase of your oscillator when you generate a new envelope, but from what I can see there is no way to do this with the Processing Sound library. So the only fix is to have slower attack times in that case.

May be worth a feature request to the developer if this is functionality you need, but there are also other audio libs that do this.

I hope this helps.