From 097764d94c2b02731f6f4e157ca8765fe143009e Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 15 Jan 2018 23:40:42 -0500 Subject: [PATCH] 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. --- include/audacity/EffectInterface.h | 5 +++- src/PluginManager.cpp | 26 +++++++++---------- src/PluginManager.h | 4 +-- src/effects/Effect.cpp | 30 ++++++++++++---------- src/effects/Effect.h | 3 ++- src/effects/VST/VSTEffect.cpp | 14 ++++++++-- src/effects/VST/VSTEffect.h | 3 ++- src/effects/audiounits/AudioUnitEffect.cpp | 7 ++++- src/effects/audiounits/AudioUnitEffect.h | 3 ++- src/effects/ladspa/LadspaEffect.cpp | 7 ++++- src/effects/ladspa/LadspaEffect.h | 3 ++- src/effects/lv2/LV2Effect.cpp | 7 ++++- src/effects/lv2/LV2Effect.h | 3 ++- src/effects/nyquist/Nyquist.cpp | 7 ++++- src/effects/nyquist/Nyquist.h | 3 ++- src/effects/vamp/VampEffect.cpp | 7 ++++- src/effects/vamp/VampEffect.h | 3 ++- 17 files changed, 91 insertions(+), 44 deletions(-) diff --git a/include/audacity/EffectInterface.h b/include/audacity/EffectInterface.h index a1cff1fea..8a9134e0e 100755 --- a/include/audacity/EffectInterface.h +++ b/include/audacity/EffectInterface.h @@ -64,7 +64,10 @@ public: virtual ~EffectIdentInterface() {}; 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 // effects have been converted. diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 722585ae8..78feab786 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -1221,7 +1221,7 @@ void PluginDescriptor::SetValid(bool valid) // Effects -wxString PluginDescriptor::GetUntranslatedEffectFamily() const +wxString PluginDescriptor::GetEffectFamilyId() const { return mEffectFamily; } @@ -1290,7 +1290,7 @@ bool PluginDescriptor::IsEffectAutomatable() const return mEffectAutomatable; } -void PluginDescriptor::SetEffectFamily(const wxString & family) +void PluginDescriptor::SetEffectFamilyId(const wxString & family) { mEffectFamily = family; } @@ -1439,7 +1439,7 @@ const PluginID & PluginManager::RegisterPlugin(ModuleInterface *provider, Effect plug.SetProviderID(PluginManager::GetID(provider)); plug.SetEffectType(effect->GetType()); - plug.SetEffectFamily(effect->GetFamily()); + plug.SetEffectFamilyId(effect->GetFamilyId()); plug.SetEffectInteractive(effect->IsInteractive()); plug.SetEffectDefault(effect->IsDefault()); plug.SetEffectRealtime(effect->SupportsRealtime()); @@ -2105,7 +2105,7 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) { continue; } - plug.SetEffectFamily(strVal); + plug.SetEffectFamilyId(strVal); // Is it a default (above the line) effect and bypass group if not found if (!pRegistry->Read(KEY_EFFECTDEFAULT, &boolVal)) @@ -2277,7 +2277,7 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) stype = KEY_EFFECTTYPE_HIDDEN; } 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_EFFECTINTERACTIVE, plug.IsEffectInteractive()); pRegistry->Write(KEY_EFFECTREALTIME, plug.IsEffectRealtime()); @@ -2354,7 +2354,7 @@ void PluginManager::CheckForUpdates(bool bFast) continue; } - if ( (plugType == PluginTypeModule) ) + if ( plugType == PluginTypeModule ) { if( bFast ) { @@ -2416,7 +2416,7 @@ const PluginID & PluginManager::RegisterPlugin(EffectIdentInterface *effect) PluginDescriptor & plug = CreatePlugin(GetID(effect), effect, PluginTypeEffect); plug.SetEffectType(effect->GetType()); - plug.SetEffectFamily(effect->GetFamily()); + plug.SetEffectFamilyId(effect->GetFamilyId()); plug.SetEffectInteractive(effect->IsInteractive()); plug.SetEffectDefault(effect->IsDefault()); plug.SetEffectRealtime(effect->SupportsRealtime()); @@ -2476,7 +2476,7 @@ const PluginDescriptor *PluginManager::GetFirstPlugin(PluginType type) if (type == PluginTypeEffect) { // 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) { @@ -2496,7 +2496,7 @@ const PluginDescriptor *PluginManager::GetNextPlugin(PluginType type) if (type == PluginTypeEffect) { // 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) { @@ -2517,7 +2517,7 @@ const PluginDescriptor *PluginManager::GetFirstPluginForEffectType(EffectType ty bool familyEnabled; // 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.IsInstantiated() && em.IsHidden(plug.GetID())) @@ -2541,7 +2541,7 @@ const PluginDescriptor *PluginManager::GetNextPluginForEffectType(EffectType typ PluginDescriptor & plug = mPluginsIter->second; bool familyEnabled; // 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.IsInstantiated() && em.IsHidden(plug.GetID())) @@ -2634,7 +2634,7 @@ PluginID PluginManager::GetID(EffectIdentInterface *effect) { return wxString::Format(wxT("%s_%s_%s_%s_%s"), GetPluginTypeString(PluginTypeEffect), - effect->GetFamily(), + effect->GetFamilyId(), effect->GetVendor(), effect->GetName(), effect->GetPath()); @@ -2931,7 +2931,7 @@ wxString PluginManager::SettingsPath(const PluginID & ID, bool shared) wxString id = GetPluginTypeString(plug.GetPluginType()) + wxT("_") + - plug.GetUntranslatedEffectFamily() + // is empty for non-Effects + plug.GetEffectFamilyId() + // is empty for non-Effects wxT("_") + plug.GetUntranslatedVendor() + wxT("_") + diff --git a/src/PluginManager.h b/src/PluginManager.h index 11a813ddf..388fc688c 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -89,7 +89,7 @@ public: // Effect plugins only - wxString GetUntranslatedEffectFamily() const; + wxString GetEffectFamilyId() const; wxString GetTranslatedEffectFamily() const; EffectType GetEffectType() const; bool IsEffectDefault() const; @@ -99,7 +99,7 @@ public: bool IsEffectAutomatable() const; // "family" should be an untranslated string wrapped in wxT() - void SetEffectFamily(const wxString & family); + void SetEffectFamilyId(const wxString & family); void SetEffectType(EffectType type); void SetEffectDefault(bool dflt); void SetEffectInteractive(bool interactive); diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index a3c5af332..49f8291d0 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -213,11 +213,11 @@ wxString Effect::GetDescription() return wxEmptyString; } -wxString Effect::GetFamily() +wxString Effect::GetFamilyId() { if (mClient) { - return mClient->GetFamily(); + return mClient->GetFamilyId(); } // PRL: In 2.2.2 we wanted to change the user-visible name to @@ -232,6 +232,16 @@ wxString Effect::GetFamily() return XO("Audacity"); } +wxString Effect::GetFamilyName() +{ + if (mClient) + { + return mClient->GetFamilyName(); + } + + return XO("Built-in"); +} + bool Effect::IsInteractive() { if (mClient) @@ -2480,7 +2490,7 @@ void Effect::Preview(bool dryOnly) wxWindow *FocusDialog = wxWindow::FindFocus(); double previewDuration; - bool isNyquist = (GetFamily().IsSameAs(NYQUISTEFFECTS_FAMILY))? true : false; + bool isNyquist = GetFamilyId().IsSameAs(NYQUISTEFFECTS_FAMILY); bool isGenerator = GetType() == EffectTypeGenerate; // 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)) { - 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. // Always use default web browser to allow full-featured HTML pages. 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(); - auto type = mEffect->GetFamily(); - // PRL: 2.2.2 hack to change the visible name without breaking - // 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(_("Type: %s"), + ::wxGetTranslation( mEffect->GetFamilyName() ))); sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetTranslatedName())); sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion())); sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor())); diff --git a/src/effects/Effect.h b/src/effects/Effect.h index bf41e46fb..ed940dae1 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -87,7 +87,8 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; // returns UNTRANSLATED + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; bool IsLegacy() override; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 63f3aa8fe..e66287f9c 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -234,7 +234,12 @@ public: return mDescription; } - wxString GetFamily() override + wxString GetFamilyId() override + { + return VSTPLUGINTYPE; + } + + wxString GetFamilyName() override { return VSTPLUGINTYPE; } @@ -1246,7 +1251,12 @@ EffectType VSTEffect::GetType() } -wxString VSTEffect::GetFamily() +wxString VSTEffect::GetFamilyId() +{ + return VSTPLUGINTYPE; +} + +wxString VSTEffect::GetFamilyName() { return VSTPLUGINTYPE; } diff --git a/src/effects/VST/VSTEffect.h b/src/effects/VST/VSTEffect.h index bd2a9eabf..048fcea27 100644 --- a/src/effects/VST/VSTEffect.h +++ b/src/effects/VST/VSTEffect.h @@ -95,7 +95,8 @@ class VSTEffect final : public wxEvtHandler, // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; bool IsLegacy() override; diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index 2c89e64f2..3e974683a 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -941,7 +941,12 @@ EffectType AudioUnitEffect::GetType() return EffectTypeProcess; } -wxString AudioUnitEffect::GetFamily() +wxString AudioUnitEffect::GetFamilyId() +{ + return AUDIOUNITEFFECTS_FAMILY; +} + +wxString AudioUnitEffect::GetFamilyName() { return AUDIOUNITEFFECTS_FAMILY; } diff --git a/src/effects/audiounits/AudioUnitEffect.h b/src/effects/audiounits/AudioUnitEffect.h index 7f44e472e..9d11425c7 100644 --- a/src/effects/audiounits/AudioUnitEffect.h +++ b/src/effects/audiounits/AudioUnitEffect.h @@ -61,7 +61,8 @@ public: // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; bool IsLegacy() override; diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index e58b7d49a..ba1362393 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -668,7 +668,12 @@ EffectType LadspaEffect::GetType() return EffectTypeProcess; } -wxString LadspaEffect::GetFamily() +wxString LadspaEffect::GetFamilyId() +{ + return LADSPAEFFECTS_FAMILY; +} + +wxString LadspaEffect::GetFamilyName() { return LADSPAEFFECTS_FAMILY; } diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index 3a8e16c64..4a109fd3a 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -56,7 +56,8 @@ public: // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; bool IsLegacy() override; diff --git a/src/effects/lv2/LV2Effect.cpp b/src/effects/lv2/LV2Effect.cpp index c7b4d23b5..820980bb5 100644 --- a/src/effects/lv2/LV2Effect.cpp +++ b/src/effects/lv2/LV2Effect.cpp @@ -386,7 +386,12 @@ EffectType LV2Effect::GetType() return EffectTypeProcess; } -wxString LV2Effect::GetFamily() +wxString LV2Effect::GetFamilyId() +{ + return LV2EFFECTS_FAMILY; +} + +wxString LV2Effect::GetFamilyName() { return LV2EFFECTS_FAMILY; } diff --git a/src/effects/lv2/LV2Effect.h b/src/effects/lv2/LV2Effect.h index 2e77fad66..d41275b96 100644 --- a/src/effects/lv2/LV2Effect.h +++ b/src/effects/lv2/LV2Effect.h @@ -119,7 +119,8 @@ public: // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; bool IsLegacy() override; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 3b9fbf5de..c2abc1626 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -252,7 +252,12 @@ EffectType NyquistEffect::GetType() return mType; } -wxString NyquistEffect::GetFamily() +wxString NyquistEffect::GetFamilyId() +{ + return NYQUISTEFFECTS_FAMILY; +} + +wxString NyquistEffect::GetFamilyName() { return NYQUISTEFFECTS_FAMILY; } diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 29ef88e2e..bfb920278 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -90,7 +90,8 @@ public: // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override; diff --git a/src/effects/vamp/VampEffect.cpp b/src/effects/vamp/VampEffect.cpp index 06bc09d4c..194a7380e 100644 --- a/src/effects/vamp/VampEffect.cpp +++ b/src/effects/vamp/VampEffect.cpp @@ -130,7 +130,12 @@ EffectType VampEffect::GetType() return EffectTypeAnalyze; } -wxString VampEffect::GetFamily() +wxString VampEffect::GetFamilyId() +{ + return VAMPEFFECTS_FAMILY; +} + +wxString VampEffect::GetFamilyName() { return VAMPEFFECTS_FAMILY; } diff --git a/src/effects/vamp/VampEffect.h b/src/effects/vamp/VampEffect.h index 7ce5b0ece..b85aec18e 100644 --- a/src/effects/vamp/VampEffect.h +++ b/src/effects/vamp/VampEffect.h @@ -54,7 +54,8 @@ public: // EffectIdentInterface implementation EffectType GetType() override; - wxString GetFamily() override; + wxString GetFamilyId() override; + wxString GetFamilyName() override; bool IsInteractive() override; bool IsDefault() override;