From c2218d5ddfc2322bd441ad416638ba244d5e36b6 Mon Sep 17 00:00:00 2001 From: lllucius Date: Sat, 29 Nov 2014 23:17:03 +0000 Subject: [PATCH] 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. --- src/AudacityApp.h | 1 + src/Menus.cpp | 24 ++++++++++++++++++++---- src/Project.h | 4 +++- src/effects/EffectManager.cpp | 5 +++++ src/effects/EffectManager.h | 1 + 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/AudacityApp.h b/src/AudacityApp.h index 3558a1fdc..5884659df 100644 --- a/src/AudacityApp.h +++ b/src/AudacityApp.h @@ -87,6 +87,7 @@ enum HaveRecentFiles = 0x02000000, IsNotSyncLockedFlag = 0x04000000, //awd IsSyncLockedFlag = 0x08000000, //awd + IsRealtimeNotActiveFlag= 0x10000000, //lll NoFlagsSpecifed = 0xffffffff }; diff --git a/src/Menus.cpp b/src/Menus.cpp index a72105559..7088ae71e 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -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; } diff --git a/src/Project.h b/src/Project.h index 18697b75b..bb5cdd795 100644 --- a/src/Project.h +++ b/src/Project.h @@ -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); diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index fcee1f34b..22675cdc1 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -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() diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 4847de042..0553333ce 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -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);