1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-19 09:30:06 +02:00

Protect Nyquist against effect-within-effect

The Effect code makes temporary copies of wavetracks.  If Nyquist invokes another effect,
its temporary copy is no longer valid.
My solution is to NOT apply the Nyquist effect results IF some other effect was successfully
invoked in creating them.  I do this by counting the effect invocations.  If it has changed, then
Nyquist output Is not applied back to the track.

The net result is that Nyquist prompt can invoke other effects, or process the audio itself,
but it cannot do both.
This commit is contained in:
James Crook 2018-02-13 12:59:04 +00:00 committed by Paul Licameli
parent 15aad64f7b
commit b93a2e53cc
3 changed files with 14 additions and 2 deletions

View File

@ -71,6 +71,9 @@ greater use in future.
#include <unordered_map> #include <unordered_map>
#endif #endif
// Effect application counter
int Effect::nEffectsDone=0;
static const int kDummyID = 20000; static const int kDummyID = 20000;
static const int kSaveAsID = 20001; static const int kSaveAsID = 20001;
static const int kImportID = 20002; static const int kImportID = 20002;
@ -2267,6 +2270,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult)
// The output list is no longer needed // The output list is no longer needed
mOutputTracks.reset(); mOutputTracks.reset();
mOutputTracksType = Track::None; mOutputTracksType = Track::None;
nEffectsDone++;
} }
void Effect::CountWaveTracks() void Effect::CountWaveTracks()

View File

@ -340,7 +340,6 @@ protected:
bool TrackGroupProgress(int whichGroup, double frac, const wxString & = wxEmptyString); bool TrackGroupProgress(int whichGroup, double frac, const wxString & = wxEmptyString);
int GetNumWaveTracks() { return mNumTracks; } int GetNumWaveTracks() { return mNumTracks; }
int GetNumWaveGroups() { return mNumGroups; } int GetNumWaveGroups() { return mNumGroups; }
// Calculates the start time and selection length in samples // Calculates the start time and selection length in samples
@ -369,6 +368,9 @@ protected:
void CopyInputTracks(); // trackType = Track::Wave void CopyInputTracks(); // trackType = Track::Wave
void CopyInputTracks(int trackType); void CopyInputTracks(int trackType);
// A global counter of all the successful Effect invocations.
static int nEffectsDone;
// For the use of analyzers, which don't need to make output wave tracks, // For the use of analyzers, which don't need to make output wave tracks,
// but may need to add label tracks. // but may need to add label tracks.
class AddedAnalysisTrack { class AddedAnalysisTrack {

View File

@ -488,6 +488,8 @@ bool NyquistEffect::CheckWhetherSkipEffect()
bool NyquistEffect::Process() bool NyquistEffect::Process()
{ {
bool success = true; bool success = true;
int nEffectsSoFar = nEffectsDone;
mProjectChanged = false; mProjectChanged = false;
EffectManager & em = EffectManager::Get(); EffectManager & em = EffectManager::Get();
em.SetSkipStateFlag(false); em.SetSkipStateFlag(false);
@ -790,7 +792,11 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample
dlog.ShowModal(); dlog.ShowModal();
} }
ReplaceProcessedTracks(success); // Has rug been pulled from under us by some effect done within Nyquist??
if( nEffectsSoFar == nEffectsDone )
ReplaceProcessedTracks(success);
else
ReplaceProcessedTracks(false); // Do not use the results.
if (!mProjectChanged) if (!mProjectChanged)
em.SetSkipStateFlag(true); em.SetSkipStateFlag(true);