mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 00:19:27 +02:00
Code clean-up by Steve. Instructions moved from ;info line to Manual. Filter quality control only available now by uncommenting the code (a new resonant filter effect will be provided on Wiki instead).
This commit is contained in:
parent
742c91d64d
commit
eb2fcde382
@ -4,96 +4,33 @@
|
||||
;categories "http://lv2plug.in/ns/lv2core#HighpassPlugin"
|
||||
;name "High Pass Filter..."
|
||||
;action "Performing High Pass Filter..."
|
||||
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\nAttenuates frequencies below your specified cutoff frequency.\nHigher rolloff values give a sharper attenuation of frequencies below\nthe cutoff frequency. If using a rolloff of 12 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping."
|
||||
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under GPL v2.\n"
|
||||
|
||||
;control rolloff-choice " Rolloff [dB per octave]" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
|
||||
;control q " Filter quality [q] for 12 dB rolloff" real "" 0.7071 .1 20
|
||||
;control f " Cutoff frequency [Hz]" real "" 1000 1 20000
|
||||
;; highpass.ny by Dominic Mazzoni
|
||||
;; Modified by David R. Sky
|
||||
;; Updated by Steve Daulton June 2012
|
||||
;; Released under terms of the GNU General Public License version 2:
|
||||
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html .
|
||||
|
||||
; note that all Nyquist highpass functions
|
||||
; [hp, highpass2, highpass4, highpass6, highpass8]
|
||||
; are defined below with -s suffix.
|
||||
; This enables highpass functions other than hp
|
||||
; to deal with stereo selection,
|
||||
; and dummy q arg for all but highpass2
|
||||
;; To enable the Q control, remove one semicolon from the start of lines 18 and 32
|
||||
|
||||
; 6dB/octave
|
||||
(defun hp-s (s f q) ; dummy q arg
|
||||
(hp s f))
|
||||
|
||||
; 12dB/octave
|
||||
(defun highpass2-s (s f q)
|
||||
(if (arrayp s)
|
||||
(vector (highpass2 (aref s 0) f q)
|
||||
(highpass2 (aref s 1) f q))
|
||||
(highpass2 s f q)))
|
||||
|
||||
; 24dB/octave
|
||||
(defun highpass4-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (highpass4 (aref s 0) f)
|
||||
(highpass4 (aref s 1) f))
|
||||
(highpass4 s f)))
|
||||
|
||||
; 36dB/octave
|
||||
(defun highpass6-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (highpass6 (aref s 0) f)
|
||||
(highpass6 (aref s 1) f))
|
||||
(highpass6 s f)))
|
||||
|
||||
; 48dB/octave
|
||||
(defun highpass8-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (highpass8 (aref s 0) f)
|
||||
(highpass8 (aref s 1) f))
|
||||
(highpass8 s f)))
|
||||
|
||||
; check function: returns 1 on error
|
||||
(defun check (arg min max)
|
||||
(if (and (>= arg min) (<= arg max))
|
||||
0 1))
|
||||
|
||||
|
||||
; initialize blank error-msg
|
||||
(setf error-msg "")
|
||||
|
||||
; check for erroneous q value
|
||||
(setf error-msg (if
|
||||
(and (= rolloff-choice 1)
|
||||
(= (check q 0.1 20) 1))
|
||||
(strcat error-msg (format nil
|
||||
"q value ~a lies outside valid range 0.1 to 20
|
||||
for your chosen rolloff of 12 dB per octave.~%
|
||||
" q))
|
||||
error-msg))
|
||||
|
||||
;; check for erroneous frequency cutoff value
|
||||
(cond ((< f 1)
|
||||
(setf error-msg
|
||||
(strcat error-msg (format nil
|
||||
"Cutoff frequency is set at ~a Hz~%but must be at least 1 Hz." f))))
|
||||
((> f (truncate (/ *sound-srate* 2.0)))
|
||||
(setf error-msg
|
||||
(strcat error-msg (format nil
|
||||
"Cutoff frequency is set at ~a Hz but must not~%~
|
||||
be greater than ~a Hz (half of the track sample rate)."
|
||||
f (truncate (/ *sound-srate* 2.0)))))))
|
||||
|
||||
|
||||
(cond
|
||||
((> (length error-msg) 0)
|
||||
(setf error-msg (strcat (format nil
|
||||
"Error.~%You have entered at least one invalid value:~%
|
||||
") error-msg))
|
||||
(format nil "~a" error-msg))
|
||||
;
|
||||
(t ; perform highpass effect
|
||||
(funcall (nth rolloff-choice '(hp-s highpass2-s highpass4-s highpass6-s highpass8-s))
|
||||
s f q)))
|
||||
|
||||
|
||||
|
||||
; from previous commit
|
||||
; arch-tag: 49302eba-9945-43d7-aade-f1c7eded27af
|
||||
;control rolloff "Rolloff (dB per octave)" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
|
||||
;;control q "Filter quality (Q) for 12 dB rolloff" real "" 0.7071 .1 20
|
||||
;control frequency "Cutoff frequency (Hz)" real "" 1000 1 20000
|
||||
|
||||
(cond
|
||||
((> frequency (/ *sound-srate* 2))
|
||||
(format nil
|
||||
"Cutoff frequency is set at ~a Hz but must not~%~
|
||||
be greater than ~a Hz (half of the track sample rate)."
|
||||
frequency
|
||||
(truncate (/ *sound-srate* 2.0))))
|
||||
((<= frequency 1)
|
||||
(format nil
|
||||
"Cutoff frequency is set at ~a Hz~%but must be at least 1 Hz."
|
||||
frequency))
|
||||
; ((= rolloff 1)(highpass2 s frequency (max (min q 20) 0.1)))
|
||||
(T
|
||||
(funcall
|
||||
(nth rolloff '(hp highpass2 highpass4 highpass6 highpass8))
|
||||
s frequency)))
|
||||
|
@ -4,94 +4,33 @@
|
||||
;categories "http://lv2plug.in/ns/lv2core#LowpassPlugin"
|
||||
;name "Low Pass Filter..."
|
||||
;action "Performing Low Pass Filter..."
|
||||
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under terms of the GNU General Public License Version 2\nAttenuates high frequencies above your specified cutoff frequency.\nHigher rolloff values give a sharper attenuation of frequencies above\nthe cutoff frequency. If using a rolloff of 12 dB, a [q] value greater than\ndefault 0.7 increases resonance ['ringing'] of the cutoff frequency and\ncould result in clipping.""
|
||||
;info "by Dominic Mazzoni, modified by David R. Sky\nReleased under GPL v2.\n"
|
||||
|
||||
;control rolloff-choice " Rolloff [dB per octave]" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
|
||||
;control q " Filter quality [q] for 12 dB rolloff" real "" 0.7071 .1 20
|
||||
;control f " Cutoff frequency [Hz]" real "" 1000 1 20000
|
||||
;; lowpass.ny by Dominic Mazzoni
|
||||
;; Modified by David R. Sky
|
||||
;; Updated by Steve Daulton June 2012
|
||||
;; Released under terms of the GNU General Public License version 2:
|
||||
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html .
|
||||
|
||||
; note that all Nyquist lowpass functions
|
||||
; [lp, lowpass2, lowpass4, lowpass6, lowpass8]
|
||||
; are defined below with -s suffix.
|
||||
; This enables lowpass functions other than lp
|
||||
; to deal with stereo selection,
|
||||
; and dummy q arg for all but lowpass2
|
||||
;; To enable the Q control, remove one semicolon from the start of lines 18 and 32
|
||||
|
||||
; 6dB/octave
|
||||
(defun lp-s (s f q) ; dummy q arg
|
||||
(lp s f))
|
||||
|
||||
; 12dB/octave
|
||||
(defun lowpass2-s (s f q)
|
||||
(if (arrayp s)
|
||||
(vector (lowpass2 (aref s 0) f q)
|
||||
(lowpass2 (aref s 1) f q))
|
||||
(lowpass2 s f q)))
|
||||
|
||||
; 24dB/octave
|
||||
(defun lowpass4-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (lowpass4 (aref s 0) f)
|
||||
(lowpass4 (aref s 1) f))
|
||||
(lowpass4 s f)))
|
||||
|
||||
; 36dB/octave
|
||||
(defun lowpass6-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (lowpass6 (aref s 0) f)
|
||||
(lowpass6 (aref s 1) f))
|
||||
(lowpass6 s f)))
|
||||
|
||||
; 48dB/octave
|
||||
(defun lowpass8-s (s f q) ; dummy q arg
|
||||
(if (arrayp s)
|
||||
(vector (lowpass8 (aref s 0) f)
|
||||
(lowpass8 (aref s 1) f))
|
||||
(lowpass8 s f)))
|
||||
|
||||
; check function: returns 1 on error
|
||||
(defun check (arg min max)
|
||||
(if (and (>= arg min) (<= arg max))
|
||||
0 1))
|
||||
|
||||
|
||||
; initialize blank error-msg
|
||||
(setf error-msg "")
|
||||
|
||||
; check for erroneous q value
|
||||
(setf error-msg (if
|
||||
(and (= rolloff-choice 1)
|
||||
(= (check q 0.1 20) 1))
|
||||
(strcat error-msg (format nil
|
||||
"q value ~a lies outside valid range 0.1 to 20
|
||||
for your chosen rolloff of 12 dB per octave.~%
|
||||
" q))
|
||||
error-msg))
|
||||
|
||||
;; check for erroneous frequency cutoff value
|
||||
(cond ((< f 1)
|
||||
(setf error-msg
|
||||
(strcat error-msg (format nil
|
||||
"Cutoff frequency is set at ~a Hz~%but must be at least 1 Hz." f))))
|
||||
((> f (truncate (/ *sound-srate* 2.0)))
|
||||
(setf error-msg
|
||||
(strcat error-msg (format nil
|
||||
"Cutoff frequency is set at ~a Hz but must not~%~
|
||||
be greater than ~a Hz (half of the track sample rate)."
|
||||
f (truncate (/ *sound-srate* 2.0)))))))
|
||||
|
||||
|
||||
(cond
|
||||
((> (length error-msg) 0)
|
||||
(setf error-msg (strcat (format nil
|
||||
"Error.~%You have entered at least one invalid value:~%
|
||||
") error-msg))
|
||||
(format nil "~a" error-msg))
|
||||
;
|
||||
(t ; perform lowpass effect
|
||||
(funcall (nth rolloff-choice '(lp-s lowpass2-s lowpass4-s lowpass6-s lowpass8-s))
|
||||
s f q)))
|
||||
|
||||
; from previous commit
|
||||
; arch-tag: c2d96e46-b4e2-47c0-9a19-761011418e02
|
||||
;control rolloff "Rolloff (dB per octave)" choice " 6 dB,12 dB,24 dB,36 dB,48 dB" 0
|
||||
;;control q "Filter quality (Q) for 12 dB rolloff" real "" 0.7071 .1 20
|
||||
;control frequency "Cutoff frequency (Hz)" real "" 1000 1 20000
|
||||
|
||||
(cond
|
||||
((> frequency (/ *sound-srate* 2))
|
||||
(format nil
|
||||
"Cutoff frequency is set at ~a Hz but must not~%~
|
||||
be greater than ~a Hz (half of the track sample rate)."
|
||||
frequency
|
||||
(truncate (/ *sound-srate* 2.0))))
|
||||
((<= frequency 1)
|
||||
(format nil
|
||||
"Cutoff frequency is set at ~a Hz~%but must be at least 1 Hz."
|
||||
frequency))
|
||||
; ((= rolloff 1)(lowpass2 s frequency (max (min q 20) 0.1)))
|
||||
(T
|
||||
(funcall
|
||||
(nth rolloff '(lp lowpass2 lowpass4 lowpass6 lowpass8))
|
||||
s frequency)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user