From 65f1bbe449574cb84484b2f4a4e144afb5f82c14 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 25 Jul 2015 15:12:18 -0400 Subject: [PATCH] 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. --- plug-ins/SpectralEditMulti.ny | 6 +-- plug-ins/SpectralEditParametricEQ.ny | 15 ++---- plug-ins/SpectralEditShelves.ny | 16 ++----- src/effects/nyquist/Nyquist.cpp | 68 ++++++++++++++++------------ src/effects/nyquist/Nyquist.h | 1 + 5 files changed, 51 insertions(+), 55 deletions(-) diff --git a/plug-ins/SpectralEditMulti.ny b/plug-ins/SpectralEditMulti.ny index 57175dcf7..c609fd20d 100644 --- a/plug-ins/SpectralEditMulti.ny +++ b/plug-ins/SpectralEditMulti.ny @@ -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*)) diff --git a/plug-ins/SpectralEditParametricEQ.ny b/plug-ins/SpectralEditParametricEQ.ny index af5410000..45671cf6d 100644 --- a/plug-ins/SpectralEditParametricEQ.ny +++ b/plug-ins/SpectralEditParametricEQ.ny @@ -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*))) diff --git a/plug-ins/SpectralEditShelves.ny b/plug-ins/SpectralEditShelves.ny index 512c4dbb2..6f523023c 100644 --- a/plug-ins/SpectralEditShelves.ny +++ b/plug-ins/SpectralEditShelves.ny @@ -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*))) diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 244067e6f..718cd1ba4 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -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; diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 47b9e2246..794275fef 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -223,6 +223,7 @@ private: wxArrayString mCategories; wxString mProps; + wxString mPerTrackProps; bool mRestoreSplits; int mMergeClips;