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...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
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...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
bool InitializePlugin ()
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () 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...
 
bool LoadUserPreset (const RegistryPath &name, EffectSettings &settings) const override
 Change settings to a user-named preset. More...
 
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...
 
bool LoadFactoryPreset (int id, EffectSettings &settings) const override
 Change settings to the preset whose name is GetFactoryPresets()[id] More...
 
bool LoadFactoryDefaults (EffectSettings &settings) const override
 Change settings back to "factory default". More...
 
virtual const EffectParameterMethodsParameters () const
 
int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal) override
 
EffectUIClientInterfaceGetEffectUIClientInterface () override
 Returns the EffectUIClientInterface instance for this effect. More...
 
std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access) override
 Adds controls to a panel that is given as the parent window of S More...
 
bool IsGraphicalUI () override
 
bool ValidateUI (EffectSettings &) override
 
bool CloseUI () override
 
bool CanExportPresets () override
 
void ExportPresets (const EffectSettings &settings) const override
 
void ImportPresets (EffectSettings &settings) override
 
bool HasOptions () override
 
void ShowOptions () override
 
const EffectSettingsManagerGetDefinition () const override
 
virtual NumericFormatSymbol GetSelectionFormat ()
 
int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false) override
 Usually applies factory to self and given access. More...
 
bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const override
 
bool LoadSettingsFromString (const wxString &parms, EffectSettings &settings) const override
 
bool IsBatchProcessing () const override
 
void SetBatchProcessing () override
 
void UnsetBatchProcessing () override
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
unsigned TestUIFlags (unsigned mask)
 
bool Delegate (Effect &delegate, EffectSettings &settings)
 Re-invoke DoEffect on another Effect object that implements the work. More...
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={}) const
 
bool EnableApply (bool enable=true)
 
wxWindow * GetUIParent ()
 
- Public Member Functions inherited from EffectBase
 EffectBase ()
 
 ~EffectBase () override
 
- Public Member Functions inherited from EffectUIClientInterface
virtual ~EffectUIClientInterface ()
 
virtual int ShowClientInterface (wxWindow &parent, wxDialog &dialog, EffectUIValidator *pValidator, bool forceModal=false)=0
 
virtual bool IsGraphicalUI ()=0
 
virtual std::unique_ptr< EffectUIValidatorPopulateUI (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)=0
 Adds controls to a panel that is given as the parent window of S More...
 
virtual bool CanExportPresets ()=0
 
virtual void ExportPresets (const EffectSettings &settings) const =0
 
virtual void ImportPresets (EffectSettings &settings)=0
 
virtual bool HasOptions ()=0
 
virtual void ShowOptions ()=0
 
virtual bool ValidateUI (EffectSettings &settings)=0
 
virtual bool CloseUI ()=0
 
- Public Member Functions inherited from EffectPlugin
EffectPluginoperator= (EffectPlugin &)=delete
 
virtual ~EffectPlugin ()
 
virtual const EffectSettingsManagerGetDefinition () const =0
 
virtual int ShowHostInterface (wxWindow &parent, const EffectDialogFactory &factory, std::shared_ptr< EffectInstance > &pInstance, EffectSettingsAccess &access, bool forceModal=false)=0
 Usually applies factory to self and given access. More...
 
virtual EffectUIClientInterfaceGetEffectUIClientInterface ()=0
 Returns the EffectUIClientInterface instance for this effect. More...
 
virtual void Preview (EffectSettingsAccess &access, bool dryOnly)=0
 
virtual bool SaveSettingsAsString (const EffectSettings &settings, wxString &parms) const =0
 
virtual bool 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, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent=nullptr, const EffectDialogFactory &dialogFactory={}, const EffectSettingsAccessPtr &pAccess=nullptr)=0
 Unfortunately complicated dual-use function. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)=0
 Update controls for the settings. More...
 
virtual bool TransferDataFromWindow (EffectSettings &settings)=0
 Update the given settings from controls. More...
 
- 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
 

Private Member Functions

EffectSettings MakeSettings () const override
 
bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst, SettingsCopyDirection copyDirection) const override
 Update one settings object from another. More...
 
