1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Distinguish Effect Family Id from Effect Family Name...

... and the distinction makes a difference only for built-in effects.

"Id" is meant to persist in pluginregistry.cfg, and is constrained by how
previous versions of Audacity were written.

"Name" is not persistent, so we have the liberty to change it, as done here
for the built-ins.
This commit is contained in:
Paul Licameli 2018-01-15 23:40:42 -05:00
parent d1d78fd56e
commit 097764d94c
17 changed files with 91 additions and 44 deletions

View File

@ -64,7 +64,10 @@ public:
virtual ~EffectIdentInterface() {}; virtual ~EffectIdentInterface() {};
virtual EffectType GetType() = 0; virtual EffectType GetType() = 0;
virtual wxString GetFamily() = 0; // Returns a string for internal uses only that may persist in config files:
virtual wxString GetFamilyId() = 0;
// Returns a user-visible string:
virtual wxString GetFamilyName() = 0;
// These should move to the "EffectClientInterface" class once all // These should move to the "EffectClientInterface" class once all
// effects have been converted. // effects have been converted.

View File

@ -1221,7 +1221,7 @@ void PluginDescriptor::SetValid(bool valid)
// Effects // Effects
wxString PluginDescriptor::GetUntranslatedEffectFamily() const wxString PluginDescriptor::GetEffectFamilyId() const
{ {
return mEffectFamily; return mEffectFamily;
} }
@ -1290,7 +1290,7 @@ bool PluginDescriptor::IsEffectAutomatable() const
return mEffectAutomatable; return mEffectAutomatable;
} }
void PluginDescriptor::SetEffectFamily(const wxString & family) void PluginDescriptor::SetEffectFamilyId(const wxString & family)
{ {
mEffectFamily = family; mEffectFamily = family;
} }
@ -1439,7 +1439,7 @@ const PluginID & PluginManager::RegisterPlugin(ModuleInterface *provider, Effect
plug.SetProviderID(PluginManager::GetID(provider)); plug.SetProviderID(PluginManager::GetID(provider));
plug.SetEffectType(effect->GetType()); plug.SetEffectType(effect->GetType());
plug.SetEffectFamily(effect->GetFamily()); plug.SetEffectFamilyId(effect->GetFamilyId());
plug.SetEffectInteractive(effect->IsInteractive()); plug.SetEffectInteractive(effect->IsInteractive());
plug.SetEffectDefault(effect->IsDefault()); plug.SetEffectDefault(effect->IsDefault());
plug.SetEffectRealtime(effect->SupportsRealtime()); plug.SetEffectRealtime(effect->SupportsRealtime());
@ -2105,7 +2105,7 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type)
{ {
continue; continue;
} }
plug.SetEffectFamily(strVal); plug.SetEffectFamilyId(strVal);
// Is it a default (above the line) effect and bypass group if not found // Is it a default (above the line) effect and bypass group if not found
if (!pRegistry->Read(KEY_EFFECTDEFAULT, &boolVal)) if (!pRegistry->Read(KEY_EFFECTDEFAULT, &boolVal))
@ -2277,7 +2277,7 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type)
stype = KEY_EFFECTTYPE_HIDDEN; stype = KEY_EFFECTTYPE_HIDDEN;
} }
pRegistry->Write(KEY_EFFECTTYPE, stype); pRegistry->Write(KEY_EFFECTTYPE, stype);
pRegistry->Write(KEY_EFFECTFAMILY, plug.GetUntranslatedEffectFamily()); pRegistry->Write(KEY_EFFECTFAMILY, plug.GetEffectFamilyId());
pRegistry->Write(KEY_EFFECTDEFAULT, plug.IsEffectDefault()); pRegistry->Write(KEY_EFFECTDEFAULT, plug.IsEffectDefault());
pRegistry->Write(KEY_EFFECTINTERACTIVE, plug.IsEffectInteractive()); pRegistry->Write(KEY_EFFECTINTERACTIVE, plug.IsEffectInteractive());
pRegistry->Write(KEY_EFFECTREALTIME, plug.IsEffectRealtime()); pRegistry->Write(KEY_EFFECTREALTIME, plug.IsEffectRealtime());
@ -2354,7 +2354,7 @@ void PluginManager::CheckForUpdates(bool bFast)
continue; continue;
} }
if ( (plugType == PluginTypeModule) ) if ( plugType == PluginTypeModule )
{ {
if( bFast ) if( bFast )
{ {
@ -2416,7 +2416,7 @@ const PluginID & PluginManager::RegisterPlugin(EffectIdentInterface *effect)
PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, PluginTypeEffect); PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, PluginTypeEffect);
plug.SetEffectType(effect->GetType()); plug.SetEffectType(effect->GetType());
plug.SetEffectFamily(effect->GetFamily()); plug.SetEffectFamilyId(effect->GetFamilyId());
plug.SetEffectInteractive(effect->IsInteractive()); plug.SetEffectInteractive(effect->IsInteractive());
plug.SetEffectDefault(effect->IsDefault()); plug.SetEffectDefault(effect->IsDefault());
plug.SetEffectRealtime(effect->SupportsRealtime()); plug.SetEffectRealtime(effect->SupportsRealtime());
@ -2476,7 +2476,7 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(PluginType type)
if (type == PluginTypeEffect) if (type == PluginTypeEffect)
{ {
// This preference may be written by EffectsPrefs // This preference may be written by EffectsPrefs
gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); gPrefs->Read(plug.GetEffectFamilyId() + wxT("/Enable"), &familyEnabled, true);
} }
if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled)
{ {
@ -2496,7 +2496,7 @@ const PluginDescriptor *PluginManager::GetNextPlugin(PluginType type)
if (type == PluginTypeEffect) if (type == PluginTypeEffect)
{ {
// This preference may be written by EffectsPrefs // This preference may be written by EffectsPrefs
gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); gPrefs->Read(plug.GetEffectFamilyId() + wxT("/Enable"), &familyEnabled, true);
} }
if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled) if (plug.IsValid() && plug.IsEnabled() && plug.GetPluginType() == type && familyEnabled)
{ {
@ -2517,7 +2517,7 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty
bool familyEnabled; bool familyEnabled;
// This preference may be written by EffectsPrefs // This preference may be written by EffectsPrefs
gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); gPrefs->Read(plug.GetEffectFamilyId() + wxT("/Enable"), &familyEnabled, true);
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
{ {
if (plug.IsInstantiated() && em.IsHidden(plug.GetID())) if (plug.IsInstantiated() && em.IsHidden(plug.GetID()))
@ -2541,7 +2541,7 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ
PluginDescriptor & plug = mPluginsIter->second; PluginDescriptor & plug = mPluginsIter->second;
bool familyEnabled; bool familyEnabled;
// This preference may be written by EffectsPrefs // This preference may be written by EffectsPrefs
gPrefs->Read(plug.GetUntranslatedEffectFamily() + wxT("/Enable"), &familyEnabled, true); gPrefs->Read(plug.GetEffectFamilyId() + wxT("/Enable"), &familyEnabled, true);
if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled) if (plug.IsValid() && plug.IsEnabled() && plug.GetEffectType() == type && familyEnabled)
{ {
if (plug.IsInstantiated() && em.IsHidden(plug.GetID())) if (plug.IsInstantiated() && em.IsHidden(plug.GetID()))
@ -2634,7 +2634,7 @@ PluginID PluginManager::GetID(EffectIdentInterface *effect)
{ {
return wxString::Format(wxT("%s_%s_%s_%s_%s"), return wxString::Format(wxT("%s_%s_%s_%s_%s"),
GetPluginTypeString(PluginTypeEffect), GetPluginTypeString(PluginTypeEffect),
effect->GetFamily(), effect->GetFamilyId(),
effect->GetVendor(), effect->GetVendor(),
effect->GetName(), effect->GetName(),
effect->GetPath()); effect->GetPath());
@ -2931,7 +2931,7 @@ wxString PluginManager::SettingsPath(const PluginID & ID, bool shared)
wxString id = GetPluginTypeString(plug.GetPluginType()) + wxString id = GetPluginTypeString(plug.GetPluginType()) +
wxT("_") + wxT("_") +
plug.GetUntranslatedEffectFamily() + // is empty for non-Effects plug.GetEffectFamilyId() + // is empty for non-Effects
wxT("_") + wxT("_") +
plug.GetUntranslatedVendor() + plug.GetUntranslatedVendor() +
wxT("_") + wxT("_") +

View File

@ -89,7 +89,7 @@ public:
// Effect plugins only // Effect plugins only
wxString GetUntranslatedEffectFamily() const; wxString GetEffectFamilyId() const;
wxString GetTranslatedEffectFamily() const; wxString GetTranslatedEffectFamily() const;
EffectType GetEffectType() const; EffectType GetEffectType() const;
bool IsEffectDefault() const; bool IsEffectDefault() const;
@ -99,7 +99,7 @@ public:
bool IsEffectAutomatable() const; bool IsEffectAutomatable() const;
// "family" should be an untranslated string wrapped in wxT() // "family" should be an untranslated string wrapped in wxT()
void SetEffectFamily(const wxString & family); void SetEffectFamilyId(const wxString & family);
void SetEffectType(EffectType type); void SetEffectType(EffectType type);
void SetEffectDefault(bool dflt); void SetEffectDefault(bool dflt);
void SetEffectInteractive(bool interactive); void SetEffectInteractive(bool interactive);

View File

@ -213,11 +213,11 @@ wxString Effect::GetDescription()
return wxEmptyString; return wxEmptyString;
} }
wxString Effect::GetFamily() wxString Effect::GetFamilyId()
{ {
if (mClient) if (mClient)
{ {
return mClient->GetFamily(); return mClient->GetFamilyId();
} }
// PRL: In 2.2.2 we wanted to change the user-visible name to // PRL: In 2.2.2 we wanted to change the user-visible name to
@ -232,6 +232,16 @@ wxString Effect::GetFamily()
return XO("Audacity"); return XO("Audacity");
} }
wxString Effect::GetFamilyName()
{
if (mClient)
{
return mClient->GetFamilyName();
}
return XO("Built-in");
}
bool Effect::IsInteractive() bool Effect::IsInteractive()
{ {
if (mClient) if (mClient)
@ -2480,7 +2490,7 @@ void Effect::Preview(bool dryOnly)
wxWindow *FocusDialog = wxWindow::FindFocus(); wxWindow *FocusDialog = wxWindow::FindFocus();
double previewDuration; double previewDuration;
bool isNyquist = (GetFamily().IsSameAs(NYQUISTEFFECTS_FAMILY))? true : false; bool isNyquist = GetFamilyId().IsSameAs(NYQUISTEFFECTS_FAMILY);
bool isGenerator = GetType() == EffectTypeGenerate; bool isGenerator = GetType() == EffectTypeGenerate;
// Mix a few seconds of audio from all of the tracks // Mix a few seconds of audio from all of the tracks
@ -3271,7 +3281,7 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
void EffectUIHost::OnHelp(wxCommandEvent & WXUNUSED(event)) void EffectUIHost::OnHelp(wxCommandEvent & WXUNUSED(event))
{ {
if (mEffect->GetFamily().IsSameAs(NYQUISTEFFECTS_FAMILY) && (mEffect->ManualPage().IsEmpty())) { if (mEffect->GetFamilyId().IsSameAs(NYQUISTEFFECTS_FAMILY) && (mEffect->ManualPage().IsEmpty())) {
// Old ShowHelp required when there is no on-line manual. // Old ShowHelp required when there is no on-line manual.
// Always use default web browser to allow full-featured HTML pages. // Always use default web browser to allow full-featured HTML pages.
HelpSystem::ShowHelp(FindWindow(wxID_HELP), mEffect->HelpPage(), wxEmptyString, true, true); HelpSystem::ShowHelp(FindWindow(wxID_HELP), mEffect->HelpPage(), wxEmptyString, true, true);
@ -3358,16 +3368,8 @@ void EffectUIHost::OnMenu(wxCommandEvent & WXUNUSED(evt))
{ {
auto sub = std::make_unique<wxMenu>(); auto sub = std::make_unique<wxMenu>();
auto type = mEffect->GetFamily(); sub->Append(kDummyID, wxString::Format(_("Type: %s"),
// PRL: 2.2.2 hack to change the visible name without breaking ::wxGetTranslation( mEffect->GetFamilyName() )));
// compatibility of pluginsettings.cfg; redo this better
// See also PluginDescriptor::GetTranslatedEffectFamily
if (type == wxT("Audacity"))
type = XO("Built-in");
// And now, also, translate this (what 2.2.1 neglected)
type = wxGetTranslation(type);
sub->Append(kDummyID, wxString::Format(_("Type: %s"), type));
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetTranslatedName())); sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetTranslatedName()));
sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion())); sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion()));
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor())); sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor()));

View File

@ -87,7 +87,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler,
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; // returns UNTRANSLATED wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;
bool IsLegacy() override; bool IsLegacy() override;

View File

@ -234,7 +234,12 @@ public:
return mDescription; return mDescription;
} }
wxString GetFamily() override wxString GetFamilyId() override
{
return VSTPLUGINTYPE;
}
wxString GetFamilyName() override
{ {
return VSTPLUGINTYPE; return VSTPLUGINTYPE;
} }
@ -1246,7 +1251,12 @@ EffectType VSTEffect::GetType()
} }
wxString VSTEffect::GetFamily() wxString VSTEffect::GetFamilyId()
{
return VSTPLUGINTYPE;
}
wxString VSTEffect::GetFamilyName()
{ {
return VSTPLUGINTYPE; return VSTPLUGINTYPE;
} }

