SchedAbs delay when stopping/starting Ndefs

I have the following code:

(
t.schedAbs(t.beats.ceil, { Ndef(\y).stop; } );
t.schedAbs(t.beats.ceil, { Ndef(\comb).play; } );
)

(
t.schedAbs(t.beats.ceil, Ndef(\comb).stop; );
t.schedAbs(t.beats.ceil, Ndef(\y).play;  );
)

My expectation is that the server would, in the future, stop and start the appropriate NDefs on the beat and I would, essentially, get a hard cut between the two.

What I am hearing instead is that the playing Ndef is cut on the beat, but the Ndef to play takes a few hundred milliseconds (at least) to start playing.

What is happening here ? Is this standard JITLib behavior ? If I wanted to cut back and forth between the two would it make more sense to have an audio sink that’s essentially a muted bus ?

I guess it’s the built-in fade: NodeProxy | SuperCollider 3.12.2 Help

hjh

You might be happy to know that you don’t need schedAbs for this - quantization is already built into NodeProxy and Ndef:

(
Ndef(\foo).quant = 1;
Ndef(\foo, {
	var trig, hpFreq;
	
	trig = Impulse.kr(4);
	
	hpFreq = 4000;

	Env.perc(0, 1, 1, -42).kr(gate:trig) * HPF.ar(WhiteNoise.ar(), hpFreq)
}).play
)

Try changing hpFreq and resetting the synth - changes will be quantized according to quant, and thus it will stay in sync with itself. This should apply to play/stop as well.

And, fwiw, stop IS actually just muting the bus - the synth is still playing in the background in this case.

Ah, testing this for the play/stop case I see that play is implemented to use quant, but stop is NOT. In fact, stop doesn’t even necessarily use the correct clock to schedule the stop!

I haven’t tested this too much, but this extension seems to fix the issue by scheduling the stop according to quant (and the correct clock!) the saw way that it’s done for play:

+BusPlug {
	stop { | fadeTime, reset = false |
		var bundle = MixedBundle.new;
		monitor.stopToBundle(bundle, fadeTime);
		bundle.schedSend(this.homeServer, this.clock ? TempoClock.default, this.quant);
		if(reset) { monitor = nil };
		this.changed(\stop, [fadeTime, reset]);
	}
}

This definitely feels like a bug in BusPlug - JITLib is usually impressively bulletproof with this kind of thing, I’m surprised this bug has been around for so long without being discovered!

wow! I found a bug!
Thanks for the help, scztt.

@scztt - that change looks like it works.
Good stuff! Thank you.