Scripting Helper

Requires Audacity 2.3.0 or later.

The plug-in (bottom of post) is called “Scripting Helper…” and it was made primarily for experimenting and testing the new AUD-DO functions.
When installed, it will appear in the Tools menu.

The plug-in performs 4 functions according to the “Command” setting.

Command: List All
Prints a list (sorted alphabetically) of all “Scriptable” commands.
Note that there are some valid scripting commands listed in that are not included in this list (for example “MidiDeviceInfo:”. This is because they are not defined in either “Scriptables I” or “Scriptables II”. (Technically, it’s because they are not listed by “Extra > Scriptables II > GetInfo”. I don’t know if James intends to add the missing commands at a later date).

Command: Arguments
This looks up the function arguments for the command given in “Command id”.
If “Command id” is set to “Amplify”, then the output shows:
Ratio (float)
AllowClipping (bool)

Command: Syntax
This looks up the Nyquist / LISP syntax for the AUD-DO command for the command given in “Command id”.
If “Command id” is set to “Amplify”, then the output shows:
“Amplify: Ratio=float AllowClipping=bool”
This means that the full Nyquist command would be:
(aud-do “Amplify: Ratio=float AllowClipping=bool”)

Command: Run Command
This tests the command given in “Command to run”.
If “Command to run” is:
(aud-do “Amplify: Ratio=0.5”)
and some audio is selected, then the audio will be amplified by a ratio of 0.5, and
Scripting Helper will return a message saying what it has done:
Ran command: (aud-do “Amplify: Ratio=0.5”)

Note that “Run Command” is not restricted to the list of Scriptable I and Scriptables II, but may be used with any valid scriptable command. For example, the following command will work:
(aud-do “MidiDeviceInfo:”)

scripting-help.ny (3.74 KB)

Example use:

By running the effect with “Command: List All” we can see that there is a command called “ChangePitch”.

This is the same effect as “Change Pitch” in the Effect menu, but with AUD-DO we can run it in a Nyquist script.

Next we need to know what parameters are available for this effect, so we enter “ChangePitch” (without quotes) as the “Command id”, and select “Command:Arguments

Produces the output:

Which shows us that there are two parameters; “Percentage”, which is a floating point number, and SBSMS, which is a boolean true / false.
For scripting commands, use the number “1” for “true” and “0” for “false”.

Now we can check the correct syntax by selecting “Command:Syntax

Produces the output:

So let’s say that we want to lower the pitch by 1 octave (-50%), using the “High Quality” (SBSMS) option.
First we will need to select some audio, then we need to substitute our preferred values into the AUD-DO command, using the syntax shown above.

An AUD-DO command is always in the form: (aud-do “command in quotes”)

So this is our syntax:

(aud-do "ChangePitch: Percentage=double SBSMS=bool")

and putting in our values of “-50” and “1” (“true”), we get:

(aud-do "ChangePitch: Percentage=-50.0 SBSMS=1")

So now we can copy and paste that command into the “Command to run:” box, and select “Command:Run Command

Click “OK” and we see that the selected audio is processed, and a confirmation message returned:

A limitation of running scripting commands with Nyquist is that ONLY the scripting commands are allowed to change the project. We cannot (yet) have a mixture of scripting commands changing the project and normal Nyquist commands changing the project. So we can run the above scripting command in the Nyquist Prompt like this:

;type tool
(aud-do "ChangePitch: Percentage=-50.0 SBSMS=1")

but we if for example we do this:

;type tool
(aud-do "ChangePitch: Percentage=-50.0 SBSMS=1")
(mult *track* 0.5)

The command (mult track 0.5) will fail,
but we could do:

;type tool
(aud-do "ChangePitch: Percentage=-50.0 SBSMS=1")
(aud-do "Amplify: Ratio=0.5")

Is this why something like

;type tool
(aud-do-command "Pluck")

fails (rather) silently when entered from the Nyquist Prompt?

The log contains something rather mysterious like

07:18:13: Context was passed in, but was ignored.  ApplyAndSendResponse has its own one
07:18:13: Nyquist returned nyx_list

Yes. The problem here is that the scripting command “Pluck:” calls the “Pluck” effect, but the “Pluck” effect is a Nyquist Plug-in.

“We cannot (yet) have a mixture of scripting commands changing the project and normal Nyquist commands changing the project.”

so by implication, it is not possible to call a Nyquist plug-in from AUD-DO. Audacity just ignores the command (aud-do-command “Pluck”), and will ignore any command (aud-do “”).

Please do let me know if my replies are useful to you werame5913.

Yes, this was useful info. Thank you!