From 921f40255d6db63b1512df6f1482e04dc2f89c56 Mon Sep 17 00:00:00 2001 From: SteveDaulton Date: Sun, 25 Apr 2021 14:39:41 +0100 Subject: [PATCH] Bug 1091 Spectral Edit effects may have unpredictable results --- src/effects/nyquist/Nyquist.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index fe0084a5a..1710201fd 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -563,30 +563,38 @@ bool NyquistEffect::Init() if (!mIsPrompt && mIsSpectral) { auto *project = FindProject(); - bool bAllowSpectralEditing = true; + bool bAllowSpectralEditing = false; + bool hasSpectral = false; for ( auto t : TrackList::Get( *project ).Selected< const WaveTrack >() ) { const auto displays = WaveTrackView::Get(*t).GetDisplays(); - bool hasSpectral = (displays.end() != std::find( + if (displays.end() != std::find( displays.begin(), displays.end(), - WaveTrackSubView::Type{ WaveTrackViewConstants::Spectrum, {} } - ) ); - if ( !hasSpectral || - !(t->GetSpectrogramSettings().SpectralSelectionEnabled())) { - bAllowSpectralEditing = false; + WaveTrackSubView::Type{ WaveTrackViewConstants::Spectrum, {} })) + hasSpectral = true; + if ( hasSpectral && + (t->GetSpectrogramSettings().SpectralSelectionEnabled())) { + bAllowSpectralEditing = true; break; } } if (!bAllowSpectralEditing || ((mF0 < 0.0) && (mF1 < 0.0))) { - Effect::MessageBox( - XO("To use 'Spectral effects', enable 'Spectral Selection'\n" - "in the track Spectrogram settings and select the\n" - "frequency range for the effect to act on."), + if (!hasSpectral) { + Effect::MessageBox( + XO("Enable track spectrogram view before\n" + "applying 'Spectral' effects."), wxOK | wxICON_EXCLAMATION | wxCENTRE, XO("Error") ); - + } else { + Effect::MessageBox( + XO("To use 'Spectral effects', enable 'Spectral Selection'\n" + "in the track Spectrogram settings and select the\n" + "frequency range for the effect to act on."), + wxOK | wxICON_EXCLAMATION | wxCENTRE, + XO("Error") ); + } return false; } }