1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-19 17:40:15 +02:00

EXPERIMENTAL_EFFECT_MANAGEMENT

On a reset preferences, this adds the default built in effects only.  The effects menu now has a 'More...' as its last item, and the list of plugins is invoked there.  We can add from that list to the menus from that.
This commit is contained in:
James Crook 2015-04-25 19:05:39 +01:00
parent f3f7dca595
commit 9bc32b0e6b
5 changed files with 96 additions and 3 deletions

View File

@ -77,6 +77,9 @@
// All code removed after 2.1.0 release since it was unmaintained. LLL // All code removed after 2.1.0 release since it was unmaintained. LLL
//#define EFFECT_CATEGORIES //#define EFFECT_CATEGORIES
// JKC Apr 2015, Menu item to manage effects.
#define EXPERIMENTAL_EFFECT_MANAGEMENT
// Andreas Micheler, 20.Nov 2007: // Andreas Micheler, 20.Nov 2007:
// A spectrumLogF-like view mode with notes quantization. // A spectrumLogF-like view mode with notes quantization.
// Just select the "Find Notes" checkbox in the spectrum prefs // Just select the "Find Notes" checkbox in the spectrum prefs
@ -185,4 +188,5 @@
#undef EXPERIMENTAL_CRASH_REPORT #undef EXPERIMENTAL_CRASH_REPORT
#endif #endif
#endif #endif

View File

@ -1011,6 +1011,12 @@ void AudacityProject::CreateMenusAndCommands()
EffectTypeProcess, EffectTypeProcess,
AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag, AudioIONotBusyFlag | TimeSelectedFlag | WaveTracksSelectedFlag,
TracksExistFlag | IsRealtimeNotActiveFlag); 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(); 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)) void AudacityProject::OnStereoToMono(int WXUNUSED(index))
{ {
OnEffect(EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), OnEffect(EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")),

View File

@ -374,6 +374,7 @@ void OnRepeatLastEffect(int index);
void OnApplyChain(); void OnApplyChain();
void OnEditChains(); void OnEditChains();
void OnStereoToMono(int index); void OnStereoToMono(int index);
void OnManageEffects();
// Help Menu // Help Menu

View File

@ -394,6 +394,7 @@ public:
// constructors and destructors // constructors and destructors
PluginRegistrationDialog(ProviderMap & map); PluginRegistrationDialog(ProviderMap & map);
virtual ~PluginRegistrationDialog(); virtual ~PluginRegistrationDialog();
void RegisterDefaultEffects();
private: private:
void Populate(); void Populate();
@ -755,6 +756,58 @@ void PluginRegistrationDialog::OnOK(wxCommandEvent & WXUNUSED(evt))
EndModal(mCancelClicked ? wxID_CANCEL : wxID_OK); 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)) void PluginRegistrationDialog::OnCancel(wxCommandEvent & WXUNUSED(evt))
{ {
mCancelClicked = true; mCancelClicked = true;
@ -1421,7 +1474,13 @@ void PluginManager::Initialize()
ModuleManager::Get().DiscoverProviders(); ModuleManager::Get().DiscoverProviders();
// And finally check for updates // 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(); CheckForUpdates();
#endif
} }
void PluginManager::Terminate() void PluginManager::Terminate()
@ -1812,7 +1871,7 @@ void PluginManager::SaveGroup(PluginType type)
return; return;
} }
void PluginManager::CheckForUpdates() void PluginManager::CheckForUpdates(eItemsToUpdate UpdateWhat)
{ {
// Get ModuleManager reference // Get ModuleManager reference
ModuleManager & mm = ModuleManager::Get(); ModuleManager & mm = ModuleManager::Get();
@ -1823,6 +1882,9 @@ void PluginManager::CheckForUpdates()
gPrefs->Read(wxT("/Plugins/Rescan"), &doRescan, true); gPrefs->Read(wxT("/Plugins/Rescan"), &doRescan, true);
gPrefs->Read(wxT("/Plugins/CheckForUpdates"), &doCheck, true); gPrefs->Read(wxT("/Plugins/CheckForUpdates"), &doCheck, true);
if( UpdateWhat == kPROMPT_TO_ADD_EFFECTS )
doRescan = true;
ProviderMap map; ProviderMap map;
// Always check for and disable missing plugins // Always check for and disable missing plugins
@ -1883,7 +1945,12 @@ void PluginManager::CheckForUpdates()
if (map.size() != 0) if (map.size() != 0)
{ {
PluginRegistrationDialog dlg(map); 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); gPrefs->Write(wxT("/Plugins/Rescan"), false);
} }

View File

@ -165,6 +165,13 @@ typedef wxArrayString PluginIDList;
class PluginRegistrationDialog; class PluginRegistrationDialog;
enum eItemsToUpdate {
kCHECK_ALL,
kJUST_STANDARD_EFFECTS,
kPROMPT_TO_ADD_EFFECTS
};
class PluginManager : public PluginManagerInterface class PluginManager : public PluginManagerInterface
{ {
public: public:
@ -258,6 +265,7 @@ public:
// For builtin effects // For builtin effects
const PluginID & RegisterPlugin(EffectIdentInterface *effect); const PluginID & RegisterPlugin(EffectIdentInterface *effect);
void CheckForUpdates(eItemsToUpdate UpdateWhat=kCHECK_ALL);
private: private:
void Load(); void Load();
@ -265,7 +273,6 @@ private:
void Save(); void Save();
void SaveGroup(PluginType type); void SaveGroup(PluginType type);
void CheckForUpdates();
void DisableMissing(); void DisableMissing();
wxArrayString IsNewOrUpdated(const wxArrayString & paths); wxArrayString IsNewOrUpdated(const wxArrayString & paths);