LISP code for multiple selections like Contrast plug-in

I want to do something very similar to what the Contrast plug-in does with its two “measure selection” buttons, but with some different math. Not much experience with LISP/Nyquist but I can probably manage the rest if I can figure out how to do the selections like the Contrast plug-in does. Hints appreciated, or is the code for Contrast accessible?

Nyquist plug-ins don’t stay open like the Contrast tool, but Nyquist does have a variable called scratch which can be used to store a value that will persist after the plug-in has run.*SCRATCH*_Tutorial

Thanks! It’s not as elegant, but will suit my needs. Is that how the Noise Reduction effect works- get the sample, then run it again to do the actual processing?

Sort of, but Noise Reduction is not a Nyquist plug-in, it’s written in C++ as part of Audacity.