Skip to content

Commit

Permalink
StereoToMono also in effects module, but should it remain an effect?
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Apr 11, 2024
1 parent 2facda3 commit a74de13
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 28 deletions.
2 changes: 2 additions & 0 deletions modules/effects/mod-effect-classes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ list( APPEND SOURCES
ScienFilter.h
Silence.cpp
Silence.h
StereoToMono.cpp
StereoToMono.h
ToneGen.cpp
ToneGen.h
TruncSilence.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*//*******************************************************************/


#include "StereoToMono.h"
#include "EffectOutputTracks.h"
#include "LoadEffects.h"
Expand Down Expand Up @@ -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<CommandItem> {
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, {} } }
};
}
File renamed without changes.
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 1 addition & 25 deletions src/menus/TrackMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<CommandItem> {
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() ),
Expand Down

0 comments on commit a74de13

Please sign in to comment.