bool 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 {}
 
wxWindow * mParent {}
 
bool mFactoryPresetsLoaded { false }
 
RegistryPaths mFactoryPresetNames
 
wxArrayString mFactoryPresetUris
 

Friends

class LV2PluginValidator
 

Additional Inherited Members

- Public Types inherited from Effect
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Public Types inherited from EffectPlugin
using EffectSettingsAccessPtr = std::shared_ptr< EffectSettingsAccess >
 
- Public Types inherited from EffectDefinitionInterface
enum class  RealtimeSince : unsigned { Never , Since_3_2 , Always }
 In which versions of Audacity was an effect realtime capable? More...
 
- 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 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 EnablePreview (bool enable=true)
 
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...
 
virtual std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access)
 Add controls to effect panel; always succeeds. 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)
 
std::shared_ptr< AddedAnalysisTrackAddAnalysisTrack (const wxString &name=wxString())
 
ModifiedAnalysisTrack ModifyAnalysisTrack (const LabelTrack *pOrigTrack, const wxString &name=wxString())
 
TrackAddToOutputTracks (const std::shared_ptr< Track > &t)
 
- Protected Member Functions inherited from EffectBase
void Preview (EffectSettingsAccess &access, bool dryOnly) override
 
bool DoEffect (EffectSettings &settings, double projectRate, TrackList *list, WaveTrackFactory *factory, NotifyingSelectedRegion &selectedRegion, unsigned flags, wxWindow *pParent, const EffectDialogFactory &dialogFactory, const EffectSettingsAccessPtr &pAccess) override
 Unfortunately complicated dual-use function. 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 Effect
wxWeakRef< wxDialog > mHostUIDialog
 This smart pointer tracks the lifetime of the dialog. More...
 
wxWindow * mUIParent {}
 
- 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:109

◆ ~LV2Effect()

LV2Effect::~LV2Effect ( )
virtual

Definition at line 58 of file LV2Effect.cpp.

59{
60}

Member Function Documentation

◆ CanExportPresets()

bool LV2Effect::CanExportPresets ( )
overridevirtual

Reimplemented from Effect.

Definition at line 428 of file LV2Effect.cpp.

429{
430 return false;
431}

◆ CloseUI()

bool LV2Effect::CloseUI ( )
overridevirtual

Reimplemented from Effect.

Definition at line 349 of file LV2Effect.cpp.

350{
351#ifdef __WXMAC__
352#ifdef __WX_EVTLOOP_BUSY_WAITING__
353 wxEventLoop::SetBusyWaiting(false);
354#endif
355#endif
356
357 mParent = nullptr;
358 return true;
359}
wxWindow * mParent
Definition: LV2Effect.h:124

References mParent.

◆ CopySettingsContents()

bool LV2Effect::CopySettingsContents ( const EffectSettings src,
EffectSettings dst,
SettingsCopyDirection  copyDirection 
) 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 193 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 const auto copyOutputs = copyDirection == SettingsCopyDirection::WorkerToMain;
218
219 size_t portIndex {};
220
221 for (auto& port : controlPorts)
222 {
223 if (port->mIsInput || copyOutputs)
224 dstControls[portIndex] = srcControls[portIndex];
225
226 ++portIndex;
227 }
228
229 // Ignore mpState
230
231 return true;
232}
int min(int a, int b)
@ WorkerToMain
Worker thread settings replicated to main thread.
LV2EffectSettings & GetSettings(EffectSettings &settings)
Definition: LV2Ports.h:215
const LV2Ports mPorts
Definition: LV2Effect.h:112
LV2ControlPortArray mControlPorts
Definition: LV2Ports.h:274
std::vector< float > values
vector of values in correspondence with the control ports
Definition: LV2Ports.h:208

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

Here is the call graph for this function:

◆ ExportPresets()

void LV2Effect::ExportPresets ( const EffectSettings settings) const
overridevirtual

Reimplemented from Effect.

Definition at line 433 of file LV2Effect.cpp.

434{
435}

◆ GetDescription()

TranslatableString LV2Effect::GetDescription ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 93 of file LV2Effect.cpp.

