Nyquist code for "gradual" high-pass filter please

What Steve did here … https://forum.audacityteam.org/t/a-gradual-filter/22027/4
but a high-pass (not low pass as above) filter with the cut-off frequency gradually dropping until the full audio band is passed at the original volume.

[ I’ve tried experimenting with Steve’s code to make it high-pass instead of low-pass but I can’t fathom-out how to do it :frowning: ]

Hi, Steve here :slight_smile:
Please describe as clearly as possible what you are trying to do (include the numbers) and I’ll see if I can help.

Hi Steve,
your previous code created a “gradual” low-pass filter whose cut-off frequency increased across the interval selected …

I’m after something very similar but a high-pass filter whose cut-off frequency decreases across the interval selected.
''gradual'' filters on white noise~.GIF
[ I’ve found VSTs which do that, e.g. …

however their maximum interval is too short for my purposes ]

Try this:

(setq start-freq 10000) ; cannot be greater than 1/2 the sample rate
(setq end-freq 100)
(setq passes 4)         ; more passes for a steeper filter cut-off
(setq sweep-type 0)     ; 1 for a linear sweep, 0 for exponential sweep

(let* ((nyq (/ *sound-srate* 2.0))
       (f0 (max 0 (min nyq start-freq)))
       (f1 (max 0 (min nyq end-freq))))
  (if (= sweep-type 0)
      (setf hpfreq (pwev f0 1 f1))
      (setf hpfreq (pwlv f0 1 f1)))
  (dotimes (i passes s)
    (setf s (hp s hpfreq))))

That’s perfect :slight_smile:


Thanks very much Steve

That sounds nice, Trebor,
which transition do you prefer, exponential or linear?

Exponential works better IMO.

BTW using “find” hp, “replace” with lp on the above code gives the same effect as Steve’s 2011 code, but now with a smoother envelope …


Low-pass variant of above code …

    (setq start-freq 22000) ; cannot be greater than 1/2 the sample rate
    (setq end-freq 20)
    (setq passes 1)         ; more passes for a steeper filter cut-off
    (setq sweep-type 0)     ; 1 for a linear sweep, 0 for exponential sweep

    (let* ((nyq (/ *sound-srate* 2.0))
           (f0 (max 0 (min nyq start-freq)))
           (f1 (max 0 (min nyq end-freq))))
      (if (= sweep-type 0)
          (setf lpfreq (pwev f0 1 f1))
          (setf lpfreq (pwlv f0 1 f1)))
      (dotimes (i passes s)
        (setf s (lp s lpfreq))))