<=2020-03-21 - 2020-03-30

First what I should note is that clicks produced at sound start and sound end and sound cut are all different things.
The last two - end or cut - could be treated the same way, even though an improper start and end might be an error of sample's author.
Here we will speak about clicks at start only once and briefly: to get no click, your sound must start -1.0 sample from the center of the first sample.

There may be various solutions on how to cut your sound at any arbitrary position and get no click.
One of them is to have more voices than your tracker needs, that way allowing to your player not stop those sounds immediately, but give them few more pieces of second to play decaying quickly.
This way doesn't require any extra buffering or processing of multiple samples per sample once when KeyOff occurs.
Somewhat another solution is to have two voices per voice and swap them.

But instead of bothering with each voice separately, we can have just one declick buffer for the whole processing.
See, the processing which is needed is of a constant length/period, the samplerate also is not changing at play time, hence, we are coming at a buffer of a definite size.
Once KeyOff is received, fill that buffer with the incoming samples (outgoing from the resampler).
If there are simultaneous KeyOffs, - sum up them. Actually, sum up always, - don't just put into the buffer.
Doing it that way we will only have to shift that buffer and apply (add) its content to the output.
Well, one more possible saving to the performance is that we don't need to apply to the output the content of that buffer once it has ended (this buffer is short and exhausts quickly).

Now about the decay we have to use at KeyOff.
The decay envelope goes from 1.0 (full volume) to 0.0 (no sound).
I've tried few: linear, cosine from phase 0 to PI (means 1/2 of cosine period), subtracting 1 from sine from phase 0 to PI/2 (means 1/4 of sine period), cosine from phase 0 to PI/2 (means 1/4 of cosine period).
Linear envelope is best.

That's all I wanted to say about declicking for now.
I've tried to be clear as possible, but the subject is such that it yet might not be easy to grasp.
I am adding some illustrations which might help to look from the other perspective.
    

Lets begin from an example which should be easily comprehensible: a transition between sounds of a different frequencies.
Both stop and start are occurring at phase 0.
    

Lets do it be less nice: introduce an obvious click.
    

The declick I'm currently proposing looks this way.
Sum up the dark blue waveform to dark green one to get the proper sounding.
    

I also tried envelopes based on trigonometric functions.
Per same period of decay time they sounded worse (for the test is better to use a brink values of the transition period (the length of tail buffer), where a click is yet somewhat noticeable, and the best one to test that is 100-200μs).
    

What could be noted here when comparing to linear envelope?
The cosine 1/2 has a steeper slope on its middle.
The sine 1/4 has a steeper slope on its beginning.
The cosine 1/4 has a steeper slope on its end.
That perhaps is the reason why they sound worse.
The linear decay looks being the correct one to use.
    

Somewhere at 2020-03-26 I began thinking (actually, returned to a thought) about doing a more static declicking by using an accumulated level values.
Static in the meaning that no further sample pump would be necessary.
It might be that even the tail buffer will not be necessary.
Not sure about this conception though.
Well, even less likely the no-buf conception is correct.
    

Plots are drawn using Flotr2 javascript.