Nyquist is basically XLisp with an extra data type - a “sound” - and a load of additional built in functions.

There is one tricky concept that you will run into, and that is “behavioral abstraction” the “transformation environment”. You can go quite a long way in Nyquist without worrying about this, so I’d suggest that you ignore that for now and it will become clearer as you get to know Nyquist.

The “additional built in functions” are listed in the Nyquist reference manual in the language reference section: Index

The XLisp manual also has a language reference section which is extremely useful as it contains examples for each XLisp function: XLISP Language Reference

Also the Audacity Nyquist plug-ins reference: Missing features - Audacity Support

The RMS function is described in the Nyquist manual here: Nyquist Functions

(rms sound [rate window-size])

As you can see, the function supports two optional parameters, rate and window-size. If you supply one optional parameter, that will be “rate”. If you supply both optional parameters, the first will be “rate” and the second will be “window size”. See the description in the manual for more details.

In order to allow user input you will need to add a control widget in the plug-in header. For example you could use a “slider widget” (Missing features - Audacity Support).

Try to use meaningful names for variables. Better to be verbose than obscure

So for example:

```
;control window-size "Window size" real "milliseconds" 100 1 1000
```

will give you a variable called “window-size” with a default value of 100, and a minimum slider range of 1, and a maximum slider range of 1000.

Because (in “text right”) it says that the units are milliseconds, you will need to convert that to seconds:

```
(setq window-size (/ window-size 1000.0))
```

We know that if we only supply one of the optional parameters, it will be “rate”, and then the window size will be 1/rate seconds, so we need to convert our user input into a “rate” value.

```
(setq rate (/ window-size))
```

Note that is we don’t specify the dividend, it is assumed to be 1. Thus (/ val) is exactly the same as (/ 1 val).

One word of caution, “1” is an integer, so if the divisor “val” is an integer the answer will be calculated using integer arithmetic and the answer will always be zero, so only do this if you know for sure that “val” is a float (floating point value), otherwise write it in full as (/ 1.0 val).

So we have rate ( /second), which we can now use in our code, replacing (rms s) with (rms s rate).