Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
LV2Effect Class Referencefinal

#include <LV2Effect.h>

Inheritance diagram for LV2Effect:
[legend]
Collaboration diagram for LV2Effect:
[legend]

Public Member Functions

 LV2Effect (const LilvPlugin &plug)
 
virtual ~LV2Effect ()
 
PluginPath GetPath () const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
bool InitializePlugin ()
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Adds controls to a panel that is given as the parent window of S More...
 
bool CloseUI () const override
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
bool HasOptions () const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
- Public Member Functions inherited from StatelessPerTrackEffect
 ~StatelessPerTrackEffect () override
 
- Public Member Functions inherited from PerTrackEffect
 ~PerTrackEffect () override
 
- Public Member Functions inherited from Effect
 Effect ()
 
virtual ~Effect ()
 
PluginPath GetPath () const override
 
bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings) override
 
bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const override
 
ComponentInterfaceSymbol GetSymbol () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
TranslatableString GetDescription () const override
 
EffectType GetType () const override
 Type determines how it behaves. More...
 
EffectFamilySymbol GetFamily () const override
 Report identifier and user-visible name of the effect protocol. More...
 
bool IsInteractive () const override
 Whether the effect needs a dialog for entry of settings. More...
 
bool IsDefault () const override
 Whether the effect sorts "above the line" in the menus. More...
 
RealtimeSince RealtimeSupport () const override
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsAutomation () const override
 Whether the effect has any automatable controls. More...
 
bool SaveSettings (const EffectSettings &settings, CommandParameters &parms) const override
 Store settings as keys and values. More...
 
bool LoadSettings (const CommandParameters &parms, EffectSettings &settings) const override
 Restore settings from keys and values. More...
 
OptionalMessage LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 
bool SaveUserPreset (const RegistryPath &name, const EffectSettings &settings) const override
 Save settings in the configuration file as a user-named preset. More...
 
RegistryPaths GetFactoryPresets () const override
 Report names of factory presets. More...
 
OptionalMessage LoadFactoryPreset (int id, EffectSettings &settings) const override
 
OptionalMessage LoadFactoryDefaults (EffectSettings &settings) const override
 
virtual const EffectParameterMethodsParameters () const
 
bool CanExportPresets () const override
 Whether the effect supports export of presets to files, and importing too. More...
 
bool HasOptions () const override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
void SetTracks (TrackList *pTracks)
 
bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess) override
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual bool HasOptions () const =0
 
virtual bool CanExportPresets () const =0
 Whether the effect supports export of presets to files, and importing too. More...
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly)=0
 Calculate temporary tracks of limited length with effect applied and play. More...
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual OptionalMessage LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const =0
 
virtual bool IsBatchProcessing () const =0
 
virtual void SetBatchProcessing ()=0
 
virtual void UnsetBatchProcessing ()=0
 