View File

@ -95,7 +95,8 @@ class VSTEffect final : public wxEvtHandler,
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;
bool IsLegacy() override; bool IsLegacy() override;

View File

@ -941,7 +941,12 @@ EffectType AudioUnitEffect::GetType()
return EffectTypeProcess; return EffectTypeProcess;
} }
wxString AudioUnitEffect::GetFamily() wxString AudioUnitEffect::GetFamilyId()
{
return AUDIOUNITEFFECTS_FAMILY;
}
wxString AudioUnitEffect::GetFamilyName()
{ {
return AUDIOUNITEFFECTS_FAMILY; return AUDIOUNITEFFECTS_FAMILY;
} }

View File

@ -61,7 +61,8 @@ public:
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;
bool IsLegacy() override; bool IsLegacy() override;

View File

@ -668,7 +668,12 @@ EffectType LadspaEffect::GetType()
return EffectTypeProcess; return EffectTypeProcess;
} }
wxString LadspaEffect::GetFamily() wxString LadspaEffect::GetFamilyId()
{
return LADSPAEFFECTS_FAMILY;
}
wxString LadspaEffect::GetFamilyName()
{ {
return LADSPAEFFECTS_FAMILY; return LADSPAEFFECTS_FAMILY;
} }

View File

@ -56,7 +56,8 @@ public:
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;
bool IsLegacy() override; bool IsLegacy() override;

