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

EffectsPrefs queries PluginManager for checkbox settings paths

This commit is contained in:
Paul Licameli 2019-04-08 09:38:27 -04:00
parent 82e3ec6818
commit af3b54ba2a
2 changed files with 106 additions and 52 deletions

View File

@ -1408,15 +1408,20 @@ RegistryPath PluginManager::GetPluginEnabledSetting(
const PluginDescriptor &desc )
{
switch ( desc.GetPluginType() ) {
case PluginTypeEffect: {
case PluginTypeModule: {
// Retrieve optional family symbol that was recorded in
// RegisterPlugin() for the module
auto family = desc.GetEffectFamily();
if ( family.empty() )
if ( family.empty() ) // as for built-in effect and command modules
return {};
else
return wxT('/') + family + wxT("/Enable");
}
case PluginTypeEffect:
// do NOT use GetEffectFamily() for this descriptor, but instead,
// delegate to the plugin descriptor of the provider, which may
// be different (may be empty)
return GetPluginEnabledSetting( desc.GetProviderID() );
default:
return {};
}
@ -1438,6 +1443,7 @@ bool PluginManager::IsPluginRegistered(const PluginPath &path)
const PluginID & PluginManager::RegisterPlugin(ModuleInterface *module)
{
PluginDescriptor & plug = CreatePlugin(GetID(module), module, PluginTypeModule);
plug.SetEffectFamily(module->GetOptionalFamilySymbol().Internal());
plug.SetEnabled(true);
plug.SetValid(true);

View File

@ -26,6 +26,7 @@
#include <wx/defs.h>
#include "../Languages.h"
#include "../PluginManager.h"
#include "../Prefs.h"
#include "../ShuttleGui.h"
@ -65,6 +66,95 @@ void EffectsPrefs::Populate()
// ----------------------- End of main section --------------
}
namespace {
// Rather than hard-code an exhaustive list of effect families in this file,
// pretend we don't know, but discover them instead by querying the module and
// effect managers.
// But then we would like to have prompts with accelerator characters that are
// distinct. We collect some prompts in the following map.
// It is not required that each module be found here, nor that each module
// mentioned here be found.
const std::map< wxString, wxString > SuggestedPrompts{
/* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
{ wxT("AudioUnit"), XO("Audio Unit") },
/* i18n-hint: abbreviates "Linux Audio Developer's Simple Plugin API"
(Application programming interface)
*/
{ wxT("LADSPA"), XO("&LADSPA") },
/* i18n-hint: abbreviates
"Linux Audio Developer's Simple Plugin API (LADSPA) version 2" */
{ wxT("LV2"), XO("LV&2") },
/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
In the translations of this and other strings, you may transliterate the
name into another alphabet. */
{ wxT("Nyquist"), XO("N&yquist") },
/* i18n-hint: Vamp is the proper name of a software protocol for sound analysis.
It is not an abbreviation for anything. See http://vamp-plugins.org */
{ wxT("Vamp"), XO("&Vamp") },
/* i18n-hint: Abbreviates Virtual Studio Technology, an audio software protocol
developed by Steinberg GmbH */
{ wxT("VST"), XO("V&ST") },
};
// Collect needed prompts and settings paths, at most once, on demand
struct Entry {
wxString prompt; // untranslated
wxString setting;
};
static const std::vector< Entry > &GetModuleData()
{
struct ModuleData : public std::vector< Entry > {
ModuleData() {
auto &pm = PluginManager::Get();
for (auto plug = pm.GetFirstPlugin(PluginTypeModule);
plug;
plug = pm.GetNextPlugin(PluginTypeModule)) {
auto internal = plug->GetEffectFamily();
if ( internal.empty() )
continue;
wxString prompt;
auto iter = SuggestedPrompts.find( internal );
if ( iter == SuggestedPrompts.end() )
// For the built-in modules this Msgid includes " Effects",
// but those strings were never shown to the user,
// and the prompts in the table above do not include it.
// If there should be new modules, it is not important for them
// to follow the " Effects" convention, but instead they can
// have shorter msgids.
prompt = plug->GetSymbol().Msgid();
else
prompt = iter->second;
auto setting = pm.GetPluginEnabledSetting( *plug );
push_back( { prompt, setting } );
}
// Guarantee some determinate ordering
std::sort( begin(), end(),
[]( const Entry &a, const Entry &b ){
return a.setting < b.setting;
}
);
}
};
static ModuleData theData;
return theData;
}
}
void EffectsPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.SetBorder(2);
@ -72,56 +162,14 @@ void EffectsPrefs::PopulateOrExchange(ShuttleGui & S)
S.StartStatic(_("Enable Effects"));
{
#if USE_AUDIO_UNITS
/* i18n-hint: Audio Unit is the name of an Apple audio software protocol */
S.TieCheckBox(_("Audio Unit"),
wxT("/AudioUnit/Enable"),
true);
#endif
// JKC: LADSPA, LV2, Nyquist, VST, VAMP should not be translated.
#if USE_LADSPA
/* i18n-hint: abbreviates "Linux Audio Developer's Simple Plugin API"
(Application programming interface)
*/
S.TieCheckBox(_("&LADSPA"),
wxT("/LADSPA/Enable"),
true);
#endif
#if USE_LV2
/* i18n-hint: abbreviates
"Linux Audio Developer's Simple Plugin API (LADSPA) version 2" */
S.TieCheckBox(_("LV&2"),
wxT("/LV2/Enable"),
true);
#endif
#if USE_NYQUIST
/* i18n-hint: "Nyquist" is an embedded interpreted programming language in
Audacity, named in honor of the Swedish-American Harry Nyquist (or Nyqvist).
In the translations of this and other strings, you may transliterate the
name into another alphabet. */
S.TieCheckBox(_("N&yquist"),
wxT("/Nyquist/Enable"),
true);
#endif
#if USE_VAMP
/* i18n-hint: Vamp is the proper name of a software protocol for sound analysis.
It is not an abbreviation for anything. See http://vamp-plugins.org */
S.TieCheckBox(_("&Vamp"),
wxT("/Vamp/Enable"),
true);
#endif
#if USE_VST
/* i18n-hint: Abbreviates Virtual Studio Technology, an audio software protocol
developed by Steinberg GmbH */
S.TieCheckBox(_("V&ST"),
wxT("/VST/Enable"),
true);
#endif
for ( const auto &entry : GetModuleData() )
{
S.TieCheckBox(
GetCustomTranslation( entry.prompt ),
entry.setting,
true
);
}
}
S.EndStatic();