1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-11 09:31:13 +02:00

Disable spectral editing effects in one place in Nyquist.cpp...

... by passing invalid frequency values,
rather than by checking the 'view property in each effect.

Spectral editing is now permitted only for appropriate track view types.

But I would suggest reconsideration of the exact conditions in which we do
this.
This commit is contained in:
Paul Licameli 2015-07-25 15:12:18 -04:00
parent 7f7506dbcd
commit 65f1bbe449
5 changed files with 51 additions and 55 deletions

View File

@ -45,7 +45,5 @@
(T (sum (prod env (wet sig f0 f1 fc))
(prod (diff 1.0 env) sig))))))
(if (string-not-equal (get '*TRACK* 'VIEW) "spectral" :end1 8 :end2 8)
"Use this effect in the 'Spectral Selection'\nor 'Spectral Selection log(f)' view."
(catch 'error-message
(multichan-expand #'result *track*)))
(catch 'error-message
(multichan-expand #'result *track*))

View File

@ -55,14 +55,7 @@
(sum (prod env (wet sig control-gain f0 f1)) (prod (diff 1.0 env) sig))))))
(catch 'error-message
(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.~%~%"))
(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.")
(T (setf p-err "")
(if (= control-gain 0) ; Allow dry preview
"Gain is zero. Nothing to do."
(multichan-expand #'result *track*)))))
(setf p-err "")
(if (= control-gain 0) ; Allow dry preview
"Gain is zero. Nothing to do."
(multichan-expand #'result *track*)))

View File

@ -67,16 +67,8 @@
(remprop '*selection* 'high-hz))
(catch 'error-message
(cond
((not (get '*TRACK* 'VIEW)) ; 'View is NIL during Preview
(setf p-err (format nil "This effect requires a frequency selection in the~%~
'Spectral Selection' or 'Spectral Selection log(f)'~%~
track view.~%~%"))
(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.")
(T (setf p-err "")
(if (= control-gain 0) ; Allow dry preview
"Gain is zero. Nothing to do."
(multichan-expand #'result *track*)))))
(setf p-err "")
(if (= control-gain 0) ; Allow dry preview
"Gain is zero. Nothing to do."
(multichan-expand #'result *track*)))

View File

@ -539,34 +539,6 @@ bool NyquistEffect::Process()
Internat::ToString(mT1).c_str());
mProps += wxString::Format(wxT("(putprop '*SELECTION* (list %s) 'TRACKS)\n"), waveTrackList.c_str());
mProps += wxString::Format(wxT("(putprop '*SELECTION* %d 'CHANNELS)\n"), numChannels);
wxString lowHz = wxT("nil");
wxString highHz = wxT("nil");
wxString centerHz = wxT("nil");
wxString bandwidth = wxT("nil");
#if defined(EXPERIMENTAL_SPECTRAL_EDITING)
if (mF0 >= 0.0) {
lowHz.Printf(wxT("(float %s)"), Internat::ToString(mF0).c_str());
}
if (mF1 >= 0.0) {
highHz.Printf(wxT("(float %s)"), Internat::ToString(mF1).c_str());
}
if ((mF0 >= 0.0) && (mF1 >= 0.0)) {
centerHz.Printf(wxT("(float %s)"), Internat::ToString(sqrt(mF0 * mF1)).c_str());
}
if ((mF0 > 0.0) && (mF1 >= mF0)) {
bandwidth.Printf(wxT("(float %s)"), Internat::ToString(log(mF1 / mF0)/log(2.0)).c_str());
}
#endif
mProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'LOW-HZ)\n"), lowHz.c_str());
mProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'CENTER-HZ)\n"), centerHz.c_str());
mProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'HIGH-HZ)\n"), highHz.c_str());
mProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'BANDWIDTH)\n"), bandwidth.c_str());
}
// Keep track of whether the current track is first selected in its sync-lock group
@ -621,6 +593,45 @@ bool NyquistEffect::Process()
nyx_set_os_callback(StaticOSCallback, (void *)this);
nyx_capture_output(StaticOutputCallback, (void *)this);
if (mVersion >= 4)
{
mPerTrackProps = wxEmptyString;
wxString lowHz = wxT("nil");
wxString highHz = wxT("nil");
wxString centerHz = wxT("nil");
wxString bandwidth = wxT("nil");
const WaveTrack::WaveTrackDisplay display = mCurTrack[0]->GetDisplay();
const bool bAllowSpectralEditing =
(display == WaveTrack::SpectralSelectionDisplay) ||
(display == WaveTrack::SpectralSelectionLogDisplay);
if (bAllowSpectralEditing) {
#if defined(EXPERIMENTAL_SPECTRAL_EDITING)
if (mF0 >= 0.0) {
lowHz.Printf(wxT("(float %s)"), Internat::ToString(mF0).c_str());
}
if (mF1 >= 0.0) {
highHz.Printf(wxT("(float %s)"), Internat::ToString(mF1).c_str());
}
if ((mF0 >= 0.0) && (mF1 >= 0.0)) {
centerHz.Printf(wxT("(float %s)"), Internat::ToString(sqrt(mF0 * mF1)).c_str());
}
if ((mF0 > 0.0) && (mF1 >= mF0)) {
bandwidth.Printf(wxT("(float %s)"), Internat::ToString(log(mF1 / mF0) / log(2.0)).c_str());
}
}
#endif
mPerTrackProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'LOW-HZ)\n"), lowHz.c_str());
mPerTrackProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'CENTER-HZ)\n"), centerHz.c_str());
mPerTrackProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'HIGH-HZ)\n"), highHz.c_str());
mPerTrackProps += wxString::Format(wxT("(putprop '*SELECTION* %s 'BANDWIDTH)\n"), bandwidth.c_str());
}
success = ProcessOne();
nyx_capture_output(NULL, (void *)NULL);
@ -765,6 +776,7 @@ bool NyquistEffect::ProcessOne()
if (mVersion >= 4) {
cmd += mProps;
cmd += mPerTrackProps;
// Set the track TYPE and VIEW properties
wxString type;

View File

@ -223,6 +223,7 @@ private:
wxArrayString mCategories;
wxString mProps;
wxString mPerTrackProps;
bool mRestoreSplits;
int mMergeClips;