94{
95 return XO("n/a");
96}
#define XO(s)
Definition: Internat.h:31

References XO.

◆ GetFactoryPresets()

RegistryPaths LV2Effect::GetFactoryPresets ( ) const
overridevirtual

Report names of factory presets.

Reimplemented from Effect.

Definition at line 373 of file LV2Effect.cpp.

374{
375 using namespace LV2Symbols;
377 return mFactoryPresetNames;
378
379 if (LilvNodesPtr presets{ lilv_plugin_get_related(&mPlug, node_Preset) }) {
380 LILV_FOREACH(nodes, i, presets.get()) {
381 const auto preset = lilv_nodes_get(presets.get(), i);
382
384
385 lilv_world_load_resource(gWorld, preset);
386
387 if (LilvNodesPtr labels{ lilv_world_find_nodes(gWorld, preset,
388 node_Label, nullptr) }) {
389 const auto label = lilv_nodes_get_first(labels.get());
391 }
392 else
393 mFactoryPresetNames.push_back(
394 LilvString(preset).AfterLast(wxT('#')));
395 }
396 }
397
399
400 return mFactoryPresetNames;
401}
wxT("CloseDown"))
Lilv_ptr< LilvNodes, lilv_nodes_free > LilvNodesPtr
wxString LilvString(const LilvNode *node)
Definition: LV2Utils.h:37
EffectReverbSettings preset
Definition: Reverb.cpp:46
TranslatableString label
Definition: TagsEditor.cpp:163
bool mFactoryPresetsLoaded
Definition: LV2Effect.h:127
RegistryPaths mFactoryPresetNames
Definition: LV2Effect.h:128
wxArrayString mFactoryPresetUris
Definition: LV2Effect.h:129
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.

Reimplemented from Effect.

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

Reimplemented from Effect.

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

Reimplemented from Effect.

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.

Reimplemented from Effect.

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:264
unsigned mAudioIn
Definition: LV2Ports.h:263

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

Reimplemented from Effect.

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.

Here is the call graph for this function:

◆ GetVersion()

wxString LV2Effect::GetVersion ( ) const
overridevirtual

Reimplemented from Effect.

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 ( )
overridevirtual

Reimplemented from Effect.

Definition at line 441 of file LV2Effect.cpp.

442{
443 return true;
444}

◆ ImportPresets()

void LV2Effect::ImportPresets ( EffectSettings settings)
overridevirtual

Reimplemented from Effect.

Definition at line 437 of file LV2Effect.cpp.

438{
439}

◆ 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:115
bool mWantsOptionsInterface
Definition: LV2Effect.h:114
const LV2FeaturesList mFeatures
Definition: LV2Effect.h:110

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.

Reimplemented from Effect.

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.

Reimplemented from Effect.

Definition at line 127 of file LV2Effect.cpp.

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

References LV2Ports::mControlPorts, and mPorts.

◆ LoadFactoryPreset()

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

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

Reimplemented from Effect.

Definition at line 403 of file LV2Effect.cpp.

