I’m working on a looper UGen which uses Latch.ar to set a loop point:
loopPoint = Latch.ar(recPointer, \startLoop.tr);
But what if I wanted to reset the loopPoint to zero? It would have been nice with a reset input to the latch UGen that resets the output to zero upon receiving a trigger.
The reason why this one fails, I think, is because of interpolation in the * operator.
Audio-rate recPointer is multiplied by control-rate 1 - reset. The kr operand needs to be promoted to ar, which I believe is done by making a linear ramp over the duration of the control block. So the first value of 1 - reset, when reset rises to 1, would be 63/64, assuming default settings – certainly not the 0 required to suppress the recPointer.
I’d go one step further: 1 - reset is not exactly a valid way to invert a trigger. It is a valid way to negate the result of a signal comparison operator, because that result is guaranteed to be 0 or 1. But a trigger is not guaranteed to be only exactly 0 or 1, so you can’t apply the same logic to triggers.
I’d write reset <= 0 instead.
But that alone won’t solve the problem because the interpolation is in the subsequent * operator. T2A is valid to deal with that. I had thought there might be some alternative but on second thought, nope, that’s the droid you’re looking for.