Old Nyquist Prompt I was given no longer working

Hi there,

Around a year ago, a member of this community was kind enough to provide me with the following Nyquist Prompt:

;control lhz "Low frequency corner" float "Hz" 1000 20 2000
;control hhz "High frequency corner" float "Hz" 2000 1000 10000

(when (= (length (get '*selection* 'tracks)) 3)
  (if (not (get '*scratch* 'filter-count-921))
      (setf count
        (putprop '*scratch* 1 'filter-count-921))
      (setf count
        (putprop '*scratch*
          (1+ (get '*scratch* 'filter-count-921))

(if (/= (length (get '*selection* 'tracks)) 3)
    "Error.\nYou must select three identical tracks."
    (case count
      (1    ;low pass
        (lowpass4 *track* lhz))
      (2    ;high pass
        (highpass4 *track* hhz))
      (t    ;band pass and clean up
        (remprop '*scratch* 'filter-count-921)
        (diff *track*
          (sum (lowpass4 *track* lhz)
                (highpass4 *track* hhz))))))

This code worked amazingly well and saved me a heap of time, however after starting a new project with a new install of Audacity, it no longer works. I wondered if there was anyone who would be able to help me fix the code. The original code required that I still had to do a few manual steps and optimally, the Prompt would:

  1. Duplicate a track twice to create 3 identical “Original” tracks.
  2. Use a high pass filter at an optional frequency on an “Original” track to create a “Highs” track.
  3. Make a copy of the “Highs” track and invert it to create an “Inverted Highs” track.
  4. Use a low pass filter at an optional frequency on an “Original” track to create a “Lows” track.
  5. Make a copy of the “Lows” track and invert it to create an “Inverted Lows” track.
  6. Mix the “Inverted Highs” and “Inverted Lows” track with the final “Original” track to create a “Mids” track.
  7. Move the “Mids” track up so it is between the “Highs” and “Lows” track.

I totally understand if writing it to do exactly these steps might be a bit too much trouble so just fixing the original code would be a lifesaver as it is!

That code works in Audacity 2-1-3 if you tick the box in the Nyquist Prompt window, (which I have coloured red )
Tick the box I have coloured red.png

The “Use legacy (version 3) syntax” box should not be ticked, but due to a quirk in the implementation it will still work in Audacity 2.1.3 if that box is ticked.

Use the Debug button rather than the OK button. What does it say in the debug window that pops up?

Sorry about that, I assumed the code didn’t work, so I only tried it with the legacy syntax, and it did work then.

One of the most common telltale signs for version 4 effects is the use of track. In version 3 and earlier, audio was passed to Nyquist in the variable “S” (or “s”, Nyquist is case insensitive). In version 4, this variable was changed to a more descriptive name TRACK.

Sorry for the late response - life happened!

I’ve tried the prompt with and without the legacy syntax box ticked. With the box ticked I get the same error three times, “You must select three identical tracks” but the tracks are identical. When I have the box unchecked, I get three outputs, “Nyquist returned the value: 1”, “Nyquist returned the value: 2” and “Nyquist returned the value: 3”.

I am using Windows version 2.1.0.

I can’t test that version as it is so old. The code works OK for me with Audacity 2.1.2 and later.
The current version of Audacity is 2.1.3 and is available here: https://www.audacityteam.org/download/