404{
405 using namespace LV2Symbols;
406 if (id < 0 || id >= (int) mFactoryPresetUris.size())
407 return false;
408
409 LilvNodePtr preset{ lilv_new_uri(gWorld, mFactoryPresetUris[id].ToUTF8()) };
410 if (!preset)
411 return false;
412
413 using LilvStatePtr = Lilv_ptr<LilvState, lilv_state_free>;
414 if (LilvStatePtr state{
415 lilv_state_new_from_world(gWorld,
417 }){
418 auto &mySettings = GetSettings(settings);
419 mPorts.EmitPortValues(*state, mySettings);
420 // Save the state, for whatever might not be contained in port values
421 mySettings.mpState = move(state);
422 return true;
423 }
424 else
425 return false;
426}
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:395
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()

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

Definition at line 455 of file LV2Effect.cpp.

457{
458 wxString parms;
459 if (!GetConfig(*this,
460 PluginSettings::Private, group, wxT("Parameters"), parms, wxEmptyString))
461 return false;
463 if (!eap.SetParameters(parms))
464 return false;
465 return LoadSettings(eap, settings);
466}
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:275
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

Reimplemented from Effect.

Definition at line 275 of file LV2Effect.cpp.

277{
278 // First pass validates values
279 for (auto & port : mPorts.mControlPorts) {
280 if (port->mIsInput) {
281 double d = 0.0;
282 if (!parms.Read(port->mName, &d))
283 return false;
284 // Use unscaled range here
285 if (d < port->mMin || d > port->mMax)
286 return false;
287 }
288 }
289
290 // Second pass actually sets the values
292 size_t index = 0;
293 for (auto & port : mPorts.mControlPorts) {
294 if (port->mIsInput) {
295 double d = 0.0;
296 if (!parms.Read(port->mName, &d))
297 return false;
298 values[index] = d;
299 }
300 ++index;
301 }
302
303 return true;
304}
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()

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

Change settings to a user-named preset.

Reimplemented from Effect.

Definition at line 361 of file LV2Effect.cpp.

363{
365}
const TranslatableString name
Definition: Distortion.cpp:82
bool LoadParameters(const RegistryPath &group, EffectSettings &settings) const
Definition: LV2Effect.cpp:455

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

Here is the call graph for this function:

◆ 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 234 of file LV2Effect.cpp.

235{
236 auto result = std::make_shared<LV2Instance>(*this, mFeatures, mPorts);
237 if (result->IsOk())
238 return result;
239 return nullptr;
240}

References mFeatures, and mPorts.

◆ 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 settings.values.reserve(mPorts.mControlPorts.size());
186 for (auto &controlPort : mPorts.mControlPorts) {
187 auto &value = settings.values.emplace_back();
188 value = controlPort->mDef;
189 }
190 return result;
191}

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

Here is the call graph for this function:

◆ PopulateUI()

std::unique_ptr< EffectUIValidator > LV2Effect::PopulateUI ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access 
)
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
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

Reimplemented from Effect.

Definition at line 312 of file LV2Effect.cpp.

314{
315 auto &settings = access.Get();
316 auto parent = S.GetParent();
317 mParent = parent;
318
319 auto &myInstance = dynamic_cast<LV2Instance &>(instance);
320 auto pWrapper =
321 myInstance.MakeWrapper(settings, mProjectRate, true);
322 if (!pWrapper) {
323 AudacityMessageBox( XO("Couldn't instantiate effect") );
324 return nullptr;
325 }
326
327 // Determine if the GUI editor is supposed to be used or not
328 bool useGUI = false;
329 LV2Preferences::GetUseGUI(*this, useGUI);
330
331 // Until I figure out where to put the "Duration" control in the
332 // graphical editor, force usage of plain editor.
334 useGUI = false;
335
336 auto result = std::make_unique<LV2Validator>(*this, mPlug,
337 dynamic_cast<LV2Instance&>(instance),
338 access, mProjectRate, mFeatures, mPorts, parent, useGUI);
339
340 if (result->mUseGUI)
341 result->mUseGUI = result->BuildFancy(move(pWrapper), settings);
342 if (!result->mUseGUI && !result->BuildPlain(access))
343 return nullptr;
344 result->UpdateUI();
345
346 return result;
347}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
#define S(N)
Definition: ToChars.cpp:64
double mProjectRate
Definition: EffectBase.h:99
virtual const EffectSettings & Get()=0
EffectType GetType() const override
Type determines how it behaves.
Definition: LV2Effect.cpp:102
std::unique_ptr< LV2Wrapper > MakeWrapper(const EffectSettings &settings, double sampleRate, bool useOutput)
Definition: LV2Instance.cpp:57
bool GetUseGUI(const EffectDefinitionInterface &effect, bool &useGUI)

References AudacityMessageBox(), EffectTypeGenerate, EffectSettingsAccess::Get(), GetType(), LV2Preferences::GetUseGUI(), LV2Instance::MakeWrapper(), mFeatures, mParent, mPlug, mPorts, EffectBase::mProjectRate, S, settings(), 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?

Reimplemented from Effect.

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 468 of file LV2Effect.cpp.

