Zero Crossing detection

I do not understand your answer. The function get-duration takes a number, not a sound. I do not find a Nyquist function called “len”. Are you referring to global variables?

From the manual:
(get-duration dur) [LISP]
Gets the actual duration of of something starting at a local time of 0 and ending at a local time of dur times the current sustain. For convenience, rslt is set to the global time corresponding to local time zero

The implication for this for effects in Audacity is that you can get the duration of a selection with (get-duration 1)

LEN is a global that gives the number of samples in a selection.
It is also used by Audacity for estimating the progress bar, which can be useful in generator plug-ins as you can provide a hint to Audacity of how long it will take to generate a sound by setting LEN to the expected length of the generated sound (provided that is known from the start).

I see then, I can avoid snd-length in the special case that the sound of interest is s. I can write my functions to handle the general case but take advantage of that too.

Are integrate and snd-inverse and sref-inverse not implemented in native C++ but in Lisp?

I thought this method would perform better than writing loops calling snd-fetch because the inner loops would not be in Lisp, which is the point of doing it that way. But I haven’t seen superior performance. Maybe there is needless inefficiency somewhere in my elaborations of it.

Those are all C++ implementations (sometimes translated automatically from an *.al file)

(print (type-of (symbol-function 'snd-integrate)))

Almost all functions with ‘snd-’ in front are of that Kind.
The high Level functions add in General multi-channel abilities and global behaviour (Timing, warp, loudness, sustain, Stretch and transpose).
The Problem lies in the automatical Translation, which is certainly not optimised (and the Memory/Sound Management in General).

Oh, heck. This tells me trigger and integrate are closures and not subrs. My attemps to improve on the time of SilenceMarker are getting nowhere. It seems I really can’t do better than repeated snd-fetch. I thought integrate and trigger would be magic. Did I waste a lot of time for nothing?

Don’t worry, there exist low-level variants of them.
There’s no Looping in xlisp code in this functions anyway (only the adaptions I mentioned before).
You can view the source code for a high-Level function by typing:

(grindef 'yin)

The low-level function is hidden within this code. If a bad Argument error is returned, you’ve reached the lowest Level.