Looping segments

I’d like to be able to loop, at audio rate, a sequence of continuous line segments where I can modulate the timing and maybe level of each. The idea is to create a phasor to drive e.g. a sine wave for a phase distortion synth.

Env looks like the right tool for the job, so I slapped together some code based on the example. However, I’m getting some artifacts - there is a discontinuity at the end of the loop where the sine cycle completes before the loop restarts. Should I use something else?

Code:

(
{
	sin(EnvGen.ar(
		Env.new(
			[
				0, // initial (can't loop to this)
				1, // loop start
				0.5, // kink
				0, // loop end
				0 // don't like it but I think it's needed
			],
			[
				0, // get right to it
				1/880, // modulate this
				1/880, // modulate this too
				0 // back to beginning
			],
			releaseNode: 3, // loop end
			loopNode: 0, // loop start (1 + 0)
		), 
		gate: 1 // keep it on like the coffee warmer
	) * 2pi - pi) ! 2;
	// discontinuity at end. ugh.
}.plot(0.004);
)

Plot:

Just fiddled around some more and it actually works fairly well at low frequencies.