470{
471 // PRL: This function just dumps the several control port values to the
472 // config files. Should it be reimplemented with
473 // lilv_state_new_from_instance to capture -- I don't know what -- other
474 // important state?
475
477 if (!SaveSettings(settings, eap))
478 return false;
479
480 wxString parms;
481 if (!eap.GetParameters(parms))
482 return false;
483
484 return SetConfig(*this,
485 PluginSettings::Private, group, wxT("Parameters"), parms);
486}
bool GetParameters(wxString &parms)
bool SaveSettings(const EffectSettings &settings, CommandParameters &parms) const override
Store settings as keys and values.
Definition: LV2Effect.cpp:261
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

Reimplemented from Effect.

Definition at line 261 of file LV2Effect.cpp.

263{
265 size_t index = 0;
266 for (auto & port : mPorts.mControlPorts) {
267 if (port->mIsInput)
268 if (!parms.Write(port->mName, values[index]))
269 return false;
270 ++index;
271 }
272 return true;
273}

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.

Reimplemented from Effect.

Definition at line 367 of file LV2Effect.cpp.

369{
371}
bool SaveParameters(const RegistryPath &group, const EffectSettings &settings) const
Definition: LV2Effect.cpp:468

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

Here is the call graph for this function:

◆ ShowClientInterface()

int LV2Effect::ShowClientInterface ( wxWindow &  parent,
wxDialog &  dialog,
EffectUIValidator pValidator,
bool  forceModal 
)
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 Effect.

Definition at line 242 of file LV2Effect.cpp.

244{
245 if (pValidator)
246 // Remember the dialog with a weak pointer, but don't control its lifetime
247 static_cast<LV2Validator*>(pValidator)->mDialog = &dialog;
248 // Try to give the window a sensible default/minimum size
249 dialog.Layout();
250 dialog.Fit();
251 dialog.SetMinSize(dialog.GetSize());
253 dialog.SetMaxSize(dialog.GetSize());
254 if ((SupportsRealtime() || GetType() == EffectTypeAnalyze) && !forceModal) {
255 dialog.Show();
256 return 0;
257 }
258 return dialog.ShowModal();
259}

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

Here is the call graph for this function:

◆ ShowOptions()

void LV2Effect::ShowOptions ( )
overridevirtual

Reimplemented from Effect.

Definition at line 446 of file LV2Effect.cpp.

447{
448 LV2Preferences::Dialog{ mParent, *this }.ShowModal();
449}

References mParent.

◆ SupportsAutomation()

bool LV2Effect::SupportsAutomation ( ) const
overridevirtual

Whether the effect has any automatable controls.

Reimplemented from Effect.

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 119 of file LV2Effect.h.

◆ mCVOutBuffers

FloatBuffers LV2Effect::mCVOutBuffers
private

Definition at line 120 of file LV2Effect.h.

◆ mFactoryPresetNames

RegistryPaths LV2Effect::mFactoryPresetNames
mutableprivate

Definition at line 128 of file LV2Effect.h.

Referenced by GetFactoryPresets().

◆ mFactoryPresetsLoaded

bool LV2Effect::mFactoryPresetsLoaded { false }
mutableprivate

Definition at line 127 of file LV2Effect.h.

Referenced by GetFactoryPresets().

◆ mFactoryPresetUris

wxArrayString LV2Effect::mFactoryPresetUris
mutableprivate

Definition at line 129 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 117 of file LV2Effect.h.

◆ mLength

double LV2Effect::mLength {}
private

Definition at line 122 of file LV2Effect.h.

◆ mParent

wxWindow* LV2Effect::mParent {}
private

Definition at line 124 of file LV2Effect.h.

Referenced by CloseUI(), PopulateUI(), and ShowOptions().

◆ mPlug

const LilvPlugin& LV2Effect::mPlug
private

◆ mPorts

const LV2Ports LV2Effect::mPorts { mPlug }
private

◆ mWantsOptionsInterface

bool LV2Effect::mWantsOptionsInterface { false }
private

Definition at line 114 of file LV2Effect.h.

Referenced by InitializePlugin().

◆ mWantsStateInterface

bool LV2Effect::mWantsStateInterface { false }
private

Definition at line 115 of file LV2Effect.h.

Referenced by InitializePlugin().


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