From a74de1398f9920f31bf4c512fb3b2abe28e516b9 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 15 Oct 2020 14:29:34 -0400 Subject: [PATCH] StereoToMono also in effects module, but should it remain an effect? --- .../effects/mod-effect-classes/CMakeLists.txt | 2 + .../mod-effect-classes}/StereoToMono.cpp | 48 ++++++++++++++++++- .../mod-effect-classes}/StereoToMono.h | 0 src/CMakeLists.txt | 2 - src/menus/TrackMenus.cpp | 26 +--------- 5 files changed, 50 insertions(+), 28 deletions(-) rename {src/effects => modules/effects/mod-effect-classes}/StereoToMono.cpp (77%) rename {src/effects => modules/effects/mod-effect-classes}/StereoToMono.h (100%) diff --git a/modules/effects/mod-effect-classes/CMakeLists.txt b/modules/effects/mod-effect-classes/CMakeLists.txt index e70b59113152..eb03d6e65bcd 100644 --- a/modules/effects/mod-effect-classes/CMakeLists.txt +++ b/modules/effects/mod-effect-classes/CMakeLists.txt @@ -73,6 +73,8 @@ list( APPEND SOURCES ScienFilter.h Silence.cpp Silence.h + StereoToMono.cpp + StereoToMono.h ToneGen.cpp ToneGen.h TruncSilence.cpp diff --git a/src/effects/StereoToMono.cpp b/modules/effects/mod-effect-classes/StereoToMono.cpp similarity index 77% rename from src/effects/StereoToMono.cpp rename to modules/effects/mod-effect-classes/StereoToMono.cpp index f3714b9d7f90..e2814204f613 100644 --- a/src/effects/StereoToMono.cpp +++ b/modules/effects/mod-effect-classes/StereoToMono.cpp @@ -13,7 +13,6 @@ *//*******************************************************************/ - #include "StereoToMono.h" #include "EffectOutputTracks.h" #include "LoadEffects.h" @@ -179,3 +178,50 @@ bool EffectStereoToMono::IsHiddenFromMenus() const { return true; } + +// Attach a menu item +#include "CommonCommandFlags.h" +#include "PluginManager.h" +#include "CommandManager.h" +#include "effects/EffectManager.h" +#include "effects/EffectUI.h" + +namespace { +void OnStereoToMono(const CommandContext &context) +{ + EffectUI::DoEffect( + EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), + context, + EffectManager::kConfigured); +} + +using namespace MenuRegistry; +auto MenuItem() +{ + static auto item = std::shared_ptr{ + // Delayed evaluation + // Stereo to Mono is an oddball command that is also subject to control + // by the plug-in manager, as if an effect. Decide whether to show or + // hide it. + Items( "", + [](AudacityProject&) -> std::unique_ptr { + const PluginID ID = + EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")); + const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID); + if (plug && plug->IsEnabled()) + return Command( wxT("Stereo to Mono"), + XXO("Mix Stereo Down to &Mono"), OnStereoToMono, + AudioIONotBusyFlag() | StereoRequiredFlag() | + WaveTracksSelectedFlag(), Options{} ); + else + return {}; + } + ) }; + return item; +} + +AttachedItem sAttachment{ + Indirect(MenuItem()), + { wxT("Tracks/Mix/Mix"), { OrderingHint::Begin, {} } } +}; +} diff --git a/src/effects/StereoToMono.h b/modules/effects/mod-effect-classes/StereoToMono.h similarity index 100% rename from src/effects/StereoToMono.h rename to modules/effects/mod-effect-classes/StereoToMono.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f395f761e74c..4e77f24b5a63 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -331,8 +331,6 @@ list( APPEND SOURCES effects/StatefulPerTrackEffect.h effects/StatelessPerTrackEffect.cpp effects/StatelessPerTrackEffect.h - effects/StereoToMono.cpp - effects/StereoToMono.h effects/TwoPassSimpleMono.cpp effects/TwoPassSimpleMono.h diff --git a/src/menus/TrackMenus.cpp b/src/menus/TrackMenus.cpp index 13fda8f12abc..f9689df2ea7a 100644 --- a/src/menus/TrackMenus.cpp +++ b/src/menus/TrackMenus.cpp @@ -548,14 +548,6 @@ namespace { // Menu handler functions -void OnStereoToMono(const CommandContext &context) -{ - EffectUI::DoEffect( - EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), - context, - EffectManager::kConfigured); -} - void OnMixAndRender(const CommandContext &context) { auto &project = context.project; @@ -1130,24 +1122,8 @@ auto TracksMenu() ////////////////////////////////////////////////////////////////////////// - Section( "", + Section( "Mix", Menu( wxT("Mix"), XXO("Mi&x"), - // Delayed evaluation - // Stereo to Mono is an oddball command that is also subject to control - // by the plug-in manager, as if an effect. Decide whether to show or - // hide it. - [](AudacityProject&) -> std::unique_ptr { - const PluginID ID = - EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")); - const PluginDescriptor *plug = PluginManager::Get().GetPlugin(ID); - if (plug && plug->IsEnabled()) - return Command( wxT("Stereo to Mono"), - XXO("Mix Stereo Down to &Mono"), OnStereoToMono, - AudioIONotBusyFlag() | StereoRequiredFlag() | - WaveTracksSelectedFlag(), Options{} ); - else - return {}; - }, Command( wxT("MixAndRender"), XXO("Mi&x and Render"), OnMixAndRender, AudioIONotBusyFlag() | WaveTracksSelectedFlag() ),