mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02: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:
parent
a0f5f5852c
commit
fd274e6d0e
@ -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))))))
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
(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 mid-shelf (sig lf hf gain)
|
||||
"Combines high shelf and low shelf filters"
|
||||
@ -30,9 +30,14 @@
|
||||
|
||||
(defun wet (sig gain f0 f1)
|
||||
(cond
|
||||
((not f0) (eq-lowshelf sig f1 gain))
|
||||
((not f1) (eq-highshelf sig f0 gain))
|
||||
(t (mid-shelf sig f0 (validate f1) gain))))
|
||||
((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))))
|
||||
|
||||
(defun result (sig)
|
||||
(let*
|
||||
@ -48,8 +53,6 @@
|
||||
(cond
|
||||
((not (or f0 f1))
|
||||
(throw 'error-message (format nil "~aPlease select frequencies." p-err)))
|
||||
((and f0 f1 (= f0 f1)) (throw 'error-message
|
||||
"Please select a frequency range."))
|
||||
; 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))
|
||||
|
@ -1258,7 +1258,18 @@ void AudacityProject::AS_SetSelectionFormat(const wxString & format)
|
||||
|
||||
double AudacityProject::SSBL_GetRate() const
|
||||
{
|
||||
return mRate;
|
||||
// Return maximum of project rate and all track rates.
|
||||
double rate = mRate;
|
||||
|
||||
TrackListOfKindIterator iterWaveTrack(Track::Wave, mTracks);
|
||||
WaveTrack *pWaveTrack = static_cast<WaveTrack*>(iterWaveTrack.First());
|
||||
while (pWaveTrack)
|
||||
{
|
||||
rate = std::max(rate, pWaveTrack->GetRate());
|
||||
pWaveTrack = static_cast<WaveTrack*>(iterWaveTrack.Next());
|
||||
}
|
||||
|
||||
return rate;
|
||||
}
|
||||
|
||||
const wxString & AudacityProject::SSBL_GetFrequencySelectionFormatName()
|
||||
@ -1290,7 +1301,7 @@ void AudacityProject::SSBL_SetBandwidthSelectionFormatName(const wxString & form
|
||||
void AudacityProject::SSBL_ModifySpectralSelection(double &bottom, double &top, bool done)
|
||||
{
|
||||
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|
||||
double nyq = mRate / 2.0;
|
||||
double nyq = SSBL_GetRate() / 2.0;
|
||||
if (bottom >= 0.0)
|
||||
bottom = std::min(nyq, bottom);
|
||||
if (top >= 0.0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user