1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 08:09:41 +02:00

Only allow one realtime effect at a time

Warning...this required a small hack that allowed updating the
menus even if the toplevel frame is not the project window.  This
is because with the active frame actually becomes the effect dialog
and UpdateMenus() bailed if it wasn't the project frame.

This should be removed when we get multiple effect support.
This commit is contained in:
lllucius 2014-11-29 23:17:03 +00:00
parent c71397beae
commit c2218d5ddf
5 changed files with 30 additions and 5 deletions

View File

@ -87,6 +87,7 @@ enum
HaveRecentFiles = 0x02000000,
IsNotSyncLockedFlag = 0x04000000, //awd
IsSyncLockedFlag = 0x08000000, //awd
IsRealtimeNotActiveFlag= 0x10000000, //lll
NoFlagsSpecifed = 0xffffffff
};

View File

@ -1041,7 +1041,7 @@ void AudacityProject::CreateMenusAndCommands()
PopulateEffectsMenu(c,
EffectTypeProcess,
AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag,
TracksExistFlag);
TracksExistFlag | IsRealtimeNotActiveFlag);
#else
int flags = PROCESS_EFFECT | BUILTIN_EFFECT | PLUGIN_EFFECT | ADVANCED_EFFECT;
// The categories form a DAG, so we start at the roots (the categories
@ -1088,7 +1088,7 @@ void AudacityProject::CreateMenusAndCommands()
PopulateEffectsMenu(c,
EffectTypeAnalyze,
AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag,
TracksExistFlag);
TracksExistFlag | IsRealtimeNotActiveFlag);
#else
flags = ANALYZE_EFFECT | BUILTIN_EFFECT | PLUGIN_EFFECT;
@ -1885,6 +1885,11 @@ wxUint32 AudacityProject::GetUpdateFlags()
else
flags |= IsNotSyncLockedFlag;
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
if (!EffectManager::Get().RealtimeIsActive())
flags |= IsRealtimeNotActiveFlag;
#endif
return flags;
}
@ -1960,7 +1965,9 @@ void AudacityProject::ModifyToolbarMenus()
mCommandManager.Check(wxT("SyncLock"), active);
}
void AudacityProject::UpdateMenus()
// checkActive is a temporary hack that should be removed as soon as we
// get multiple effect preview working
void AudacityProject::UpdateMenus(bool checkActive)
{
//ANSWER-ME: Why UpdateMenus only does active project?
//JKC: Is this test fixing a bug when multiple projects are open?
@ -1968,7 +1975,7 @@ void AudacityProject::UpdateMenus()
if (this != GetActiveProject())
return;
if (!IsActive())
if (checkActive && !IsActive())
return;
wxUint32 flags = GetUpdateFlags();
@ -3249,8 +3256,17 @@ bool AudacityProject::OnEffect(int type,
delete newTrack;
mTrackPanel->Refresh(false);
}
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
// For now, we're limiting realtime preview to a single effect, so
// make sure the menus reflect that fact that one may have just been
// opened.
UpdateMenus(false);
#endif
return false;
}
return true;
}

View File

@ -286,7 +286,9 @@ class AUDACITY_DLL_API AudacityProject: public wxFrame,
static void DeleteClipboard();
static void DeleteAllProjectsDeleteLock();
void UpdateMenus();
// checkActive is a temporary hack that should be removed as soon as we
// get multiple effect preview working
void UpdateMenus(bool checkActive = true);
void UpdatePrefs();
void UpdatePrefsVariables();
void RedrawProject(const bool bForceWaveTracks = false);

View File

@ -487,6 +487,11 @@ void EffectManager::RealtimeSetEffects(const EffectArray & effects)
#endif
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
bool EffectManager::RealtimeIsActive()
{
return mRealtimeEffects.GetCount() != 0;
}
void EffectManager::RealtimeAddEffect(Effect *effect)
{
// Block RealtimeProcess()

View File

@ -97,6 +97,7 @@ class AUDACITY_DLL_API EffectManager
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
// Realtime effect processing
bool RealtimeIsActive();
void RealtimeAddEffect(Effect *effect);
void RealtimeRemoveEffect(Effect *effect);
void RealtimeSetEffects(const EffectArray & mActive);