1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-27 15:50:10 +01:00

Bug892: Spec. Sel. Toolbar no longer forces selection below half project rate...

... rather, selections up to half of the maximum of project rate and all track
rates is permitted.

Also added some more cautions to the Nyquist code for spectral selection
effects, in case input frequencies exceed Nyquist for the track (as they
may now do).
This commit is contained in:
Paul Licameli
2015-07-25 13:28:23 -04:00
parent a0f5f5852c
commit fd274e6d0e
3 changed files with 30 additions and 15 deletions

View File

@@ -19,20 +19,23 @@
(defmacro validate (hz)
"Ensure frequency is below Nyquist"
`(setf hz (min (/ *sound-srate* 2.0),hz)))
`(setf ,hz (max 0 (min (/ *sound-srate* 2.0) ,hz))))
(defun wet (sig gain f0 f1)
;; (re)calculate bw and fc to ensure we do not exceed Nyquist frequency
(let ((fc (sqrt (* f0 (validate f1))))
(bw (/ (log (/ (validate f1) f0))
(log 2.0))))
(validate f0)
(validate f1)
(let ((fc (sqrt (* f0 f1)))
(bw (/ (log (/ f1 f0))
(log 2.0))))
(when (= bw 0)
(throw 'error-message (format nil "~aBandwidth is zero.~%Select a frequency range." p-err)))
(eq-band sig fc gain (/ bw 2))))
(defun result (sig)
(let*
((f0 (get '*selection* 'low-hz))
(f1 (get '*selection* 'high-hz))
(bw (get '*selection* 'bandwidth))
(tn (truncate len))
(rate (snd-srate sig))
(transition (truncate (* 0.01 rate))) ; 10 ms
@@ -47,8 +50,6 @@
(throw 'error-message (format nil "~aLow frequency is undefined." p-err)))
((not f1)
(throw 'error-message (format nil "~aHigh frequency is undefined." p-err)))
((= bw 0)
(throw 'error-message (format nil "~aBandwidth is zero.~%Select a frequency range." p-err)))
;; If seleted frequency band is above Nyquist, do nothing.
((< f0 (/ *sound-srate* 2.0))
(sum (prod env (wet sig control-gain f0 f1)) (prod (diff 1.0 env) sig))))))