View File

@ -386,7 +386,12 @@ EffectType LV2Effect::GetType()
return EffectTypeProcess; return EffectTypeProcess;
} }
wxString LV2Effect::GetFamily() wxString LV2Effect::GetFamilyId()
{
return LV2EFFECTS_FAMILY;
}
wxString LV2Effect::GetFamilyName()
{ {
return LV2EFFECTS_FAMILY; return LV2EFFECTS_FAMILY;
} }

View File

@ -119,7 +119,8 @@ public:
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;
bool IsLegacy() override; bool IsLegacy() override;

View File

@ -252,7 +252,12 @@ EffectType NyquistEffect::GetType()
return mType; return mType;
} }
wxString NyquistEffect::GetFamily() wxString NyquistEffect::GetFamilyId()
{
return NYQUISTEFFECTS_FAMILY;
}
wxString NyquistEffect::GetFamilyName()
{ {
return NYQUISTEFFECTS_FAMILY; return NYQUISTEFFECTS_FAMILY;
} }

View File

@ -90,7 +90,8 @@ public:
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;

View File

@ -130,7 +130,12 @@ EffectType VampEffect::GetType()
return EffectTypeAnalyze; return EffectTypeAnalyze;
} }
wxString VampEffect::GetFamily() wxString VampEffect::GetFamilyId()
{
return VAMPEFFECTS_FAMILY;
}
wxString VampEffect::GetFamilyName()
{ {
return VAMPEFFECTS_FAMILY; return VAMPEFFECTS_FAMILY;
} }

View File

@ -54,7 +54,8 @@ public:
// EffectIdentInterface implementation // EffectIdentInterface implementation
EffectType GetType() override; EffectType GetType() override;
wxString GetFamily() override; wxString GetFamilyId() override;
wxString GetFamilyName() override;
bool IsInteractive() override; bool IsInteractive() override;
bool IsDefault() override; bool IsDefault() override;