Synthdef clipping sound in between notes

I’ve been working on creating a synthdef for use in tidal cycles.
The synthdef uses a .wav file as a wavetable (SC converts the file to a signal and then a wavetable and loads to a buffer for an Osc) and is playable using tidal cycles.

I’ve gotten it to work (more or less) but when it plays notes there’s a very audible clipping that occurs in between notes as if the amplitude levels are dropping off very suddenly.

I thought it might have to do with the envelope. Somehow I may have applied an envelope to the synth incorrectly. Or perhaps it has something to do with the wavetable? Maybe there’s a conflict between the wavetable size and the duration of the envelope and other effects on the signal chain?

The code is:

// variable 'a' to open the sound file to prepare for reading contents
a = SoundFile.openRead("C:\\Users\\44774\\AppData\\Local\\SuperCollider\\Tables\\wubsquare.wav".standardizePath);
// variable 'b' to create a float array that is the same size as the sound file
b = FloatArray.newClear(a.numFrames);
// variable 'c' will read the sample data of the sound file 'a' into the array provided as variable 'b'
c = a.readData(b);
// variable 'd' will convert the array set as variable 'b' (which should now contain the data from the sample file) into a signal
d =;
// variable 'e' will convert the signal produced from the step in variable 'd' into a wavetable format
e = d.asWavetable;
// variable 'f' will load the wavetable created in the previous step in variable 'e' into a buffer on the server
f = Buffer.loadCollection(s, e);

f.bufnum; // display the buffer number of the wavetable to assign in the osc bufnum parameter
e.plot; // display a plot of the wavetable\autobot,

	|out, freq = 440.0, gate = 1|
	var env = Env.adsr(0.2, 0.35, 0.3, 0.05, -1, 0.0); // an ASDR envelope for the synth
    var gen =, gate, 1.0, 0.0, 0.1, doneAction: Done.freeSelf); // pass the env through to envgen
	// our variable sig is comprised of 2 oscillators, the osc that is using the wavetable generated from the wave file and a square wave oscillator
	var sig = [, freq, 0.0, 1.0, 0.0).midicps,, 0.5, 1, 0).midicps];
	// the oscillators in sig are passed through a resonant low pass filter,, 20000.0, 0.546, 1.0, 1.0, doneAction: Done.freeSelf), 1, 1, 0); // the filter's cutoff freq is set to move from 1200-20k hz over a period of 0.546 seconds using xline as a control rate

	// a bit crushing distortion applied to the signal from both oscillators that changes from less to more bitcrushing over 0.546 seconds,, 37485.0, 0.546, 1.0, 1.0, doneAction: Done.freeSelf),, 24, 0.546, 1.0, 1.0, doneAction:     Done.freeSelf), 1.0, 0.0);
	// some EQ to shape the signal further, 220, 1.0, 3.3, 1.0, 0.0);, 680, 2.0, -3.3, 1.0, 0.0);
	//some basic compression of the signal, sig, 0.5, 1.0, 1.0, 0.1, 1.0 , 0.0);
	//send the signal out so that the synthdef can be controled by tidalcycles/superdirt, sig, ~dirt.numChannels)*gen) // the final out signal is also passed through the envelope using *gen



I’ve tried to comment the code to clarify what I’m attempting to do.
I’ve been trying to adjust the envelope, the type of osc used (OscN, VOsc etc) and the clipping is always present. I even tried adding a reverb to the synth in tidal cycles to try and mask the clipping but it’s still very noticeable.

Any help or suggestions are greatly appreciated!

I can’t run the SynthDef, since I’m missing some UGens, but my guess is:
See the difference between:
Env.adsr(0.2, 0.35, 0.3, 0.05, -1, 0.0).plot
Env.adsr(0.2, 0.35, 0.3, 0.05, 1, 0.0).plot
You’re using an inverted envelope which gives a click.