nyquist prompt to fade EQ

Hi All,
I’m using Audacity 2.0.6. I’ve been an audacity user for many years and I love it.
Please could someone help me with this problem.
I often mess with the EQ of a recording. What I want to do now is have one EQ setting blend into another. Lets say, for example, I have a track and I’ve boosted the 110hz and 220hz frequencies and reduced all the rest and I want those frequencies (or pitches) to bend up to 130hz and 250hz over 20 seconds. Is this possible using a Nyquist prompt?
I know something similar could be done having 2 tracks that fade out and in, thus changing the pitch but I want to hear the bending up.
I would really appreciate any help on this.

Moving topic to the Nyquist forum.

Yes.

Something like this:

(setf start-hz 100.0)
(setf end-hz 1000.0)
(setf start-gain 12.0) ; gain in dB
(setf end-gain 12.0)
(setf width 0.5) ; half gain width in octaves

(defun sweepeq (sig hzs gains widths)
  ; hzs, gains, and widths are sounds at the control rate
  (eq-band sig hzs gains widths))

(let ((hzs (pwlv start-hz 1 end-hz))
      (gains (pwlv start-gain 1 end-gain))
      (widths (pwlv width 1 width)))
  (multichan-expand #'sweepeq s hzs gains widths))

Wow, thanks Steve.
I haven’t had a chance to try your code yet as I’m at work and will try tonight.
I really don’t think I could get my head around writing in nyquist as I find computer language really difficult.
Please could you help me further?
If I wanted to change the parameters of the code you wrote, how do I do that?
For example I want frequencies 215hz and 430hz shifting to 250hz and 500hz over 30 seconds, which part of the code do I change to affect the Hz and time?
Sorry if these questions are irritatingly simple.

You might be surprised. You don’t have to understand every little detail to have fun with it :wink:

Nyquist reads the code one line at a time. Anything that appears after a semicolon “;” on a line is ignored by Nyquist - it is a “comment” not an instruction. So, for example on the third line:

(setf start-gain 12.0) ; gain in dB

The instruction to Nyquist is:

(setf start-gain 12.0)

The part after the semicolon “; gain in dB” is just a comment to make the code more understandable for humans.

In Nyquist, all commands are in the same basic form:

  • They are always enclosed in brackets.
  • The first term inside the brackets is the function name (the command).
  • Anything else inside the brackets are parameters (“arguments”) for the command to chew on.

As a very simple example, to add two numbers in Nyquist code we could write the command:

(sum 3 5)

“sum” is the name of the function.
“3” and “5” are the “arguments” for the function.
In this case, what the “function” does is to add the values of all of the arguments.

When we run the code (sum 3 5), Nyquist calls the function “sum” and tells it to munch on the values “3” and “5”. When the function has finished (a tiny fraction of a second), it returns the result to Nyquist.

When we run a Nyquist script, the final value that is returned to Nyquist is passed by Nyquist back to Audacity.
Audacity then has to work out what to do with the returned value. If it is text or numbers (as in this case), Audacity will display it as a pop-up message.
Try the above in the “Nyquist Prompt” effect and you will see that Audacity pops up a message saying:
“Nyquist returned the value: 8”

If the “return value” is a sound rather than a number, Audacity will put it into the selected track.


One of the most common functions in any programming language is to set the value of something.
In the case of your filter code, we need to define several parameters - the initial filter frequency, the final filter frequency, the amount of filter gain, and so on.
In Nyquist, the usual way to set a value is to use the “setf” function.

The first 5 lines of the code set the parameters that we will need in the code:

(setf start-hz 100.0)
(setf end-hz 1000.0)
(setf start-gain 12.0) ; gain in dB
(setf end-gain 12.0)
(setf width 0.5) ; half gain width in octaves

As you can see, I have called these parameters: “start-hz”, “end-hz”, “start-gain”, “end-gain” and “width”.
Note that, ignoring the code comments, each of those lines has exactly the same form. There is the function name “setf”, then two “arguments”.
The first “argument” is the name that I have chose for a particular parameter.
The second argument is a numeric value.
Each lines sets the value of a symbol (the first argument) to the value of the second argument, so in the first line we set the value of “start-hz” to 100.0.

Note that for simplicity this code only applies one filter at a time. If you want two filter bands you can apply the effect twice with different parameters.

Note that there is no “time” value in this code. The code uses the selection length as the “time” of the transition.

If you want to use different start / end frequency values, just substitute your required values for the numeric values in the first two lines.

Steve, that was a truly amazing reply. Now I understand!
I can appreciate that it must be very annoying for serious nyquist writers on this forum to have people like me popping in for a “free service”. I can honestly say that your reply has inspired me to try and learn for myself as I can see how nyquist will expand the possibilities of my sound art making. Thanks so much for your help and perhaps future posts from me will be codes as of my own to share. Cheers.

That would be great :smiley:
If you get stuck or need pointers, feel free to ask.