diff --git a/src/Experimental.h b/src/Experimental.h index ac15abc22..d41f9583e 100644 --- a/src/Experimental.h +++ b/src/Experimental.h @@ -77,6 +77,9 @@ // All code removed after 2.1.0 release since it was unmaintained. LLL //#define EFFECT_CATEGORIES +// JKC Apr 2015, Menu item to manage effects. +#define EXPERIMENTAL_EFFECT_MANAGEMENT + // Andreas Micheler, 20.Nov 2007: // A spectrumLogF-like view mode with notes quantization. // Just select the "Find Notes" checkbox in the spectrum prefs @@ -185,4 +188,5 @@ #undef EXPERIMENTAL_CRASH_REPORT #endif + #endif diff --git a/src/Menus.cpp b/src/Menus.cpp index 9936566fd..6305d6602 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -1011,6 +1011,12 @@ void AudacityProject::CreateMenusAndCommands() EffectTypeProcess, AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag, TracksExistFlag | IsRealtimeNotActiveFlag); +#ifdef EXPERIMENTAL_EFFECT_MANAGEMENT + c->AddSeparator(); + // We could say Manage Effects on the menu, but More... is more intuitive. + c->AddItem(wxT("ManageEffects"), _("&More..."), FN(OnManageEffects)); + +#endif c->EndMenu(); @@ -3274,6 +3280,14 @@ void AudacityProject::OnRepeatLastEffect(int WXUNUSED(index)) } } +void AudacityProject::OnManageEffects() +{ + //gPrefs->Write( wxT("/Plugins/Rescan"), true); + //gPrefs->Read(wxT("/Plugins/CheckForUpdates"), &doCheck, true); + PluginManager::Get().CheckForUpdates(kPROMPT_TO_ADD_EFFECTS); + RebuildMenuBar(); +} + void AudacityProject::OnStereoToMono(int WXUNUSED(index)) { OnEffect(EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), diff --git a/src/Menus.h b/src/Menus.h index 422cc453a..20580eae4 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -374,6 +374,7 @@ void OnRepeatLastEffect(int index); void OnApplyChain(); void OnEditChains(); void OnStereoToMono(int index); +void OnManageEffects(); // Help Menu diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 66361361c..546855275 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -394,6 +394,7 @@ public: // constructors and destructors PluginRegistrationDialog(ProviderMap & map); virtual ~PluginRegistrationDialog(); + void RegisterDefaultEffects(); private: void Populate(); @@ -755,6 +756,58 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt)) EndModal(mCancelClicked ? wxID_CANCEL : wxID_OK); } +void PluginRegistrationDialog::RegisterDefaultEffects() +{ + PluginManager & pm = PluginManager::Get(); + ModuleManager & mm = ModuleManager::Get(); + + int i = 0; + for (ProviderMap::iterator iter = mMap.begin(); iter != mMap.end(); ++iter, i++) + { + wxFileName fname = iter->first; + wxString name = fname.GetName(); + wxString path = iter->first; + + // Create a placeholder descriptor to show we've seen this plugin before and not + // to show it as new the next time Audacity starts. + // + // Placeholder descriptors have a plugin type of PluginTypeNone and the ID is the + // path. + PluginDescriptor & plug = pm.mPlugins[path]; + + plug.SetID(path); + plug.SetPath(path); + plug.SetEnabled(false); + plug.SetValid(false); + + // This is just a proof of concept to show we can get a list of default effects. + // Here we take the Builtin ones, and remove several optional ones, so that they become + // opt-in. + bool bAddIt = fname.GetVolume().StartsWith( wxString( BUILTIN_EFFECT_PREFIX).BeforeFirst(':') ); + wxLogDebug(wxT("Name: [%s]"), fname.GetName().c_str() ); + bAddIt &= !fname.GetName().StartsWith( wxT(" Leveller") ); + bAddIt &= !fname.GetName().StartsWith( wxT(" Auto Duck") ); + bAddIt &= !fname.GetName().StartsWith( wxT(" Paulstretch") ); + bAddIt &= !fname.GetName().StartsWith( wxT(" Time Scale") ); + bAddIt &= !fname.GetName().StartsWith( wxT(" Classic Filters") ); + + // Built in effects get registered... + if (bAddIt) + { + wxArrayString providers = mMap[path]; + for (size_t j = 0, cnt = providers.GetCount(); j < cnt; j++) + { + if (mm.RegisterPlugin(providers[j], path)) + { + break; + } + } + } + wxYield(); + } +} + + void PluginRegistrationDialog::OnCancel(wxCommandEvent & WXUNUSED(evt)) { mCancelClicked = true; @@ -1421,7 +1474,13 @@ void PluginManager::Initialize() ModuleManager::Get().DiscoverProviders(); // And finally check for updates + // CheckForUpdates will prompt for what to add normally. + // If it is told kJUST_STANDARD_EFFECTS then it doesn't prompt. +#ifdef EXPERIMENTAL_EFFECT_MANAGEMENT + CheckForUpdates(kJUST_STANDARD_EFFECTS); +#else CheckForUpdates(); +#endif } void PluginManager::Terminate() @@ -1812,7 +1871,7 @@ void PluginManager::SaveGroup(PluginType type) return; } -void PluginManager::CheckForUpdates() +void PluginManager::CheckForUpdates(eItemsToUpdate UpdateWhat) { // Get ModuleManager reference ModuleManager & mm = ModuleManager::Get(); @@ -1823,6 +1882,9 @@ void PluginManager::CheckForUpdates() gPrefs->Read(wxT("/Plugins/Rescan"), &doRescan, true); gPrefs->Read(wxT("/Plugins/CheckForUpdates"), &doCheck, true); + if( UpdateWhat == kPROMPT_TO_ADD_EFFECTS ) + doRescan = true; + ProviderMap map; // Always check for and disable missing plugins @@ -1883,7 +1945,12 @@ void PluginManager::CheckForUpdates() if (map.size() != 0) { PluginRegistrationDialog dlg(map); - if (dlg.ShowModal() == wxID_OK) + if( UpdateWhat == kJUST_STANDARD_EFFECTS ) + { + dlg.RegisterDefaultEffects(); + gPrefs->Write(wxT("/Plugins/Rescan"), false); + } + else if (dlg.ShowModal() == wxID_OK) { gPrefs->Write(wxT("/Plugins/Rescan"), false); } diff --git a/src/PluginManager.h b/src/PluginManager.h index 1b7853f6c..6256fd737 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -165,6 +165,13 @@ typedef wxArrayString PluginIDList; class PluginRegistrationDialog; +enum eItemsToUpdate { + kCHECK_ALL, + kJUST_STANDARD_EFFECTS, + kPROMPT_TO_ADD_EFFECTS +}; + + class PluginManager : public PluginManagerInterface { public: @@ -258,6 +265,7 @@ public: // For builtin effects const PluginID & RegisterPlugin(EffectIdentInterface *effect); + void CheckForUpdates(eItemsToUpdate UpdateWhat=kCHECK_ALL); private: void Load(); @@ -265,7 +273,6 @@ private: void Save(); void SaveGroup(PluginType type); - void CheckForUpdates(); void DisableMissing(); wxArrayString IsNewOrUpdated(const wxArrayString & paths);