The “Adjustable Fade” effect is a “Nyquist Plug-in”.
“Nyquist” is an audio programming language that is included in Audacity. More information here: https://manual.audacityteam.org/man/nyquist.html
Nyquist programs are written in plain text.
For working with Nyquist in Windows, it is highly recommended to get a good plain text editor that supports "parentheses matching (such as NotePad++)
Nyquist scripts (programs) may be run in Audacity using the “Nyquist Prompt” effect: https://manual.audacityteam.org/man/nyquist_prompt.html
This is a good way to test Nyquist code.
For code that you will use frequently, Nyquist scripts may be made into plug-ins, which can be installed and are then available to run at any time like other effects.
Here is a Nyquist function that will create a single cycle of a sine wave that fits the current audio selection (lines beginning with a semicolon are “comments” and are ignored by Nyquist):
;version 4
;type process
(defun bell-curve ()
(let ((step (hz-to-step (/ (get-duration 1))))
(phase -90))
(osc step 1 *sine-table* phase)))
;; Call the function.
(bell-curve)
This is close to what we want as the “gain” that will be applied to the audio. If we want to increase the level at the half way point, then we will need a curve that is the other way up - that is, we want the phase of the sine wave to be -90 rather than +90 degrees.
;version 4
;type process
(setf g0 1.0) ; gain at start / end of curve
(setf g1 0.5) ; gain at middle of curve
(defun bell-curve (g0 g1)
(let ((step (hz-to-step (/ (get-duration 1))))
(phase (if (> g0 g1) 90 -90)) ;phase -90 for bell, +90 for inverted bell
(offset (if (> g0 g1) -1 1))) ;offset -1 for bell, +1 for inverted bell
(mult 0.5
(sum offset (osc step 1 *sine-table* phase)))))
;; Call the function.
(bell-curve g0 g1)
We also want to scale the curve according to the specified amount of gain.
Note that the above code gives us a curve that starts / end at 0, and goes up to +1 if g1 > g0 (bell curve) and goes down to -1 if g1 < g0 (inverted bell).
We need to scale the entire curve so that the height of the curve is equal to the difference of g0 and g1, and that the start value is g0.
For convenience, we can create a new function to do that, which I shall call “bell-curve-gain”
(defun bell-curve-gain (g0 g1)
(let ((start g0)
(mid-gain (abs (- g0 g1))))
(sum start
(mult mid-gain (bell-curve g0 g1)))))
To apply the gain curve to the track audio, we simply multiply (scale) the track audio by the gain curve:
(mult *track* (bell-curve-gain g0 g1))
Putting the whole thing together we get some code that can be run in the Nyquist Prompt:
;version 4
;type process
(setf g0 1.0) ; gain at start / end of curve
(setf g1 0.5) ; gain at middle of curve
(defun bell-curve (g0 g1)
(let ((step (hz-to-step (/ (get-duration 1))))
(phase (if (> g0 g1) 90 -90)) ;phase -90 for bell, +90 for inverted bell
(offset (if (> g0 g1) -1 1))) ;offset -1 for bell, +1 for inverted bell
(mult 0.5
(sum offset (osc step 1 *sine-table* phase)))))
(defun bell-curve-gain (g0 g1)
(let ((start g0)
(mid-gain (abs (- g0 g1))))
(sum start
(mult mid-gain (bell-curve g0 g1)))))
;; Call the function.
(mult *track* (bell-curve-gain g0 g1))
The one thing that is obviously missing is that our gain values g0 and g1 are hard coded into the first few lines. It would be much nicer to have slider controls, so let’s add those:
;version 4
;type process
;control g0 "Start / End gain" float "" 1 0 2
;control g1 "Mid-gain" float "" 0.5 0 2
(defun bell-curve (g0 g1)
(let ((step (hz-to-step (/ (get-duration 1))))
(phase (if (> g0 g1) 90 -90)) ;phase -90 for bell, +90 for inverted bell
(offset (if (> g0 g1) -1 1))) ;offset -1 for bell, +1 for inverted bell
(mult 0.5
(sum offset (osc step 1 *sine-table* phase)))))
(defun bell-curve-gain (g0 g1)
(let ((start g0)
(mid-gain (abs (- g0 g1))))
(sum start
(mult mid-gain (bell-curve g0 g1)))))
;; Call the function.
(mult *track* (bell-curve-gain g0 g1))
With the addition of a few more "plug-in headers, this code can easily be made into an installable plug-in. See here and have a go: https://wiki.audacityteam.org/wiki/Nyquist_Plug-ins_Reference