Fix for bug 1026

This commit is contained in:
Steve Daulton 2015-06-19 14:15:59 +01:00
parent 218172d12a
commit 07ca677dc7
2 changed files with 25 additions and 12 deletions

View File

@ -306,13 +306,20 @@
; remember that snd-biquad uses the opposite sign convention for a_i's
; than Matlab does.
; convenient biquad: normalize a0, and use zero initial conditions.
; convenient biquad: normalize a0, and use zero initial conditions.
(defun nyq:biquad (x b0 b1 b2 a0 a1 a2)
(if (< a0 1.0)
(error (format t "a0 < 1 (unstable parameter) in biquad~%")))
(if (<= a0 0.0)
(error (format nil "a0 < 0 (unstable parameter a0 = ~A) in biquad~%" a0)))
(let ((a0r (/ 1.0 a0)))
(snd-biquad x (* a0r b0) (* a0r b1) (* a0r b2)
(* a0r a1) (* a0r a2) 0 0)))
(setf a1 (* a0r a1)
a2 (* a0r a2))
(if (or (<= a2 -1.0) (<= (- 1.0 a2) (abs a1)))
(error (format nil
"(a2 <= -1) or (1 - a2 <= |a1|) (~A a1 = ~A, a2 = ~A) in biquad~%"
"unstable parameters" a1 a2)))
(snd-biquad x (* a0r b0) (* a0r b1) (* a0r b2)
a1 a2 0 0)))
(defun biquad (x b0 b1 b2 a0 a1 a2)

View File

@ -30,12 +30,9 @@
(defun wet (sig gain f0 f1)
(cond
((not f0) ;low-shelf
(if (< f1 (/ *sound-srate* 2.0))
(eq-lowshelf sig f1 gain)
(mult sig gain))) ;frequency above Nyquist so amplify full spectrum
((not f1) (eq-highshelf sig f0 gain))
(t (mid-shelf sig f0 (validate f1) gain))))
((not f0) (eq-lowshelf sig f1 gain))
((not f1) (eq-highshelf sig f0 gain))
(t (mid-shelf sig f0 (validate f1) gain))))
(defun result (sig)
(let*
@ -58,14 +55,23 @@
(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))
(cond
((not (get '*TRACK* 'VIEW)) ; 'View is NIL during Preview
(setf p-err (format nil "This effect requires a frequency selection in the~%~
'Spectrogram' or 'Spectrogram (log f)' track view.~%~%"))
'Spectral Selection' or 'Spectral Selection log(f)'~%~
track view.~%~%"))
(catch 'error-message
(multichan-expand #'result *track*)))
((string-not-equal (get '*TRACK* 'VIEW) "spectral" :end1 8 :end2 8)
"Use this effect in the 'Spectral Selection'\nor 'Spectral Selection log(f)' view.")
"Use this effect in the 'Spectral Selection'\nor 'Spectral Selection log(f)' view.")
(T (setf p-err "")
(if (= control-gain 0) ; Allow dry preview
"Gain is zero. Nothing to do."