I presume that you mean this one? Nyquist Silence Generator effect
;nyquist plug-in
;version 1
;type process
;name "Silence Generator Effect..."
;action "Generating silence..."
;info "Silence generator effect by Steve DaultonnnReplaces selection with set length of silencenTo 'Insert' silence, place the cursor at the requiredninsert position then hold the SHIFT key down andntap the cursor left or right key to create a tiny selection.nnThis effect can be used with 'Ctrl+R' provided thatnat least a tiny part of a track is selected."
;control gap "Inserted silence length" real "seconds" 5 0 10
(stretch-abs gap (force-srate *sound-srate* (s-rest 1)))
Probably best to first look at what this is doing, and how.
The first part is the plug-in “header” that tells Audacity that this file is a Nyquist plug-in, that it is a “process” type plug-in called “Silence Generator Effect…” and gives some text to be displayed at the top of the plug-in interface. The Nyquist plug-in header is described here: Missing features - Audacity Support
An important thing in the header is “;type process”.
There are currently three types of Nyquist plug-in; analyze, process and generate.
Usually a plug-in that generates audio (including silence) would be a “generate” type plug-in. This plug-in is a bit unusual in that it generates audio (silence) but it is defined as a “process” type effect. The reason for this is because of the original purpose for the plug-in: https://forum.audacityteam.org/t/repeated-command/14416/1
Some key differences between the different types of plug-in:
process:
Appear in the Effect menu.
Usually for processing (modifying) audio from a track.
Usually returns a “sound”.
Can be used in Chains (Audacity Manual).
Can be repeated using the keyboard short-cut Ctrl+R. (Audacity Manual)
Can access the selected audio.
Uses local time.
Requires that there is a Selection.
analyze:
Appear in the Analyze menu.
Usually for analyzing the audio in a track.
Usually returns a text message or labels.
Not supported by Chains.
Can access the selected audio.
Uses local time.
Requires a Selection.
generate:
Appear in the Generate menu.
Usually for generating audio.
Usually returns a “sound”.
Not supported by Chains.
Cannot access the selected audio.
Uses “global” time.
Does not require a Selection (will generate a new audio track if no track is selected).
The final point requires some explanation.
“Local” time for a Nyquist plug-in uses the duration of the selection as “one unit” of time.
“Global” time is “real” time - “one unit” of time is one second.
Thus, in a process or analyze type plug-in, the command (S-REST 1) will produce “one unit” of silence, which is the same duration as the selection, whereas in a generate type plug-in, the same command will generate one second of silence.
If the plug-in was written as a generate type plug-in (which would be normal because it generates silence) then the code would have been more simple:
;control gap "Inserted silence length" real "seconds" 5 0 10
(s-rest gap)
The first line tells Audacity to create a slider control.
The slider control sets the value of “gap” (which is a variable)
The command (S-REST GAP) generates silence of duration “GAP” - so if “GAP = 5”, then it will generate 5 seconds of silence.
In a process type plug-in, (S-REST GAP) would probably not produce the expected amount of silence - if “GAP = 5” then (S-REST GAP) will produce silence that is 5 times longer than the Selection. You can demonstrate this by entering the command (S-REST 5) in the Nyquist Prompt effect.
There are several ways that we can force a process type plug-in to generate a specified number of seconds (rather than a length that is proportional to the length of the selection). The shortest way is to use “ABS_ENV”. Thus in the Nyquist Prompt effect we can generate 5 seconds of silence with:
(abs-env
(s-rest 5))
The other way (as used in the plug-in) is to stretch “one unit” of sound to the desired duration using STRETCH-ABS.
The other command FORCE_SRATE) specifies that the silence should be generated with a sample rate that is the same as the track sample rate, which is given to Nyquist by Audacity in the variable sound-srate. Audacity plug-ins have got a bit smarter over the years and this part is not required if using Audacity 2.x
So, for your proposed plug-in, you should change the header to specify the plug-in as a “generate” type plug-in rather than an “analyze” type plug-in, then you don’t need to use STRETCH-ABS or FORCE-SRATE.
Does this make sense so far?