audacia/src/effects/EffectManager.h

185 lines
5.3 KiB
C
Raw Normal View History

/**********************************************************************
Audacity: A Digital Audio Editor
EffectManager.h
Audacity(R) is copyright (c) 1999-2008 Audacity Team.
License: GPL v2. See License.txt.
******************************************************************//**
\class EffectManager
\brief EffectManager is the class that handles effects and effect categories.
2014-06-03 20:30:19 +00:00
It maintains a graph of effect categories and subcategories,
registers and unregisters effects and can return filtered lists of
effects.
*//*******************************************************************/
#ifndef __AUDACITY_EFFECTMANAGER__
#define __AUDACITY_EFFECTMANAGER__
#include <map>
#include <string>
#include <vector>
#include "audacity/EffectInterface.h"
#include "../PluginManager.h"
#include "Effect.h"
#ifdef EFFECT_CATEGORIES
#include "EffectCategory.h"
#endif
WX_DEFINE_USER_EXPORTED_ARRAY(Effect *, EffectArray, class AUDACITY_DLL_API);
#if defined(EXPERIMENTAL_EFFECTS_RACK)
class EffectRack;
#endif
class AUDACITY_DLL_API EffectManager
{
#if defined(EXPERIMENTAL_EFFECTS_RACK)
friend class EffectRack;
#endif
2014-06-03 20:30:19 +00:00
public:
2014-06-03 20:30:19 +00:00
/** Get the singleton instance of the EffectManager. Probably not safe
for multi-thread use. */
static EffectManager& Get();
2014-06-03 20:30:19 +00:00
//
// public methods
//
// Used by the outside program to register the list of effects and retrieve
// them by index number, usually when the user selects one from a menu.
//
public:
2014-06-03 20:30:19 +00:00
EffectManager();
/** A destructor is needed so we can delete all categories. */
~EffectManager();
/** Register an effect so it will appear in the menu. */
void RegisterEffect(Effect *f, int AdditionalFlags=0);
2014-06-03 20:30:19 +00:00
/** Unregister all effects. */
void UnregisterEffects();
2014-06-03 20:30:19 +00:00
/** Run an effect given the plugin ID */
// Returns true on success. Will only operate on tracks that
// have the "selected" flag set to true, which is consistent with
// Audacity's standard UI.
bool DoEffect(const PluginID & ID,
wxWindow *parent,
int flags,
double projectRate,
TrackList *list,
TrackFactory *factory,
SelectedRegion *selectedRegion,
wxString params);
wxString GetEffectName(const PluginID & ID);
wxString GetEffectIdentifier(const PluginID & ID);
wxString GetEffectDescription(const PluginID & ID);
/** Support for batch commands */
wxString GetEffectParameters(const PluginID & ID);
bool SetEffectParameters(const PluginID & ID, const wxString & params);
bool PromptUser(const PluginID & ID, wxWindow *parent);
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
// Realtime effect processing
Round 3 of realtime changes. This gets meter type VST effects working again by extending the The master now maintains his own internal buffers and sums (mixes) all playing tracks into those buffers. The buffers are then fed into the VST effect that is presented to the user. This allows the effect to provide feedback to the user if it support it. Such effects may display meters or clipping indicators. Several issues with treading have also been corrected (hopefully ;-)). These showed up mostly on Linux, but could have happened on the others as well. The realtime support is no longer limited to 2 channels per logical track. Once support for more channels is added, this should be ready for it. The rack dialog can now be toggled via the edit toolbar button. It doesn't stay pressed because the closing of the dialog would have to be communicated back to the toolbar. As the rack is updated with new or removed effects or active state changed, all effects in the active list were shutdown and all effects in the updated list were initialized. This now shuts down only the effects no longer in the list and initializes only new ones. The rack now uses wxBitmapButton instead of Audacity's AButton. The AButton has a timing issue that prevents it from being deleted while processing the click event. I looked into it, but gave up and switched to the wxBitmapButton. Unfortunately, there's a problem with the wxBitmapButton as well...at least on my setup here. Either the bitmaps are being scaled or antialiased. Will have to get feedback on this. I finally figured out why some VSTs didn't seem to do anything in realtime, at least in my case anyway. I've installed a lot of demo VSTs and while they work in "batch/offline" mode, some of them will not work in realtime since vendors tend to remove automation as one of the demo limitations. More changes coming shortly...
2014-11-03 06:48:54 +00:00
void RealtimeSetEffects(const EffectArray & mActive);
void RealtimeInitialize();
void RealtimeFinalize();
void RealtimeSuspend();
void RealtimeResume();
Round 3 of realtime changes. This gets meter type VST effects working again by extending the The master now maintains his own internal buffers and sums (mixes) all playing tracks into those buffers. The buffers are then fed into the VST effect that is presented to the user. This allows the effect to provide feedback to the user if it support it. Such effects may display meters or clipping indicators. Several issues with treading have also been corrected (hopefully ;-)). These showed up mostly on Linux, but could have happened on the others as well. The realtime support is no longer limited to 2 channels per logical track. Once support for more channels is added, this should be ready for it. The rack dialog can now be toggled via the edit toolbar button. It doesn't stay pressed because the closing of the dialog would have to be communicated back to the toolbar. As the rack is updated with new or removed effects or active state changed, all effects in the active list were shutdown and all effects in the updated list were initialized. This now shuts down only the effects no longer in the list and initializes only new ones. The rack now uses wxBitmapButton instead of Audacity's AButton. The AButton has a timing issue that prevents it from being deleted while processing the click event. I looked into it, but gave up and switched to the wxBitmapButton. Unfortunately, there's a problem with the wxBitmapButton as well...at least on my setup here. Either the bitmaps are being scaled or antialiased. Will have to get feedback on this. I finally figured out why some VSTs didn't seem to do anything in realtime, at least in my case anyway. I've installed a lot of demo VSTs and while they work in "batch/offline" mode, some of them will not work in realtime since vendors tend to remove automation as one of the demo limitations. More changes coming shortly...
2014-11-03 06:48:54 +00:00
sampleCount RealtimeProcess(int group, int chans, float rate, float **buffers, sampleCount numSamples);
int GetRealtimeLatency();
#endif
#if defined(EXPERIMENTAL_EFFECTS_RACK)
void ShowRack();
#endif
2014-06-03 20:30:19 +00:00
const PluginID & GetEffectByIdentifier(const wxString & strTarget);
2014-06-03 20:30:19 +00:00
#ifdef EFFECT_CATEGORIES
/** Add a new effect category with the given URI and name and
return a pointer to it. If a category with this URI already
exists, return that instead. */
2014-06-03 20:30:19 +00:00
EffectCategory* AddCategory(const wxString& URI,
const wxString& name);
2014-06-03 20:30:19 +00:00
/** Return a pointer to the effect category with the given URI
or 0 if no such category has been added. */
EffectCategory* LookupCategory(const wxString& URI);
2014-06-03 20:30:19 +00:00
/** Make one category the parent of another category. Both categories
must have been returned from AddCategory() or LookupCategory().
If the new parent-child relationship would create any loops
in the graph of categories false will be returned and the graph
will not be modified, otherwise the function will return true. */
bool AddCategoryParent(EffectCategory* child, EffectCategory* parent);
2014-06-03 20:30:19 +00:00
/** Freeze the subcategory relations between all categories added so far. */
void FreezeCategories();
2014-06-03 20:30:19 +00:00
/** Return the set of all root categories, i.e. the ones without parents. */
const CategorySet& GetRootCategories() const;
2014-06-03 20:30:19 +00:00
/** Return the set of all uncategorised effects. */
EffectSet GetUnsortedEffects(int flags = ALL_EFFECTS) const;
#endif
private:
/** Return an effect by its ID. */
Effect *GetEffect(const PluginID & ID);
#if defined(EXPERIMENTAL_EFFECTS_RACK)
EffectRack *GetRack();
#endif
private:
wxArrayString mEffectPlugins;
2014-06-03 20:30:19 +00:00
int mNumEffects;
#if defined(EXPERIMENTAL_EFFECTS_RACK)
EffectRack *mRack;
#endif
#if defined(EXPERIMENTAL_REALTIME_EFFECTS)
Round 3 of realtime changes. This gets meter type VST effects working again by extending the The master now maintains his own internal buffers and sums (mixes) all playing tracks into those buffers. The buffers are then fed into the VST effect that is presented to the user. This allows the effect to provide feedback to the user if it support it. Such effects may display meters or clipping indicators. Several issues with treading have also been corrected (hopefully ;-)). These showed up mostly on Linux, but could have happened on the others as well. The realtime support is no longer limited to 2 channels per logical track. Once support for more channels is added, this should be ready for it. The rack dialog can now be toggled via the edit toolbar button. It doesn't stay pressed because the closing of the dialog would have to be communicated back to the toolbar. As the rack is updated with new or removed effects or active state changed, all effects in the active list were shutdown and all effects in the updated list were initialized. This now shuts down only the effects no longer in the list and initializes only new ones. The rack now uses wxBitmapButton instead of Audacity's AButton. The AButton has a timing issue that prevents it from being deleted while processing the click event. I looked into it, but gave up and switched to the wxBitmapButton. Unfortunately, there's a problem with the wxBitmapButton as well...at least on my setup here. Either the bitmaps are being scaled or antialiased. Will have to get feedback on this. I finally figured out why some VSTs didn't seem to do anything in realtime, at least in my case anyway. I've installed a lot of demo VSTs and while they work in "batch/offline" mode, some of them will not work in realtime since vendors tend to remove automation as one of the demo limitations. More changes coming shortly...
2014-11-03 06:48:54 +00:00
wxCriticalSection mRealtimeLock;
Effect **mRealtimeEffects;
int mRealtimeCount;
int mRealtimeLatency;
bool mRealtimeSuspended;
bool mRealtimeActive;
#endif
2014-06-03 20:30:19 +00:00
#ifdef EFFECT_CATEGORIES
// This maps URIs to EffectCategory pointers for all added categories.
// It is needed for fast lookup and easy deletion.
typedef std::map<wxString, EffectCategory*> CategoryMap;
CategoryMap *mCategories;
2014-06-03 20:30:19 +00:00
// These are the root categories, i.e. the ones without parents.
CategorySet *mRootCategories;
2014-06-03 20:30:19 +00:00
// Special category that all effects with unknown category URIs
// are placed in.
EffectSet *mUnsorted;
#endif
};
#endif