mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-11 09:03:36 +02:00
Bug 1275 - No preview in Spectral edit effects
Introduces a new type 'spectral' t Nyquist plug-ins
This commit is contained in:
committed by
James Crook
parent
0d4b58ba1c
commit
6663f406d3
@@ -1,6 +1,6 @@
|
||||
;nyquist plug-in
|
||||
;version 4
|
||||
;type process
|
||||
;type process spectral
|
||||
;preview linear
|
||||
;name "Spectral edit shelves..."
|
||||
;action "Filtering..."
|
||||
@@ -9,35 +9,31 @@
|
||||
|
||||
|
||||
;; SpectralEditShelves.ny by Paul Licameli, November 2014.
|
||||
;; Updated to version 4 by Steve Daulton November 2014.
|
||||
;; Updated by Steve Daulton 2014 / 2015.
|
||||
;; Released under terms of the GNU General Public License version 2:
|
||||
;; http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
|
||||
;control control-gain "Gain (dB)" real "" 0 -24 24
|
||||
|
||||
(setf control-gain (min 24 (max -24 control-gain))) ; excessive settings may crash
|
||||
|
||||
(defmacro validate (hz)
|
||||
"Ensure frequency is below Nyquist"
|
||||
`(setf ,hz (max 0 (min (/ *sound-srate* 2.0) ,hz))))
|
||||
"If frequency is above Nyquist, don't use it"
|
||||
`(if (or (>= ,hz (/ *sound-srate* 2.0))
|
||||
(<= ,hz 0))
|
||||
(setf ,hz nil)))
|
||||
|
||||
(defun mid-shelf (sig lf hf gain)
|
||||
"Combines high shelf and low shelf filters"
|
||||
(let* ((invg (- gain)))
|
||||
(let ((invg (- gain)))
|
||||
(scale (db-to-linear gain)
|
||||
(eq-highshelf (eq-lowshelf sig lf invg)
|
||||
hf invg))))
|
||||
|
||||
(defun wet (sig gain f0 f1)
|
||||
"Apply appropriate filter"
|
||||
(cond
|
||||
((not f0) (eq-lowshelf sig (validate f1) gain))
|
||||
((not f1) (eq-highshelf sig (validate f0) gain))
|
||||
(t
|
||||
(validate f0)
|
||||
(validate f1)
|
||||
(when (= f0 f1)
|
||||
(throw 'error-message "Please select a frequency range."))
|
||||
(mid-shelf sig f0 f1 gain))))
|
||||
((not f0) (eq-lowshelf sig f1 gain))
|
||||
((not f1) (eq-highshelf sig f0 gain))
|
||||
(t (mid-shelf sig f0 f1 gain))))
|
||||
|
||||
(defun result (sig)
|
||||
(let*
|
||||
@@ -51,24 +47,26 @@
|
||||
(breakpoints (list t1 1.0 t2 1.0 tn))
|
||||
(env (snd-pwl 0.0 rate breakpoints)))
|
||||
(cond
|
||||
((not (or f0 f1))
|
||||
((not (or f0 f1)) ; This should never happen for a 'spectral' effect.
|
||||
(throw 'error-message (format nil "~aPlease select frequencies." p-err)))
|
||||
; shelf is above Nyquist frequency so do nothing
|
||||
((and f0 (>= f0 (/ *sound-srate* 2.0))) nil)
|
||||
(T (sum (prod env (wet sig control-gain f0 f1))
|
||||
(prod (diff 1.0 env) sig))))))
|
||||
|
||||
;; Frequency selection must be between 0 Hz and Nyquist.
|
||||
(if (and (get '*selection* 'low-hz)
|
||||
(<= (get '*selection* 'low-hz) 0))
|
||||
(remprop '*selection* 'low-hz))
|
||||
(if (and (get '*selection* 'high-hz)
|
||||
(>= (get '*selection* 'high-hz)(/ *sound-srate* 2)))
|
||||
(remprop '*selection* 'high-hz))
|
||||
((and f0 (>= f0 (/ *sound-srate* 2.0)))
|
||||
; Shelf is above Nyquist frequency so do nothing.
|
||||
nil)
|
||||
((and f0 f1 (= f0 f1))
|
||||
(throw 'error-message
|
||||
(format nil "~aBandwidth is zero (the upper and lower~%~
|
||||
frequencies are both ~a Hz).~%~
|
||||
Please select a frequency range."
|
||||
p-err f0)))
|
||||
(T (if f0 (validate f0))
|
||||
(if f1 (validate f1))
|
||||
(if (not (or f0 f1)) ; 'validate' may return nil
|
||||
nil ; Do nothing
|
||||
(sum (prod env (wet sig control-gain f0 f1))
|
||||
(prod (diff 1.0 env) sig)))))))
|
||||
|
||||
(catch 'error-message
|
||||
(setf p-err "")
|
||||
(if (= control-gain 0) ; Allow dry preview
|
||||
"Gain is zero. Nothing to do."
|
||||
(multichan-expand #'result *track*)))
|
||||
|
||||
(setf p-err "Error.\n")
|
||||
(if (= control-gain 0)
|
||||
nil ; Do nothing
|
||||
(multichan-expand #'result *track*)))
|
||||
|
Reference in New Issue
Block a user