virtual bool DoEffect (EffectSettings &settings, const InstanceFinder &finder, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 
- Public Member Functions inherited from EffectInstanceFactory
virtual ~EffectInstanceFactory ()
 
virtual std::shared_ptr< EffectInstanceMakeInstance () const =0
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from EffectSettingsManager
virtual ~EffectSettingsManager ()
 
virtual bool VisitSettings (SettingsVisitor &visitor, EffectSettings &settings)
 
virtual bool VisitSettings (ConstSettingsVisitor &visitor, const EffectSettings &settings) const
 
- Public Member Functions inherited from EffectDefinitionInterface
virtual ~EffectDefinitionInterface ()
 
virtual EffectType GetType () const =0
 Type determines how it behaves. More...
 
virtual EffectType GetClassification () const
 Determines which menu it appears in; default same as GetType(). More...
 
virtual EffectFamilySymbol GetFamily () const =0
 Report identifier and user-visible name of the effect protocol. More...
 
virtual bool IsInteractive () const =0
 Whether the effect needs a dialog for entry of settings. More...
 
virtual bool IsDefault () const =0
 Whether the effect sorts "above the line" in the menus. More...
 
virtual RealtimeSince RealtimeSupport () const =0
 Since which version of Audacity has the effect supported realtime? More...
 
bool SupportsRealtime () const
 
virtual bool SupportsAutomation () const =0
 Whether the effect has any automatable controls. More...
 
virtual bool EnablesDebug () const
 Whether the effect dialog should have a Debug button; default, always false. More...
 
virtual ManualPageID ManualPage () const
 Name of a page in the Audacity alpha manual, default is empty. More...
 
virtual FilePath HelpPage () const
 Fully qualified local help file name, default is empty. More...
 
virtual bool IsHiddenFromMenus () const
 Default is false. More...
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 
- Public Member Functions inherited from StatelessEffectUIServices
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Adds controls to a panel that is given as the parent window of S More...
 
virtual std::unique_ptr< EffectEditorMakeEditor (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Called only from PopulateUI, to add controls to effect panel. More...
 
- Public Member Functions inherited from BasicEffectUIServices
int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal) const override
 
void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const override
 
OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const override
 
void ShowOptions (const EffectPlugin &plugin) const override
 
bool ValidateUI (const EffectPlugin &context, EffectSettings &) const override
 
bool CloseUI () const override
 
- Public Member Functions inherited from EffectUIServices
virtual ~EffectUIServices ()
 
virtual int ShowHostInterface (EffectPlugin &plugin, wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)
 
virtual int ShowClientInterface (const EffectPlugin &plugin, wxWindow &parent, wxDialog &dialog, EffectEditor *pEditor, bool forceModal=false) const =0
 
virtual std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const =0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual void ExportPresets (const EffectPlugin &plugin, const EffectSettings &settings) const =0
 
virtual OptionalMessage ImportPresets (const EffectPlugin &plugin, EffectSettings &settings) const =0
 
virtual void ShowOptions (const EffectPlugin &plugin) const =0
 
virtual bool ValidateUI (const EffectPlugin &context, EffectSettings &settings) const =0
 
virtual bool CloseUI () const =0
 

Private Member Functions

virtual std::unique_ptr< EffectEditorMakeEditor (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const final
 Will never be called. More...
 
EffectSettings MakeSettings () const override
 
bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const override
 Update one settings object from another. More...
 
std::unique_ptr< EffectOutputsMakeOutputs () const override
 Produce an object to hold values to send to effect output meters. More...
 
OptionalMessage LoadParameters (const RegistryPath &group, EffectSettings &settings) const
 
bool SaveParameters (const RegistryPath &group, const EffectSettings &settings) const
 

Private Attributes

const LilvPlugin & mPlug
 
const LV2FeaturesList mFeatures { mPlug }
 
const LV2Ports mPorts { mPlug }
 
bool mWantsOptionsInterface { false }
 
bool mWantsStateInterface { false }
 
size_t mFramePos {}
 
FloatBuffers mCVInBuffers
 
FloatBuffers mCVOutBuffers
 
double mLength {}
 
bool mFactoryPresetsLoaded { false }
 
RegistryPaths mFactoryPresetNames
 
wxArrayString mFactoryPresetUris
 

Friends

class LV2PluginValidator
 

Additional Inherited Members

- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
using InstancePointer = std::shared_ptr< EffectInstanceEx >
 
using InstanceFinder = std::function< std::optional< InstancePointer >(EffectSettings &settings) >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , After_3_1 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- Public Types inherited from EffectUIServices
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Static Public Member Functions inherited from Effect
static EffectFetchParameters (Effect &e, EffectSettings &)
 
static void IncEffectCounter ()
 
- Static Public Member Functions inherited from EffectDefinitionInterface
static Identifier GetSquashedName (const Identifier &ident)
 A utility that strips spaces and CamelCases a name. More...
 
- Static Public Member Functions inherited from EffectUIServices
static int DoMessageBox (const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
- Public Attributes inherited from EffectBase
TrackListmTracks {}
 
- Static Public Attributes inherited from EffectPlugin
static const wxString kUserPresetIdent = wxT("User Preset:")
 
static const wxString kFactoryPresetIdent = wxT("Factory Preset:")
 
static const wxString kCurrentSettingsIdent = wxT("<Current Settings>")
 
static const wxString kFactoryDefaultsIdent = wxT("<Factory Defaults>")
 
- Protected Member Functions inherited from PerTrackEffect
bool DoPass1 () const
 
bool DoPass2 () const
 
bool Process (EffectInstance &instance, EffectSettings &settings) const
 
- Protected Member Functions inherited from Effect
bool CheckWhetherSkipEffect (const EffectSettings &settings) const override
 Default implementation returns false. More...
 
double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const override
 Default implementation returns previewLength More...
 
bool TotalProgress (double frac, const TranslatableString &={}) const
 
bool TrackProgress (int whichTrack, double frac, const TranslatableString &={}) const
 
bool TrackGroupProgress (int whichGroup, double frac, const TranslatableString &={}) const
 
int GetNumWaveTracks () const
 
int GetNumWaveGroups () const
 
void GetBounds (const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
 
void CopyInputTracks (bool allSyncLockSelected=false)
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
virtual std::any BeginPreview (const EffectSettings &settings)
 Called when Preview() starts, to allow temporary effect state changes. More...
 
void Preview (EffectSettingsAccess &access, std::function< void()> updateUI, bool dryOnly) final
 Calculate temporary tracks of limited length with effect applied and play. More...
 
virtual bool CheckWhetherSkipEffect (const EffectSettings &settings) const =0
 After Init(), tell whether Process() should be skipped. More...
 
virtual double CalcPreviewInputLength (const EffectSettings &settings, double previewLength) const =0
 
void SetLinearEffectFlag (bool linearEffectFlag)
 
void SetPreviewFullSelectionFlag (bool previewDurationFlag)
 
bool IsPreviewing () const
 
void IncludeNotSelectedPreviewTracks (bool includeNotSelected)
 
void ReplaceProcessedTracks (const bool bGoodResult)
 
const TrackListinputTracks () const
 
const AudacityProjectFindProject () const
 
- Protected Attributes inherited from PerTrackEffect
sampleCount mSampleCnt {}
 
- Protected Attributes inherited from EffectBase
BasicUI::ProgressDialogmProgress {}
 
double mProjectRate {}
 
WaveTrackFactorymFactory {}
 
std::shared_ptr< TrackListmOutputTracks
 
double mT0 {}
 
double mT1 {}
 
wxArrayString mPresetNames
 
unsigned mUIFlags { 0 }
 
- Static Protected Attributes inherited from EffectBase
static int nEffectsDone = 0
 

Detailed Description

Definition at line 36 of file LV2Effect.h.

Constructor & Destructor Documentation

◆ LV2Effect()

LV2Effect::LV2Effect ( const LilvPlugin &  plug)

Definition at line 54 of file LV2Effect.cpp.

54 : mPlug{ plug }
55{
56}
const LilvPlugin & mPlug
Definition: LV2Effect.h:118

◆ ~LV2Effect()

LV2Effect::~LV2Effect ( )
virtual

Definition at line 58 of file LV2Effect.cpp.

59{
60}

Member Function Documentation

◆ CanExportPresets()

bool LV2Effect::CanExportPresets ( ) const
overridevirtual

Whether the effect supports export of presets to files, and importing too.

Implements EffectPlugin.

Definition at line 448 of file LV2Effect.cpp.

449{
450 return false;
451}

◆ CloseUI()

bool LV2Effect::CloseUI ( ) const
overridevirtual

Reimplemented from BasicEffectUIServices.

Definition at line 369 of file LV2Effect.cpp.

370{
371#ifdef __WXMAC__
372#ifdef __WX_EVTLOOP_BUSY_WAITING__
373 wxEventLoop::SetBusyWaiting(false);
374#endif
375#endif
376
377 return true;
378}

◆ CopySettingsContents()

bool LV2Effect::CopySettingsContents ( const EffectSettings src,
EffectSettings dst 
) const
overrideprivatevirtual

Update one settings object from another.

This may run in a worker thread, and should avoid memory allocations. Therefore do not copy the underlying std::any, but copy the contents of the contained objects.

Assume that src and dst were created and previously modified only by this

Default implementation does nothing and returns true

Parameters
srcsettings to copy from
dstsettings to copy into
copyDirectiondirection in which copy is performed
Returns
success

Reimplemented from EffectSettingsManager.

Definition at line 194 of file LV2Effect.cpp.

196{
197 auto &srcControls = GetSettings(src).values;
198 auto &dstControls = GetSettings(dst).values;
199
200 const auto &controlPorts = mPorts.mControlPorts;
201 const auto portsCount = controlPorts.size();
202 // Do not use the copy constructor of std::vector. Do an in-place rewrite
203 // of the destination vector, which will not allocate memory if dstControls
204 // began with sufficient capacity.
205 // And that will be true if dstControls originated with MakeSettings() or a
206 // copy of it, because the set of control ports does not vary after
207 // initialization of the plug-in.
208 assert(srcControls.size() == portsCount);
209 assert(dstControls.size() == portsCount);
210 // But let's be sure
211 const auto portValuesCount =
212 std::min(srcControls.size(), dstControls.size());
213
214 if (portValuesCount != portsCount)
215 return false;
216
217 size_t portIndex {};
218
219 for (auto& port : controlPorts)
220 {
221 if (port->mIsInput)
222 dstControls[portIndex] = srcControls[portIndex];
223
224 ++portIndex;
225 }
226
227 // Ignore mpState
228
229 return true;
230}
int min(int a, int b)
LV2EffectSettings & GetSettings(EffectSettings &settings)
Definition: LV2Ports.h:215
const LV2Ports mPorts
Definition: LV2Effect.h:121
LV2ControlPortArray mControlPorts
Definition: LV2Ports.h:283
std::vector< float > values
vector of values in correspondence with the control ports
Definition: LV2Ports.h:208

References GetSettings(), LV2Ports::mControlPorts, min(), mPorts, and LV2EffectSettings::values.

Here is the call graph for this function:

◆ ExportPresets()

void LV2Effect::ExportPresets ( const EffectPlugin plugin,
const EffectSettings settings 
) const
overridevirtual

Reimplemented from BasicEffectUIServices.

Definition at line 453 of file LV2Effect.cpp.

455{
456}

◆ GetDescription()

TranslatableString LV2Effect::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 93 of file LV2Effect.cpp.

94{
95 return XO("n/a");
96}
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetFactoryPresets()

RegistryPaths LV2Effect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Implements EffectSettingsManager.

Definition at line 392 of file LV2Effect.cpp.

393{
394 using namespace LV2Symbols;
396 return mFactoryPresetNames;
397
398 if (LilvNodesPtr presets{ lilv_plugin_get_related(&mPlug, node_Preset) }) {
399 LILV_FOREACH(nodes, i, presets.get()) {
400 const auto preset = lilv_nodes_get(presets.get(), i);
401
403
404 lilv_world_load_resource(gWorld, preset);
405
406 if (LilvNodesPtr labels{ lilv_world_find_nodes(gWorld, preset,
407 node_Label, nullptr) }) {
408 const auto label = lilv_nodes_get_first(labels.get());
410 }
411 else
412 mFactoryPresetNames.push_back(
413 LilvString(preset).AfterLast(wxT('#')));
414 }
415 }
416
418
419 return mFactoryPresetNames;
420}
wxT("CloseDown"))
Lilv_ptr< LilvNodes, lilv_nodes_free > LilvNodesPtr
wxString LilvString(const LilvNode *node)
Definition: LV2Utils.h:37
EffectReverbSettings preset
Definition: Reverb.cpp:44
TranslatableString label
Definition: TagsEditor.cpp:164
bool mFactoryPresetsLoaded
Definition: LV2Effect.h:134
RegistryPaths mFactoryPresetNames
Definition: LV2Effect.h:135
wxArrayString mFactoryPresetUris
Definition: LV2Effect.h:136
LilvWorld * gWorld
Definition: LV2Symbols.cpp:31

References LV2Symbols::gWorld, label, LilvString(), mFactoryPresetNames, mFactoryPresetsLoaded, mFactoryPresetUris, mPlug, preset, and wxT().

Here is the call graph for this function:

◆ GetFamily()

EffectFamilySymbol LV2Effect::GetFamily ( ) const
overridevirtual

Report identifier and user-visible name of the effect protocol.

Implements EffectDefinitionInterface.

Definition at line 122 of file LV2Effect.cpp.

123{
124 return LV2EFFECTS_FAMILY;
125}
#define LV2EFFECTS_FAMILY
Definition: LV2Effect.h:32

References LV2EFFECTS_FAMILY.

◆ GetPath()

PluginPath LV2Effect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 66 of file LV2Effect.cpp.

67{
68 return LilvString(lilv_plugin_get_uri(&mPlug));
69}

References LilvString(), and mPlug.

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol LV2Effect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 71 of file LV2Effect.cpp.

72{
74}
static ComponentInterfaceSymbol GetPluginSymbol(const LilvPlugin &plug)

References LV2FeaturesList::GetPluginSymbol(), and mPlug.

Here is the call graph for this function:

◆ GetType()

EffectType LV2Effect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 102 of file LV2Effect.cpp.

103{
104 if (mPorts.mAudioIn == 0 && mPorts.mAudioOut == 0)
105 {
106 return EffectTypeTool;
107 }
108
109 if (mPorts.mAudioIn == 0)
110 {
111 return EffectTypeGenerate;
112 }
113
114 if (mPorts.mAudioOut == 0)
115 {
116 return EffectTypeAnalyze;
117 }
118
119 return EffectTypeProcess;
120}
@ EffectTypeAnalyze
@ EffectTypeGenerate
@ EffectTypeTool
@ EffectTypeProcess
unsigned mAudioOut
Definition: LV2Ports.h:273
unsigned mAudioIn
Definition: LV2Ports.h:272

References EffectTypeAnalyze, EffectTypeGenerate, EffectTypeProcess, EffectTypeTool, LV2Ports::mAudioIn, LV2Ports::mAudioOut, and mPorts.

Referenced by PopulateUI(), RealtimeSupport(), and ShowClientInterface().

Here is the caller graph for this function:

◆ GetVendor()

VendorSymbol LV2Effect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 76 of file LV2Effect.cpp.

77{
78 wxString vendor = LilvStringMove(lilv_plugin_get_author_name(&mPlug));
79
80 if (vendor.empty())
81 {
82 return XO("n/a");
83 }
84
85 return {vendor};
86}
wxString LilvStringMove(LilvNode *node)
Definition: LV2Utils.h:45

References LilvStringMove(), mPlug, and XO().

Referenced by PopulateUI().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetVersion()

wxString LV2Effect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 88 of file LV2Effect.cpp.

89{
90 return wxT("1.0");
91}

References wxT().

Here is the call graph for this function:

◆ HasOptions()

bool LV2Effect::HasOptions ( ) const
overridevirtual

Whether there are preferences applying to the effect's family, for which a UI may be needed to change them

Implements EffectPlugin.

Definition at line 464 of file LV2Effect.cpp.

465{
466 return true;
467}

◆ ImportPresets()

OptionalMessage LV2Effect::ImportPresets ( const EffectPlugin plugin,
EffectSettings settings 
) const
overridevirtual
Returns
nullopt for failure

Reimplemented from BasicEffectUIServices.

Definition at line 458 of file LV2Effect.cpp.

460{
461 return { nullptr };
462}

◆ InitializePlugin()

bool LV2Effect::InitializePlugin ( )

Definition at line 150 of file LV2Effect.cpp.

151{
152 if (!mFeatures.mOk)
153 return false;
154
155 // Do a check only on temporary feature list objects
156 auto instanceFeatures = LV2InstanceFeaturesList{ mFeatures };
157 if (!instanceFeatures.mOk)
158 return false;
159 if (!LV2UIFeaturesList{ LV2WrapperFeaturesList{instanceFeatures},
160 nullptr, lilv_plugin_get_uri(&mPlug)
161 }.mOk)
162 return false;
163
164 // Determine available extensions
166 mWantsStateInterface = false;
167 if (LilvNodesPtr extdata{ lilv_plugin_get_extension_data(&mPlug) }) {
168 LILV_FOREACH(nodes, i, extdata.get()) {
169 const auto node = lilv_nodes_get(extdata.get(), i);
170 const auto uri = lilv_node_as_string(node);
171 if (strcmp(uri, LV2_OPTIONS__interface) == 0)
173 else if (strcmp(uri, LV2_STATE__interface) == 0)
175 }
176 }
177
178 return true;
179}
bool mWantsStateInterface
Definition: LV2Effect.h:124
bool mWantsOptionsInterface
Definition: LV2Effect.h:123
const LV2FeaturesList mFeatures
Definition: LV2Effect.h:119

References mFeatures, LV2FeaturesList::mOk, mPlug, mWantsOptionsInterface, and mWantsStateInterface.

Referenced by LV2EffectsModule::DiscoverPluginsAtPath().

Here is the caller graph for this function:

◆ IsDefault()

bool LV2Effect::IsDefault ( ) const
overridevirtual

Whether the effect sorts "above the line" in the menus.

Implements EffectDefinitionInterface.

Definition at line 132 of file LV2Effect.cpp.

133{
134 return false;
135}

◆ IsInteractive()

bool LV2Effect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 127 of file LV2Effect.cpp.

128{
129 return mPorts.mControlPorts.size() != 0;
130}

References LV2Ports::mControlPorts, and mPorts.

◆ LoadFactoryPreset()

OptionalMessage LV2Effect::LoadFactoryPreset ( int  id,
EffectSettings settings 
) const
overridevirtual

Change settings to the preset whose name is GetFactoryPresets()[id]

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 423 of file LV2Effect.cpp.

424{
425 using namespace LV2Symbols;
426 if (id < 0 || id >= (int) mFactoryPresetUris.size())
427 return {};
428
429 LilvNodePtr preset{ lilv_new_uri(gWorld, mFactoryPresetUris[id].ToUTF8()) };
430 if (!preset)
431 return {};
432
433 using LilvStatePtr = Lilv_ptr<LilvState, lilv_state_free>;
434 LilvStatePtr state{
435 lilv_state_new_from_world(gWorld,
437 };
438 if (!state)
439 return {};
440
441 auto &mySettings = GetSettings(settings);
442 mPorts.EmitPortValues(*state, mySettings);
443 // Save the state, for whatever might not be contained in port values
444 mySettings.mpState = move(state);
445 return { nullptr };
446}
std::unique_ptr< Type, Lilv_deleter< Type, f > > Lilv_ptr
Generate classes of smart pointers to lv2 resources.
Definition: LV2Utils.h:26
Lilv_ptr< LilvNode, lilv_node_free > LilvNodePtr
Definition: LV2Utils.h:33
static Settings & settings()
Definition: TrackInfo.cpp:87
LV2_URID_Map * URIDMapFeature() const
void EmitPortValues(const LilvState &state, LV2EffectSettings &settings) const
Definition: LV2Ports.cpp:411
std::string ToUTF8(const std::wstring &wstr)

References LV2Ports::EmitPortValues(), GetSettings(), LV2Symbols::gWorld, mFactoryPresetUris, mFeatures, mPorts, preset, settings(), audacity::ToUTF8(), and LV2FeaturesList::URIDMapFeature().

Here is the call graph for this function:

◆ LoadParameters()

OptionalMessage LV2Effect::LoadParameters ( const RegistryPath group,
EffectSettings settings 
) const
private

Definition at line 478 of file LV2Effect.cpp.

480{
481 wxString parms;
482 if (!GetConfig(*this,
483 PluginSettings::Private, group, wxT("Parameters"), parms, wxEmptyString))
484 return {};
486 if (!eap.SetParameters(parms))
487 return {};
488 if (!LoadSettings(eap, settings))
489 return {};
490 return { nullptr };
491}
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the SettingsVis...
bool SetParameters(const wxString &parms)
bool LoadSettings(const CommandParameters &parms, EffectSettings &settings) const override
Restore settings from keys and values.
Definition: LV2Effect.cpp:282
bool GetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, Value &var, const Value &defval)

References PluginSettings::GetConfig(), LoadSettings(), PluginSettings::Private, CommandParameters::SetParameters(), settings(), and wxT().

Referenced by LoadUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadSettings()

bool LV2Effect::LoadSettings ( const CommandParameters parms,
EffectSettings settings 
) const
overridevirtual

Restore settings from keys and values.

Returns
true on success

Implements EffectSettingsManager.

Definition at line 282 of file LV2Effect.cpp.

284{
285 // First pass validates values
286 for (auto & port : mPorts.mControlPorts) {
287 if (port->mIsInput) {
288 double d = 0.0;
289 if (!parms.Read(port->mName, &d))
290 return false;
291 // Use unscaled range here
292 if (d < port->mMin || d > port->mMax)
293 return false;
294 }
295 }
296
297 // Second pass actually sets the values
299 size_t index = 0;
300 for (auto & port : mPorts.mControlPorts) {
301 if (port->mIsInput) {
302 double d = 0.0;
303 if (!parms.Read(port->mName, &d))
304 return false;
305 values[index] = d;
306 }
307 ++index;
308 }
309
310 return true;
311}
const wxChar * values

References GetSettings(), LV2Ports::mControlPorts, mPorts, settings(), values, and LV2EffectSettings::values.

Referenced by LoadParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LoadUserPreset()

OptionalMessage LV2Effect::LoadUserPreset ( const RegistryPath name,
EffectSettings settings 
) const
overridevirtual

Change settings to a user-named preset

Returns
nullopt for failure

Implements EffectSettingsManager.

Definition at line 380 of file LV2Effect.cpp.

382{
384}
const TranslatableString name
Definition: Distortion.cpp:76
OptionalMessage LoadParameters(const RegistryPath &group, EffectSettings &settings) const
Definition: LV2Effect.cpp:478

References LoadParameters(), name, and settings().

Here is the call graph for this function:

◆ MakeEditor()

std::unique_ptr< EffectEditor > LV2Effect::MakeEditor ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access,
const EffectOutputs pOutputs 
) const
finalprivatevirtual

Will never be called.

Will not come here because Effect::PopulateUI is overridden

Implements StatelessEffectUIServices.

Definition at line 360 of file LV2Effect.cpp.

363{
365 assert(false);
366 return nullptr;
367}

◆ MakeInstance()

std::shared_ptr< EffectInstance > LV2Effect::MakeInstance ( ) const
overridevirtual

Make an object maintaining short-term state of an Effect.

One effect may have multiple instances extant simultaneously. Instances have state, may be implemented in foreign code, and are temporary, whereas EffectSettings represents persistent effect state that can be saved and reloaded from files.

Parameters
settingsmay be assumed to have a lifetime enclosing the instance's
Postcondition
true (no promises that the result isn't null)

Implements EffectInstanceFactory.

Definition at line 241 of file LV2Effect.cpp.

242{
243 auto result = std::make_shared<LV2Instance>(*this, mFeatures, mPorts);
244 if (result->IsOk())
245 return result;
246 return nullptr;
247}

References mFeatures, and mPorts.

◆ MakeOutputs()

auto LV2Effect::MakeOutputs ( ) const
overrideprivatevirtual

Produce an object to hold values to send to effect output meters.

Default implementation returns nullptr

Reimplemented from EffectSettingsManager.

Definition at line 232 of file LV2Effect.cpp.

233{
234 auto result = std::make_unique<LV2EffectOutputs>();
235 auto &values = result->values;
236 // This may waste a bit of space on input ports, but not likely much
237 values.resize(mPorts.mControlPorts.size());
238 return result;
239}

References LV2Ports::mControlPorts, mPorts, and values.

◆ MakeSettings()

EffectSettings LV2Effect::MakeSettings ( ) const
overrideprivatevirtual

Produce an object holding new, independent settings

Default implementation returns an empty any

Reimplemented from EffectSettingsManager.

Definition at line 181 of file LV2Effect.cpp.

182{
183 auto result = EffectSettings::Make<LV2EffectSettings>();
184 auto &settings = GetSettings(result);
185 // This may waste a bit of space on output ports, but not likely much
186 settings.values.reserve(mPorts.mControlPorts.size());
187 for (auto &controlPort : mPorts.mControlPorts) {
188 auto &value = settings.values.emplace_back();
189 value = controlPort->mDef;
190 }
191 return result;
192}

References GetSettings(), LV2Ports::mControlPorts, mPorts, and settings().

Here is the call graph for this function:

◆ PopulateUI()

std::unique_ptr< EffectEditor > LV2Effect::PopulateUI ( const EffectPlugin plugin,
ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access,
const EffectOutputs pOutputs 
) const
overridevirtual

Adds controls to a panel that is given as the parent window of S

Parameters
Sinterface for adding controls to a panel in a dialog
instanceguaranteed to have a lifetime containing that of the returned object
accessguaranteed to have a lifetime containing that of the returned object
pOutputsnull, or else points to outputs with lifetime containing that of the returned object
Returns
null for failure; else an object invoked to retrieve values of UI controls; it might also hold some state needed to implement event handlers of the controls; it will exist only while the dialog continues to exist

Implements EffectUIServices.

Definition at line 315 of file LV2Effect.cpp.

318{
319 auto &settings = access.Get();
320 auto parent = S.GetParent();
321
322 auto &myInstance = dynamic_cast<LV2Instance &>(instance);
323 auto pWrapper =
324 // Output port connection isn't needed for fancy UI wrapper. Its
325 // features are needed to make the suil_instance
326 myInstance.MakeWrapper(settings, mProjectRate, nullptr);
327 if (!pWrapper) {
328 AudacityMessageBox( XO("Couldn't instantiate effect") );
329 return nullptr;
330 }
331
332 // Determine if the GUI editor is supposed to be used or not
333 bool useGUI = false;
334 LV2Preferences::GetUseGUI(*this, useGUI);
335
336 // Until I figure out where to put the "Duration" control in the
337 // graphical editor, force usage of plain editor.
339 useGUI = false;
340
341 auto result = std::make_unique<LV2Editor>(*this, mPlug,
342 dynamic_cast<LV2Instance&>(instance),
343 access, pOutputs, mProjectRate, mFeatures, mPorts, parent, useGUI);
344
345#ifdef __WXMAC__
346 const auto vendor = GetVendor().Msgid().Translation();
347 const bool doX42Hack = vendor == "Robin Gareus";
348 result->mUI.mJustLeakMemory = doX42Hack;
349#endif
350
351 if (result->mUseGUI)
352 result->mUseGUI = result->BuildFancy(move(pWrapper), settings);
353 if (!result->mUseGUI && !result->BuildPlain(access))
354 return nullptr;
355 result->UpdateUI();
356
357 return result;
358}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define S(N)
Definition: ToChars.cpp:64
const TranslatableString & Msgid() const
double mProjectRate
Definition: EffectBase.h:105
virtual const EffectSettings & Get()=0
VendorSymbol GetVendor() const override
Definition: LV2Effect.cpp:76
EffectType GetType() const override
Type determines how it behaves.
Definition: LV2Effect.cpp:102
std::unique_ptr< LV2Wrapper > MakeWrapper(const EffectSettings &settings, double sampleRate, EffectOutputs *pOutputs)
Definition: LV2Instance.cpp:59
wxString Translation() const
bool GetUseGUI(const EffectDefinitionInterface &effect, bool &useGUI)

References AudacityMessageBox(), EffectTypeGenerate, EffectSettingsAccess::Get(), GetType(), LV2Preferences::GetUseGUI(), GetVendor(), LV2Instance::MakeWrapper(), mFeatures, mPlug, mPorts, EffectBase::mProjectRate, ComponentInterfaceSymbol::Msgid(), S, settings(), TranslatableString::Translation(), and XO().

Here is the call graph for this function:

◆ RealtimeSupport()

auto LV2Effect::RealtimeSupport ( ) const
overridevirtual

Since which version of Audacity has the effect supported realtime?

Implements EffectDefinitionInterface.

Definition at line 137 of file LV2Effect.cpp.

138{
139 // TODO reenable after achieving statelessness
140 return GetType() == EffectTypeProcess
143}

References EffectDefinitionInterface::Always, EffectTypeProcess, GetType(), and EffectDefinitionInterface::Never.

Here is the call graph for this function:

◆ SaveParameters()

bool LV2Effect::SaveParameters ( const RegistryPath group,
const EffectSettings settings 
) const
private

Definition at line 493 of file LV2Effect.cpp.

495{
496 // PRL: This function just dumps the several control port values to the
497 // config files. Should it be reimplemented with
498 // lilv_state_new_from_instance to capture -- I don't know what -- other
499 // important state?
500
502 if (!SaveSettings(settings, eap))
503 return false;
504
505 wxString parms;
506 if (!eap.GetParameters(parms))
507 return false;
508
509 return SetConfig(*this,
510 PluginSettings::Private, group, wxT("Parameters"), parms);
511}
bool GetParameters(wxString &parms)
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: LV2Effect.cpp:268
bool SetConfig(const EffectDefinitionInterface &ident, ConfigurationType type, const RegistryPath &group, const RegistryPath &key, const Value &value)

References CommandParameters::GetParameters(), PluginSettings::Private, SaveSettings(), PluginSettings::SetConfig(), settings(), and wxT().

Referenced by SaveUserPreset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveSettings()

bool LV2Effect::SaveSettings ( const EffectSettings settings,
CommandParameters parms 
) const
overridevirtual

Store settings as keys and values.

The override may assume parms is initially empty

Returns
true on success

Implements EffectSettingsManager.

Definition at line 268 of file LV2Effect.cpp.

270{
272 size_t index = 0;
273 for (auto & port : mPorts.mControlPorts) {
274 if (port->mIsInput)
275 if (!parms.Write(port->mName, values[index]))
276 return false;
277 ++index;
278 }
279 return true;
280}

References GetSettings(), LV2Ports::mControlPorts, mPorts, settings(), values, and LV2EffectSettings::values.

Referenced by SaveParameters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SaveUserPreset()

bool LV2Effect::SaveUserPreset ( const RegistryPath name,
const EffectSettings settings 
) const
overridevirtual

Save settings in the configuration file as a user-named preset.

Implements EffectSettingsManager.

Definition at line 386 of file LV2Effect.cpp.

388{
390}
bool SaveParameters(const RegistryPath &group, const EffectSettings &settings) const
Definition: LV2Effect.cpp:493

References name, SaveParameters(), and settings().

Here is the call graph for this function:

◆ ShowClientInterface()

int LV2Effect::ShowClientInterface ( const EffectPlugin plugin,
wxWindow &  parent,
wxDialog &  dialog,
EffectEditor pEditor,
bool  forceModal 
) const
overridevirtual
Returns
0 if destructive effect processing should not proceed (and there may be a non-modal dialog still opened); otherwise, modal dialog return code

Reimplemented from BasicEffectUIServices.

Definition at line 249 of file LV2Effect.cpp.

251{
252 if (pEditor)
253 // Remember the dialog with a weak pointer, but don't control its lifetime
254 static_cast<LV2Editor*>(pEditor)->mDialog = &dialog;
255 // Try to give the window a sensible default/minimum size
256 dialog.Layout();
257 dialog.Fit();
258 dialog.SetMinSize(dialog.GetSize());
260 dialog.SetMaxSize(dialog.GetSize());
261 if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) {
262 dialog.Show();
263 return 0;
264 }
265 return dialog.ShowModal();
266}

References EffectTypeAnalyze, GetType(), mFeatures, LV2FeaturesListBase::mNoResize, and EffectDefinitionInterface::SupportsRealtime().

Here is the call graph for this function:

◆ ShowOptions()

void LV2Effect::ShowOptions ( const EffectPlugin plugin) const
overridevirtual

Reimplemented from BasicEffectUIServices.

Definition at line 469 of file LV2Effect.cpp.

470{
471 LV2Preferences::Dialog{ *this }.ShowModal();
472}

◆ SupportsAutomation()

bool LV2Effect::SupportsAutomation ( ) const
overridevirtual

Whether the effect has any automatable controls.

Implements EffectDefinitionInterface.

Definition at line 145 of file LV2Effect.cpp.

146{
147 return true;
148}

Friends And Related Function Documentation

◆ LV2PluginValidator

friend class LV2PluginValidator
friend

Definition at line 39 of file LV2Effect.h.

Member Data Documentation

◆ mCVInBuffers

FloatBuffers LV2Effect::mCVInBuffers
private

Definition at line 128 of file LV2Effect.h.

◆ mCVOutBuffers

FloatBuffers LV2Effect::mCVOutBuffers
private

Definition at line 129 of file LV2Effect.h.

◆ mFactoryPresetNames

RegistryPaths LV2Effect::mFactoryPresetNames
mutableprivate

Definition at line 135 of file LV2Effect.h.

Referenced by GetFactoryPresets().

◆ mFactoryPresetsLoaded

bool LV2Effect::mFactoryPresetsLoaded { false }
mutableprivate

Definition at line 134 of file LV2Effect.h.

Referenced by GetFactoryPresets().

◆ mFactoryPresetUris

wxArrayString LV2Effect::mFactoryPresetUris
mutableprivate

Definition at line 136 of file LV2Effect.h.

Referenced by GetFactoryPresets(), and LoadFactoryPreset().

◆ mFeatures

const LV2FeaturesList LV2Effect::mFeatures { mPlug }
private

◆ mFramePos

size_t LV2Effect::mFramePos {}
private

Definition at line 126 of file LV2Effect.h.

◆ mLength

double LV2Effect::mLength {}
private

Definition at line 131 of file LV2Effect.h.

◆ mPlug

const LilvPlugin& LV2Effect::mPlug
private

◆ mPorts

const LV2Ports LV2Effect::mPorts { mPlug }
private

◆ mWantsOptionsInterface

bool LV2Effect::mWantsOptionsInterface { false }
private

Definition at line 123 of file LV2Effect.h.

Referenced by InitializePlugin().

◆ mWantsStateInterface

bool LV2Effect::mWantsStateInterface { false }
private

Definition at line 124 of file LV2Effect.h.

Referenced by InitializePlugin().


The documentation for this class was generated from the following files: