2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
LoadEffects.cpp
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
2018-03-06 21:42:58 +00:00
|
|
|
**************************************************************************//**
|
Automation: AudacityCommand
This is a squash of 50 commits.
This merges the capabilities of BatchCommands and Effects using a new
AudacityCommand class. AudacityCommand provides one function to specify the
parameters, and then we leverage that one function in automation, whether by chains,
mod-script-pipe or (future) Nyquist.
- Now have AudacityCommand which is using the same mechanism as Effect
- Has configurable parameters
- Has data-entry GUI (built using shuttle GUI)
- Registers with PluginManager.
- Menu commands now provided in chains, and to python batch.
- Tested with Zoom Toggle.
- ShuttleParams now can set, get, set defaults, validate and specify
the parameters.
- Bugfix: Don't overwrite values with defaults first time out.
- Add DefineParams function for all built-in effects.
- Extend CommandContext to carry output channels for results.
We abuse EffectsManager. It handles both Effects and
AudacityCommands now. In time an Effect should become a special case of
AudacityCommand and we'll split and rename the EffectManager class.
- Don't use 'default' as a parameter name.
- Massive renaming for CommandDefinitionInterface
- EffectIdentInterface becomes EffectDefinitionInterface
- EffectAutomationParameters becomes CommandAutomationParameters
- PluginType is now a bit field.
This way we can search for related types at the same time.
- Most old batch commands made into AudacityCommands.
The ones that weren't are for a reason. They are used by mod-script-pipe
to carry commands and responses across from a non-GUI thread to the GUI
thread.
- Major tidy up of ScreenshotCommand
- Reworking of SelectCommand
- GetPreferenceCommand and SetPreferenceCommand
- GetTrackInfo and SetTrackInfo
- GetInfoCommand
- Help, Open, Save, Import and Export commands.
- Removed obsolete commands ExecMenu, GetProjectInfo and SetProjectInfo
which are now better handled by other commands.
- JSONify "GetInfo: Commands" output, i.e. commas in the right places.
- General work on better Doxygen.
- Lyrics -> LyricsPanel
- Meter -> MeterPanel
- Updated Linux makefile.
- Scripting commands added into Extra menu.
- Distinct names for previously duplicated find-clipping parameters.
- Fixed longstanding error with erroneous status field number which
previously caused an ASSERT in debug.
- Sensible formatting of numbers in Chains, 0.1 not 0.1000000000137
2018-01-14 18:51:41 +00:00
|
|
|
\class BuiltinEffectsModule
|
|
|
|
\brief Internal module to auto register all built in effects.
|
2018-03-06 21:42:58 +00:00
|
|
|
*****************************************************************************/
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2021-05-09 15:16:56 +00:00
|
|
|
|
2018-11-10 19:47:12 +00:00
|
|
|
#include "LoadEffects.h"
|
2018-11-11 02:40:37 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#include "../Prefs.h"
|
|
|
|
|
2020-01-19 18:37:10 +00:00
|
|
|
#include "Effect.h"
|
2021-05-13 18:53:19 +00:00
|
|
|
#include "ModuleManager.h"
|
2020-01-19 18:37:10 +00:00
|
|
|
|
|
|
|
static bool sInitialized = false;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2019-01-17 23:31:08 +00:00
|
|
|
struct BuiltinEffectsModule::Entry {
|
2021-05-14 17:10:48 +00:00
|
|
|
ComponentInterfaceSymbol name;
|
2019-01-17 23:31:08 +00:00
|
|
|
BuiltinEffectsModule::Factory factory;
|
|
|
|
bool excluded;
|
|
|
|
|
|
|
|
using Entries = std::vector< Entry >;
|
|
|
|
static Entries &Registry()
|
|
|
|
{
|
|
|
|
static Entries result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void BuiltinEffectsModule::DoRegistration(
|
|
|
|
const ComponentInterfaceSymbol &name, const Factory &factory, bool excluded )
|
|
|
|
{
|
2020-01-19 18:37:10 +00:00
|
|
|
wxASSERT( !sInitialized );
|
2021-05-14 17:10:48 +00:00
|
|
|
Entry::Registry().emplace_back( Entry{ name, factory, excluded } );
|
2019-01-17 23:31:08 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 03:53:42 +00:00
|
|
|
// ============================================================================
|
|
|
|
// Module registration entry point
|
|
|
|
//
|
|
|
|
// This is the symbol that Audacity looks for when the module is built as a
|
|
|
|
// dynamic library.
|
|
|
|
//
|
|
|
|
// When the module is builtin to Audacity, we use the same function, but it is
|
|
|
|
// declared static so as not to clash with other builtin modules.
|
|
|
|
// ============================================================================
|
|
|
|
DECLARE_MODULE_ENTRY(AudacityModule)
|
|
|
|
{
|
|
|
|
// Create and register the importer
|
2016-03-31 14:33:28 +00:00
|
|
|
// Trust the module manager not to leak this
|
2021-05-13 20:20:44 +00:00
|
|
|
return safenew BuiltinEffectsModule();
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Register this as a builtin module
|
|
|
|
// ============================================================================
|
|
|
|
DECLARE_BUILTIN_MODULE(BuiltinsEffectBuiltin);
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// BuiltinEffectsModule
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2021-05-13 20:20:44 +00:00
|
|
|
BuiltinEffectsModule::BuiltinEffectsModule()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BuiltinEffectsModule::~BuiltinEffectsModule()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
2018-11-02 15:31:44 +00:00
|
|
|
// ComponentInterface implementation
|
2015-04-17 03:53:42 +00:00
|
|
|
// ============================================================================
|
|
|
|
|
2019-02-28 00:58:02 +00:00
|
|
|
PluginPath BuiltinEffectsModule::GetPath()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2021-05-13 20:20:44 +00:00
|
|
|
return {};
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
2018-11-02 15:31:44 +00:00
|
|
|
ComponentInterfaceSymbol BuiltinEffectsModule::GetSymbol()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2015-04-19 03:49:05 +00:00
|
|
|
return XO("Builtin Effects");
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 18:16:09 +00:00
|
|
|
VendorSymbol BuiltinEffectsModule::GetVendor()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2015-04-19 03:49:05 +00:00
|
|
|
return XO("The Audacity Team");
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString BuiltinEffectsModule::GetVersion()
|
|
|
|
{
|
|
|
|
// This "may" be different if this were to be maintained as a separate DLL
|
|
|
|
return AUDACITY_VERSION_STRING;
|
|
|
|
}
|
|
|
|
|
2019-12-08 18:53:48 +00:00
|
|
|
TranslatableString BuiltinEffectsModule::GetDescription()
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-12-08 18:53:48 +00:00
|
|
|
return XO("Provides builtin effects to Audacity");
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// ModuleInterface implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
bool BuiltinEffectsModule::Initialize()
|
|
|
|
{
|
2020-01-19 18:37:10 +00:00
|
|
|
for ( const auto &entry : Entry::Registry() ) {
|
2021-05-14 17:10:48 +00:00
|
|
|
auto path = wxString(BUILTIN_EFFECT_PREFIX) + entry.name.Internal();
|
2020-01-19 18:37:10 +00:00
|
|
|
mEffects[ path ] = &entry;
|
2015-05-22 15:15:47 +00:00
|
|
|
}
|
2020-01-19 18:37:10 +00:00
|
|
|
sInitialized = true;
|
2015-04-17 03:53:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BuiltinEffectsModule::Terminate()
|
|
|
|
{
|
|
|
|
// Nothing to do here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-04-08 13:29:42 +00:00
|
|
|
EffectFamilySymbol BuiltinEffectsModule::GetOptionalFamilySymbol()
|
|
|
|
{
|
|
|
|
// Returns empty, because there should not be an option in Preferences to
|
|
|
|
// disable the built-in effects.
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2019-03-08 20:06:24 +00:00
|
|
|
const FileExtensions &BuiltinEffectsModule::GetFileExtensions()
|
|
|
|
{
|
|
|
|
static FileExtensions empty;
|
|
|
|
return empty;
|
|
|
|
}
|
|
|
|
|
2015-05-12 15:41:22 +00:00
|
|
|
bool BuiltinEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-12-18 05:27:40 +00:00
|
|
|
TranslatableString ignoredErrMsg;
|
2020-01-19 18:37:10 +00:00
|
|
|
for (const auto &pair : mEffects)
|
2015-05-12 15:41:22 +00:00
|
|
|
{
|
2020-01-19 18:37:10 +00:00
|
|
|
const auto &path = pair.first;
|
2021-05-14 17:10:48 +00:00
|
|
|
if (!pm.IsPluginRegistered(path, &pair.second->name.Msgid()))
|
2015-05-12 15:41:22 +00:00
|
|
|
{
|
2021-05-14 17:10:48 +00:00
|
|
|
if ( pair.second->excluded )
|
|
|
|
continue;
|
2017-12-27 15:40:38 +00:00
|
|
|
// No checking of error ?
|
2017-12-28 23:29:03 +00:00
|
|
|
DiscoverPluginsAtPath(path, ignoredErrMsg,
|
|
|
|
PluginManagerInterface::DefaultRegistrationCallback);
|
2015-05-12 15:41:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We still want to be called during the normal registration process
|
2015-04-17 03:53:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-02-28 00:58:02 +00:00
|
|
|
PluginPaths BuiltinEffectsModule::FindPluginPaths(PluginManagerInterface & WXUNUSED(pm))
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2020-01-19 18:37:10 +00:00
|
|
|
PluginPaths names;
|
|
|
|
for ( const auto &pair : mEffects )
|
|
|
|
names.push_back( pair.first );
|
|
|
|
return names;
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
2017-12-28 23:29:03 +00:00
|
|
|
unsigned BuiltinEffectsModule::DiscoverPluginsAtPath(
|
2019-12-18 05:27:40 +00:00
|
|
|
const PluginPath & path, TranslatableString &errMsg,
|
2017-12-28 23:29:03 +00:00
|
|
|
const RegistrationCallback &callback)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2019-12-18 05:27:40 +00:00
|
|
|
errMsg = {};
|
2016-03-31 13:24:26 +00:00
|
|
|
auto effect = Instantiate(path);
|
2015-04-17 03:53:42 +00:00
|
|
|
if (effect)
|
|
|
|
{
|
2018-01-01 01:03:52 +00:00
|
|
|
if (callback)
|
|
|
|
callback(this, effect.get());
|
2017-12-28 23:29:03 +00:00
|
|
|
return 1;
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 05:27:40 +00:00
|
|
|
errMsg = XO("Unknown built-in effect name");
|
2017-12-28 23:29:03 +00:00
|
|
|
return 0;
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-28 00:58:02 +00:00
|
|
|
bool BuiltinEffectsModule::IsPluginValid(const PluginPath & path, bool bFast)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
2017-02-05 20:27:56 +00:00
|
|
|
// bFast is unused as checking in the list is fast.
|
2018-02-15 12:11:45 +00:00
|
|
|
static_cast<void>(bFast);
|
2020-01-19 18:37:10 +00:00
|
|
|
return mEffects.find( path ) != mEffects.end();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 17:08:36 +00:00
|
|
|
std::unique_ptr<ComponentInterface>
|
|
|
|
BuiltinEffectsModule::CreateInstance(const PluginPath & path)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2016-03-31 13:42:16 +00:00
|
|
|
// Acquires a resource for the application.
|
2021-06-18 17:08:36 +00:00
|
|
|
return Instantiate(path);
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// BuiltinEffectsModule implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
2019-02-28 00:58:02 +00:00
|
|
|
std::unique_ptr<Effect> BuiltinEffectsModule::Instantiate(const PluginPath & path)
|
2015-04-17 03:53:42 +00:00
|
|
|
{
|
|
|
|
wxASSERT(path.StartsWith(BUILTIN_EFFECT_PREFIX));
|
2020-01-19 18:37:10 +00:00
|
|
|
auto iter = mEffects.find( path );
|
|
|
|
if ( iter != mEffects.end() )
|
|
|
|
return iter->second->factory();
|
|
|
|
|
|
|
|
wxASSERT( false );
|
2016-04-10 18:15:51 +00:00
|
|
|
return nullptr;
|
2015-04-17 03:53:42 +00:00
|
|
|
}
|