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

#include <VampEffect.h>

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

Public Member Functions

 VampEffect (std::unique_ptr< Vamp::Plugin > &&plugin, const PluginPath &path, int output, bool hasParameters)
 
virtual ~VampEffect ()
 
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...
 
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...
 
unsigned GetAudioInCount () const override
 How many input buffers to allocate at once. More...
 
bool Init () override
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 
std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 
bool TransferDataFromWindow (EffectSettings &settings) override
 
- Public Member Functions inherited from StatefulEffect
 ~StatefulEffect () override
 
std::shared_ptr< EffectInstanceMakeInstance () const override
 Make an object maintaining short-term state of an Effect. More...
 
- Public Member Functions inherited from StatefulEffectBase
virtual bool Init ()
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 
virtual bool RealtimeInitialize (EffectSettings &settings, double sampleRate)
 
virtual bool RealtimeAddProcessor (EffectSettings &settings, EffectOutputs *pOutputs, unsigned numChannels, float sampleRate)
 
virtual bool RealtimeSuspend ()
 
virtual bool RealtimeResume ()
 
virtual bool RealtimeProcessStart (MessagePackage &package)
 settings are possibly changed, since last call, by an asynchronous dialog More...
 
virtual size_t RealtimeProcess (size_t group, EffectSettings &settings, const float *const *inBuf, float *const *outBuf, size_t numSamples)
 
virtual bool RealtimeProcessEnd (EffectSettings &settings) noexcept
 settings can be updated to let a dialog change appearance at idle More...
 
virtual bool RealtimeFinalize (EffectSettings &settings) noexcept
 
virtual size_t SetBlockSize (size_t maxBlockSize)
 
virtual size_t GetBlockSize () const
 
virtual unsigned GetAudioInCount () const
 How many input buffers to allocate at once. More...
 
virtual unsigned GetAudioOutCount () const
 How many output buffers to allocate at once. More...
 
virtual sampleCount GetLatency () const
 
virtual bool NeedsDither () const
 
virtual bool ProcessInitialize (EffectSettings &settings, double sampleRate, ChannelNames chanMap=nullptr)
 
virtual bool ProcessFinalize () noexcept
 
- 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
 
virtual EffectSettings MakeSettings () const
 
virtual bool CopySettingsContents (const EffectSettings &src, EffectSettings &dst) const
 Update one settings object from another. More...
 
virtual std::unique_ptr< EffectOutputsMakeOutputs () const
 Produce an object to hold values to send to effect output meters. More...
 
- 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 StatefulEffectUIServices
 ~StatefulEffectUIServices () override
 
std::unique_ptr< EffectEditorPopulateUI (const EffectPlugin &plugin, ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
 Allows PopulateOrExchange to return null. More...
 
virtual std::unique_ptr< EffectEditorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs)
 Add controls to effect panel; always succeeds. More...
 
virtual bool TransferDataToWindow (const EffectSettings &settings)
 
virtual bool TransferDataFromWindow (EffectSettings &settings)
 
- 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

void AddFeatures (LabelTrack *track, Vamp::Plugin::FeatureSet &features)
 
void UpdateFromPlugin ()
 
void OnCheckBox (wxCommandEvent &evt)
 
void OnChoice (wxCommandEvent &evt)
 
void OnSlider (wxCommandEvent &evt)
 
void OnTextCtrl (wxCommandEvent &evt)
 

Private Attributes

wxWeakRef< wxWindow > mUIParent {}
 
std::unique_ptr< Vamp::Plugin > mPlugin
 
PluginPath mPath
 
int mOutput
 
bool mHasParameters
 
Vamp::HostExt::PluginLoader::PluginKey mKey
 
wxString mName
 
double mRate
 
bool mInSlider
 
bool mInText
 
Vamp::Plugin::ParameterList mParameters
 
Floats mValues
 
ArrayOf< wxSlider * > mSliders
 
ArrayOf< wxTextCtrl * > mFields
 
ArrayOf< wxStaticText * > mLabels
 
ArrayOf< wxCheckBox * > mToggles
 
ArrayOf< wxChoice * > mChoices
 
wxChoice * mProgram
 

Additional Inherited Members

- Public Types inherited from StatefulEffectBase
using MessagePackage = EffectInstance::MessagePackage
 
- 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 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 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 38 of file VampEffect.h.

Constructor & Destructor Documentation

◆ VampEffect()

VampEffect::VampEffect ( std::unique_ptr< Vamp::Plugin > &&  plugin,
const PluginPath path,
int  output,
bool  hasParameters 
)

Definition at line 63 of file VampEffect.cpp.

67: mPlugin(std::move(plugin)),
68 mPath(path),
69 mOutput(output),
70 mHasParameters(hasParameters),
71 mRate(0)
72{
73 mKey = mPath.BeforeFirst(wxT('/')).ToUTF8();
74 mName = mPath.AfterFirst(wxT('/'));
75}
wxT("CloseDown"))
double mRate
Definition: VampEffect.h:101
PluginPath mPath
Definition: VampEffect.h:95
int mOutput
Definition: VampEffect.h:96
wxString mName
Definition: VampEffect.h:100
std::unique_ptr< Vamp::Plugin > mPlugin
Definition: VampEffect.h:94
bool mHasParameters
Definition: VampEffect.h:97
Vamp::HostExt::PluginLoader::PluginKey mKey
Definition: VampEffect.h:99

References wxT().

Here is the call graph for this function:

◆ ~VampEffect()

VampEffect::~VampEffect ( )
virtual

Definition at line 77 of file VampEffect.cpp.

78{
79}

Member Function Documentation

◆ AddFeatures()

void VampEffect::AddFeatures ( LabelTrack track,
Vamp::Plugin::FeatureSet &  features 
)
private

Definition at line 713 of file VampEffect.cpp.

715{
716 for (Vamp::Plugin::FeatureList::iterator fli = features[mOutput].begin();
717 fli != features[mOutput].end(); ++fli)
718 {
719 Vamp::RealTime ftime0 = fli->timestamp;
720 double ltime0 = ftime0.sec + (double(ftime0.nsec) / 1000000000.0);
721
722 Vamp::RealTime ftime1 = ftime0;
723 if (fli->hasDuration) ftime1 = ftime0 + fli->duration;
724 double ltime1 = ftime1.sec + (double(ftime1.nsec) / 1000000000.0);
725
726 wxString label = LAT1CTOWX(fli->label.c_str());
727 if (label == wxString())
728 {
729 if (fli->values.empty())
730 {
731 label = wxString::Format(LAT1CTOWX("%.3f"), ltime0);
732 }
733 else
734 {
735 label = wxString::Format(LAT1CTOWX("%.3f"), *fli->values.begin());
736 }
737 }
738
739 ltrack->AddLabel(SelectedRegion(ltime0, ltime1), label);
740 }
741}
#define LAT1CTOWX(X)
Definition: Internat.h:158
TranslatableString label
Definition: TagsEditor.cpp:164
Defines a selected portion of a project.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References LabelTrack::AddLabel(), PackedArray::begin(), label, LAT1CTOWX, and mOutput.

Referenced by Process().

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

◆ GetAudioInCount()

unsigned VampEffect::GetAudioInCount ( ) const
overridevirtual

How many input buffers to allocate at once.

If the instance processes channels independently, this can return 1 The result is not necessarily well defined before RealtimeInitialize Default implementation returns 0

Reimplemented from StatefulEffectBase.

Definition at line 135 of file VampEffect.cpp.

136{
137 return mPlugin->getMaxChannelCount();
138}

References mPlugin.

◆ GetDescription()

TranslatableString VampEffect::GetDescription ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 105 of file VampEffect.cpp.

106{
107 return Verbatim(
108 wxString::FromUTF8(mPlugin->getCopyright().c_str()) );
109}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References mPlugin, and Verbatim().

Here is the call graph for this function:

◆ GetFamily()

EffectFamilySymbol VampEffect::GetFamily ( ) const
overridevirtual

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

Implements EffectDefinitionInterface.

Definition at line 120 of file VampEffect.cpp.

121{
122 return VAMPEFFECTS_FAMILY;
123}
#define VAMPEFFECTS_FAMILY
Definition: VampEffect.h:36

References VAMPEFFECTS_FAMILY.

◆ GetPath()

PluginPath VampEffect::GetPath ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 85 of file VampEffect.cpp.

86{
87 return mPath;
88}

References mPath.

◆ GetSymbol()

ComponentInterfaceSymbol VampEffect::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 90 of file VampEffect.cpp.

91{
92 return mName;
93}

References mName.

Referenced by Process().

Here is the caller graph for this function:

◆ GetType()

EffectType VampEffect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Implements EffectDefinitionInterface.

Definition at line 115 of file VampEffect.cpp.

116{
117 return EffectTypeAnalyze;
118}
@ EffectTypeAnalyze

References EffectTypeAnalyze.

◆ GetVendor()

VendorSymbol VampEffect::GetVendor ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 95 of file VampEffect.cpp.

96{
97 return { wxString::FromUTF8(mPlugin->getMaker().c_str()) };
98}

References mPlugin.

◆ GetVersion()

wxString VampEffect::GetVersion ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 100 of file VampEffect.cpp.

101{
102 return wxString::Format(wxT("%d"), mPlugin->getPluginVersion());
103}

References mPlugin, and wxT().

Here is the call graph for this function:

◆ Init()

bool VampEffect::Init ( )
overridevirtual

Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 293 of file VampEffect.cpp.

294{
295 mRate = 0.0;
296
297 // PRL: this loop checked that channels of a track have the same rate,
298 // but there was no check that all tracks have one rate, and only the first
299 // is remembered in mRate. Is that correct?
300
301 for (auto leader : inputTracks()->Leaders<const WaveTrack>()) {
302 auto channelGroup = TrackList::Channels( leader );
303 auto rate = (*channelGroup.first++) -> GetRate();
304 for(auto channel : channelGroup) {
305 if (rate != channel->GetRate())
306 // PRL: Track rate might not match individual clip rates.
307 // So is this check not adequate?
308 {
309 // TODO: more-than-two-channels-message
311 XO(
312"Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match.") );
313 return false;
314 }
315 }
316 if (mRate == 0.0)
317 mRate = rate;
318 }
319
320 if (mRate <= 0.0)
321 {
323 }
324
325 // The plugin must be reloaded to allow changing parameters
326
327 Vamp::HostExt::PluginLoader *loader = Vamp::HostExt::PluginLoader::getInstance();
328 mPlugin.reset(loader->loadPlugin(mKey, mRate, Vamp::HostExt::PluginLoader::ADAPT_ALL));
329 if (!mPlugin)
330 {
332 XO("Sorry, failed to load Vamp Plug-in."));
333 return false;
334 }
335
336 return true;
337}
XO("Cut/Copy/Paste")
const TrackList * inputTracks() const
Definition: EffectBase.h:108
double mProjectRate
Definition: EffectBase.h:105
static int DoMessageBox(const EffectPlugin &plugin, const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1544
double GetRate(const Track &track)
Definition: TimeTrack.cpp:179

References TrackList::Channels(), EffectUIServices::DoMessageBox(), anonymous_namespace{TimeTrack.cpp}::GetRate(), EffectBase::inputTracks(), mKey, mPlugin, EffectBase::mProjectRate, mRate, and XO().

Referenced by Process().

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

◆ IsDefault()

bool VampEffect::IsDefault ( ) const
overridevirtual

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

Implements EffectDefinitionInterface.

Definition at line 130 of file VampEffect.cpp.

131{
132 return false;
133}

◆ IsInteractive()

bool VampEffect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Implements EffectDefinitionInterface.

Definition at line 125 of file VampEffect.cpp.

126{
127 return mHasParameters;
128}

References mHasParameters.

◆ LoadSettings()

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

Restore settings from keys and values.

Returns
true on success

Implements EffectSettingsManager.

Definition at line 187 of file VampEffect.cpp.

189{
190 // First pass verifies values
191 for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
192 {
193 wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
194 float lower = mParameters[p].minValue;
195 float upper = mParameters[p].maxValue;
196 bool good = false;
197
198 if (mParameters[p].isQuantized &&
199 mParameters[p].quantizeStep == 1.0 &&
200 lower == 0.0 &&
201 upper == 1.0)
202 {
203 bool val;
204
205 good = parms.Read(key, &val);
206 }
207 else if (mParameters[p].isQuantized &&
208 mParameters[p].quantizeStep == 1.0 &&
209 !mParameters[p].valueNames.empty())
210 {
211 std::vector<EnumValueSymbol> choices;
212 int val;
213
214 for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
215 {
216 wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
217 choices.push_back(choice);
218 }
219
220 good = parms.ReadEnum(key, &val, choices.data(), choices.size()) && val != wxNOT_FOUND;
221 }
222 else
223 {
224 double val;
225
226 good = parms.Read(key, &val) && val >= lower && val <= upper;
227 }
228
229 if (!good)
230 {
231 return false;
232 }
233 }
234
235 // Second pass sets the variables
236 for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
237 {
238 wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
239 float lower = mParameters[p].minValue;
240 float upper = mParameters[p].maxValue;
241
242 if (mParameters[p].isQuantized &&
243 mParameters[p].quantizeStep == 1.0 &&
244 lower == 0.0 &&
245 upper == 1.0)
246 {
247 bool val;
248
249 parms.Read(key, &val);
250
251 mPlugin->setParameter(mParameters[p].identifier, val ? upper : lower);
252 }
253 else if (mParameters[p].isQuantized &&
254 mParameters[p].quantizeStep == 1.0 &&
255 !mParameters[p].valueNames.empty())
256 {
257 std::vector<EnumValueSymbol> choices;
258 int val = 0;
259
260 for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
261 {
262 wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
263 choices.push_back(choice);
264 }
265
266 parms.ReadEnum(key, &val, choices.data(), choices.size());
267
268 mPlugin->setParameter(mParameters[p].identifier, (float) val);
269 }
270 else
271 {
272 double val;
273
274 parms.Read(key, &val);
275
276 if (mParameters[p].isQuantized)
277 {
278 float qs = mParameters[p].quantizeStep;
279
280 if (qs != 0.0)
281 {
282 val = (int)((val - lower) / qs + 0.5) * qs + lower;
283 }
284 }
285
286 mPlugin->setParameter(mParameters[p].identifier, val);
287 }
288 }
289
290 return true;
291}
static const AudacityProject::AttachedObjects::RegisteredFactory key
bool ReadEnum(const wxString &key, int *pi, const EnumValueSymbol choices[], size_t nChoices, const ObsoleteMap obsoletes[]=nullptr, size_t nObsoletes=0) const
Vamp::Plugin::ParameterList mParameters
Definition: VampEffect.h:106

References key, mParameters, mPlugin, and CommandParameters::ReadEnum().

Here is the call graph for this function:

◆ OnCheckBox()

void VampEffect::OnCheckBox ( wxCommandEvent &  evt)
private

Definition at line 786 of file VampEffect.cpp.

787{
788 int p = event.GetId() - ID_Toggles;
789
790 mPlugin->setParameter(mParameters[p].identifier, mToggles[p]->GetValue());
791}
@ ID_Toggles
Definition: VampEffect.cpp:47
ArrayOf< wxCheckBox * > mToggles
Definition: VampEffect.h:113

References ID_Toggles, mParameters, mPlugin, and mToggles.

◆ OnChoice()

void VampEffect::OnChoice ( wxCommandEvent &  evt)
private

Definition at line 793 of file VampEffect.cpp.

794{
795 int p = evt.GetId();
796
797 // special value for programs
798 if (p == ID_Program)
799 {
800 Vamp::Plugin::ProgramList programs = mPlugin->getPrograms();
801 mPlugin->selectProgram(programs[evt.GetInt()]);
803 return;
804 }
805
806 mPlugin->setParameter(mParameters[p - ID_Choices].identifier, evt.GetInt());
807}
@ ID_Choices
Definition: VampEffect.cpp:45
@ ID_Program
Definition: VampEffect.cpp:43
void UpdateFromPlugin()
Definition: VampEffect.cpp:743

References ID_Choices, ID_Program, mParameters, mPlugin, and UpdateFromPlugin().

Here is the call graph for this function:

◆ OnSlider()

void VampEffect::OnSlider ( wxCommandEvent &  evt)
private

Definition at line 809 of file VampEffect.cpp.

810{
811 int p = evt.GetId() - ID_Sliders;
812
813 float lower = mParameters[p].minValue;
814 float upper = mParameters[p].maxValue;
815 float range = upper - lower;
816 float val = (evt.GetInt() / 1000.0) * range;
817
818 if (mParameters[p].isQuantized)
819 {
820 float qs = mParameters[p].quantizeStep;
821
822 if (qs != 0.0)
823 {
824 val = (int)(val / qs + 0.5) * qs;
825 }
826 }
827
828 val += lower;
829
830 mValues[p] = val;
831 mFields[p]->GetValidator()->TransferToWindow();
832
833 mPlugin->setParameter(mParameters[p].identifier, val);
834}
@ ID_Sliders
Definition: VampEffect.cpp:44
Floats mValues
Definition: VampEffect.h:108
ArrayOf< wxTextCtrl * > mFields
Definition: VampEffect.h:111

References ID_Sliders, mFields, mParameters, mPlugin, and mValues.

◆ OnTextCtrl()

void VampEffect::OnTextCtrl ( wxCommandEvent &  evt)
private

Definition at line 836 of file VampEffect.cpp.

837{
838 int p = evt.GetId() - ID_Texts;
839
840 mFields[p]->GetValidator()->TransferFromWindow();
841
842 float lower = mParameters[p].minValue;
843 float upper = mParameters[p].maxValue;
844 float range = upper - lower;
845 float val = mValues[p];
846
847 if (mParameters[p].isQuantized)
848 {
849 float qs = mParameters[p].quantizeStep;
850
851 if (qs != 0.0)
852 {
853 val = (int)((val - lower) / qs + 0.5) * qs + lower;
854 }
855 }
856
857 mPlugin->setParameter(mParameters[p].identifier, val);
858
859 mSliders[p]->SetValue((int)(((val - lower) / range) * 1000.0 + 0.5));
860}
@ ID_Texts
Definition: VampEffect.cpp:46
ArrayOf< wxSlider * > mSliders
Definition: VampEffect.h:110

References ID_Texts, mFields, mParameters, mPlugin, mSliders, and mValues.

◆ PopulateOrExchange()

std::unique_ptr< EffectEditor > VampEffect::PopulateOrExchange ( ShuttleGui S,
EffectInstance instance,
EffectSettingsAccess access,
const EffectOutputs pOutputs 
)
overridevirtual

Add controls to effect panel; always succeeds.

Returns
if not null, then return it from PopulateUI instead of a DefaultEffectEditor; default implementation returns null

Reimplemented from StatefulEffectUIServices.

Definition at line 525 of file VampEffect.cpp.

528{
529 mUIParent = S.GetParent();
530 Vamp::Plugin::ProgramList programs = mPlugin->getPrograms();
531
532 mParameters = mPlugin->getParameterDescriptors();
533
534 auto count = mParameters.size();
535
536 mToggles.reinit( count );
537 mSliders.reinit( count );
538 mFields.reinit( count );
539 mLabels.reinit( count );
540 mChoices.reinit( count );
541 mValues.reinit( count );
542
543 wxScrolledWindow *scroller = S.Style(wxVSCROLL | wxTAB_TRAVERSAL)
544 .StartScroller(2);
545 {
546 S.StartStatic(XO("Plugin Settings"));
547 {
548 S.StartMultiColumn(5, wxEXPAND);
549 {
550 S.SetStretchyCol(3);
551
552 if (!programs.empty())
553 {
554 S.AddPrompt(XXO("Program"));
555
556 S.Id(ID_Program);
557 mProgram = S.Name(XO("Program"))
558 .MinSize( { -1, -1 } )
559 .Position(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL)
560 .AddChoice( {},
561 [&]{
562 TranslatableStrings choices;
563 for (const auto &program : programs)
564 choices.push_back(
565 Verbatim(wxString::FromUTF8(program.c_str())));
566 return choices;
567 }(),
568 Verbatim( wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()) )
569 );
570
571 S.AddSpace(1, 1);
572 S.AddSpace(1, 1);
573 S.AddSpace(1, 1);
574 }
575
576 for (size_t p = 0; p < count; p++)
577 {
578 wxString tip = wxString::FromUTF8(mParameters[p].description.c_str());
579 wxString unit = wxString::FromUTF8(mParameters[p].unit.c_str());
580
581 float value = mPlugin->getParameter(mParameters[p].identifier);
582
583 mToggles[p] = NULL;
584 mChoices[p] = NULL;
585 mSliders[p] = NULL;
586 mFields[p] = NULL;
587 mValues[p] = 0.0;
588
589 wxString labelText = wxString::FromUTF8(mParameters[p].name.c_str());
590 if (!unit.empty())
591 {
592 labelText += wxT(" (") + unit + wxT(")");
593 }
594 /* i18n-hint: An item name introducing a value, which is not part of the string but
595 appears in a following text box window; translate with appropriate punctuation */
596 S.AddPrompt(XXO("%s:").Format( labelText ));
597
598 if (mParameters[p].isQuantized &&
599 mParameters[p].quantizeStep == 1.0 &&
600 mParameters[p].minValue == 0.0 &&
601 mParameters[p].maxValue == 1.0)
602 {
603 S.Id(ID_Toggles + p);
604 mToggles[p] = S.ToolTip( Verbatim( tip ) )
605 .Name( Verbatim( labelText ) )
606 .Position(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL)
607 .AddCheckBox( {},
608 value > 0.5 );
609
610 S.AddSpace(1, 1);
611 S.AddSpace(1, 1);
612 S.AddSpace(1, 1);
613
614 }
615 else if (mParameters[p].isQuantized &&
616 mParameters[p].quantizeStep == 1.0 &&
617 !mParameters[p].valueNames.empty())
618 {
619 TranslatableStrings choices;
620 int selected = -1;
621
622 for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)
623 {
624 wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
625 if (size_t(value - mParameters[p].minValue + 0.5) == i)
626 {
627 selected = i;
628 }
629 choices.push_back( Verbatim( choice ) );
630 }
631
632 S.Id(ID_Choices + p);
633 mChoices[p] = S.ToolTip( Verbatim( tip ) )
634 .Name( Verbatim( labelText ) )
635 .Position(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL)
636 .MinSize( { -1, -1 } )
637 .AddChoice( {}, choices, selected );
638
639 S.AddSpace(1, 1);
640 S.AddSpace(1, 1);
641 S.AddSpace(1, 1);
642 }
643 else
644 {
645 mValues[p] = value;
646
647 float range = mParameters[p].maxValue - mParameters[p].minValue;
648
649 S.Id(ID_Texts + p);
650 mFields[p] = S.ToolTip( Verbatim( tip ) )
651 .Name( Verbatim( labelText ) )
652 .Position(wxALIGN_CENTER_VERTICAL | wxALL)
653 .Validator<FloatingPointValidator<float>>(
654 6, &mValues[p],
655 (range < 10
656 ? NumValidatorStyle::THREE_TRAILING_ZEROES
657 : range < 100
658 ? NumValidatorStyle::TWO_TRAILING_ZEROES
659 : NumValidatorStyle::ONE_TRAILING_ZERO),
660 mParameters[p].minValue, mParameters[p].maxValue)
661 .AddTextBox( {}, wxT(""), 12);
662
663 wxString str = Internat::ToDisplayString(mParameters[p].minValue);
664 S.AddPrompt( Verbatim( str ) );
665
666 S.Id(ID_Sliders + p);
667 mSliders[p] = S.ToolTip( Verbatim( tip ) )
668 .Name( Verbatim( labelText ) )
669 .Style(wxSL_HORIZONTAL)
670 .MinSize( { 150, -1 } )
671 .AddSlider( {}, 0, 1000, 0);
672
674 S.AddUnits( Verbatim( str ) );
675 }
676 }
677 }
678 S.EndMultiColumn();
679 }
680 S.EndStatic();
681 }
682 S.EndScroller();
683
684 scroller->SetScrollRate(0, 20);
685
686 return nullptr;
687}
#define str(a)
const TranslatableString name
Definition: Distortion.cpp:76
XXO("&Cut/Copy/Paste Toolbar")
#define S(N)
Definition: ToChars.cpp:64
std::vector< TranslatableString > TranslatableStrings
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
Abstract base class used in importing a file.
static wxString ToDisplayString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, uses the user's locale's decimal separator.
Definition: Internat.cpp:161
ArrayOf< wxChoice * > mChoices
Definition: VampEffect.h:114
ArrayOf< wxStaticText * > mLabels
Definition: VampEffect.h:112
wxChoice * mProgram
Definition: VampEffect.h:115
wxWeakRef< wxWindow > mUIParent
Definition: VampEffect.h:92

References ID_Choices, ID_Program, ID_Sliders, ID_Texts, ID_Toggles, mChoices, mFields, mLabels, mParameters, mPlugin, mProgram, mSliders, mToggles, mUIParent, mValues, name, ArrayOf< X >::reinit(), S, str, Internat::ToDisplayString(), Verbatim(), wxT(), XO(), and XXO().

Here is the call graph for this function:

◆ Process()

bool VampEffect::Process ( EffectInstance instance,
EffectSettings settings 
)
overridevirtual

!! todo: retain parameters previously set

Implements StatefulEffectBase.

Definition at line 339 of file VampEffect.cpp.

340{
341 if (!mPlugin)
342 {
343 return false;
344 }
345
346 int count = 0;
347
348 bool multiple = false;
349 unsigned prevTrackChannels = 0;
350
351 if (GetNumWaveGroups() > 1)
352 {
353 // if there is another track beyond this one and any linked one,
354 // then we're processing more than one track. That means we
355 // should use the originating track name in each NEW label
356 // track's name, to make clear which is which
357 multiple = true;
358 }
359
360 std::vector<std::shared_ptr<AddedAnalysisTrack>> addedTracks;
361
362 for (auto leader : inputTracks()->Leaders<const WaveTrack>())
363 {
364 auto channelGroup = TrackList::Channels(leader);
365 auto left = *channelGroup.first++;
366
367 unsigned channels = 1;
368
369 // channelGroup now contains all but the first channel
370 const WaveTrack *right =
371 channelGroup.size() ? *channelGroup.first++ : nullptr;
372 if (right)
373 channels = 2;
374
375 sampleCount start = 0;
376 sampleCount len = 0;
377 GetBounds(*left, right, &start, &len);
378
379 // TODO: more-than-two-channels
380
381 size_t step = mPlugin->getPreferredStepSize();
382 size_t block = mPlugin->getPreferredBlockSize();
383
384 bool initialiseRequired = true;
385
386 if (block == 0)
387 {
388 if (step != 0)
389 {
390 block = step;
391 }
392 else
393 {
394 block = 1024;
395 }
396 }
397
398 if (step == 0)
399 {
400 step = block;
401 }
402
403 if (prevTrackChannels > 0)
404 {
405 // Plugin has already been initialised, so if the number of
406 // channels remains the same, we only need to do a reset.
407 // Otherwise we need to re-construct the whole plugin,
408 // because a Vamp plugin can't be re-initialised.
409 if (prevTrackChannels == channels)
410 {
411 mPlugin->reset();
412 initialiseRequired = false;
413 }
414 else
415 {
417 Init();
418 }
419 }
420
421 if (initialiseRequired)
422 {
423 if (!mPlugin->initialise(channels, step, block))
424 {
426 XO("Sorry, Vamp Plug-in failed to initialize."));
427 return false;
428 }
429 }
430
431 const auto effectName = GetSymbol().Translation();
432 addedTracks.push_back(AddAnalysisTrack(*this,
433 multiple
434 ? wxString::Format( _("%s: %s"), left->GetName(), effectName )
435 : effectName
436 ));
437 LabelTrack *ltrack = addedTracks.back()->get();
438
439 FloatBuffers data{ channels, block };
440
441 auto originalLen = len;
442
443 auto pos = start;
444
445 while (len != 0)
446 {
447 const auto request = limitSampleBufferSize( block, len );
448
449 if (left)
450 {
451 left->GetFloats(data[0].get(), pos, request);
452 }
453
454 if (right)
455 {
456 right->GetFloats(data[1].get(), pos, request);
457 }
458
459 if (request < block)
460 {
461 for (unsigned int c = 0; c < channels; ++c)
462 {
463 for (decltype(block) i = request; i < block; ++i)
464 {
465 data[c][i] = 0.f;
466 }
467 }
468 }
469
470 // UNSAFE_SAMPLE_COUNT_TRUNCATION
471 // Truncation in case of very long tracks!
472 Vamp::RealTime timestamp = Vamp::RealTime::frame2RealTime(
473 long( pos.as_long_long() ),
474 (int)(mRate + 0.5)
475 );
476
477 Vamp::Plugin::FeatureSet features = mPlugin->process(
478 reinterpret_cast< float** >( data.get() ), timestamp);
479 AddFeatures(ltrack, features);
480
481 if (len > (int)step)
482 {
483 len -= step;
484 }
485 else
486 {
487 len = 0;
488 }
489
490 pos += step;
491
492 if (channels > 1)
493 {
494 if (TrackGroupProgress(count,
495 (pos - start).as_double() /
496 originalLen.as_double() ))
497 {
498 return false;
499 }
500 }
501 else
502 {
503 if (TrackProgress(count,
504 (pos - start).as_double() /
505 originalLen.as_double() ))
506 {
507 return false;
508 }
509 }
510 }
511
512 Vamp::Plugin::FeatureSet features = mPlugin->getRemainingFeatures();
513 AddFeatures(ltrack, features);
514
515 prevTrackChannels = channels;
516 }
517
518 // All completed without cancellation, so commit the addition of tracks now
519 for (auto &addedTrack : addedTracks)
520 addedTrack->Commit();
521
522 return true;
523}
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(Effect &effect, const wxString &name)
#define _(s)
Definition: Internat.h:73
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: SampleCount.cpp:22
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
const wxString Translation() const
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:356
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={}) const
Definition: Effect.cpp:346
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:366
int GetNumWaveGroups() const
Definition: Effect.h:141
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
bool GetFloats(float *buffer, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Retrieve samples from a track in floating-point format, regardless of the storage format.
Definition: SampleTrack.h:82
ComponentInterfaceSymbol GetSymbol() const override
Definition: VampEffect.cpp:90
bool Init() override
Definition: VampEffect.cpp:293
void AddFeatures(LabelTrack *track, Vamp::Plugin::FeatureSet &features)
Definition: VampEffect.cpp:713
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
Positions or offsets within audio files need a wide type.
Definition: SampleCount.h:19

References _, AddAnalysisTrack(), AddFeatures(), TrackList::Channels(), EffectUIServices::DoMessageBox(), Effect::GetBounds(), SampleTrack::GetFloats(), Effect::GetNumWaveGroups(), GetSymbol(), Init(), EffectBase::inputTracks(), limitSampleBufferSize(), mPlugin, mRate, ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::size(), Effect::TrackGroupProgress(), Effect::TrackProgress(), ComponentInterfaceSymbol::Translation(), and XO().

Here is the call graph for this function:

◆ SaveSettings()

bool VampEffect::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 140 of file VampEffect.cpp.

142{
143 for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
144 {
145 wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
146 float value = mPlugin->getParameter(mParameters[p].identifier);
147 float lower = mParameters[p].minValue;
148 float upper = mParameters[p].maxValue;
149
150 if (mParameters[p].isQuantized &&
151 mParameters[p].quantizeStep == 1.0 &&
152 lower == 0.0 &&
153 upper == 1.0)
154 {
155 bool val = value > 0.5;
156
157 parms.Write(key, val);
158 }
159 else if (mParameters[p].isQuantized &&
160 mParameters[p].quantizeStep == 1.0 &&
161 !mParameters[p].valueNames.empty())
162 {
163 std::vector<EnumValueSymbol> choices;
164 int val = 0;
165
166 for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
167 {
168 wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
169 if (size_t(value - mParameters[p].minValue + 0.5) == i)
170 {
171 val = i;
172 }
173 choices.push_back(choice);
174 }
175
176 parms.WriteEnum(key, val, choices.data(), choices.size());
177 }
178 else
179 {
180 parms.Write(key, value);
181 }
182 }
183
184 return true;
185}
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)

References key, mParameters, mPlugin, and CommandParameters::WriteEnum().

Here is the call graph for this function:

◆ TransferDataFromWindow()

bool VampEffect::TransferDataFromWindow ( EffectSettings settings)
overridevirtual

Update the given settings from controls; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

Definition at line 701 of file VampEffect.cpp.

702{
703 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
704 {
705 return false;
706 }
707
708 return true;
709}

References mUIParent.

◆ TransferDataToWindow()

bool VampEffect::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings; default does nothing, returns true

Reimplemented from StatefulEffectUIServices.

Definition at line 689 of file VampEffect.cpp.

690{
691 if (!mUIParent->TransferDataToWindow())
692 {
693 return false;
694 }
695
697
698 return true;
699}

References mUIParent, and UpdateFromPlugin().

Here is the call graph for this function:

◆ UpdateFromPlugin()

void VampEffect::UpdateFromPlugin ( )
private

Definition at line 743 of file VampEffect.cpp.

744{
745 for (size_t p = 0, cnt = mParameters.size(); p < cnt; p++)
746 {
747 float value = mPlugin->getParameter(mParameters[p].identifier);
748
749 if (mParameters[p].isQuantized &&
750 mParameters[p].quantizeStep == 1.0 &&
751 mParameters[p].minValue == 0.0 &&
752 mParameters[p].maxValue == 1.0)
753 {
754 mToggles[p]->SetValue(value > 0.5);
755 }
756 else if (mParameters[p].isQuantized &&
757 mParameters[p].quantizeStep == 1.0 &&
758 !mParameters[p].valueNames.empty())
759 {
760 mChoices[p]->SetSelection(size_t(value - mParameters[p].minValue + 0.5));
761 }
762 else
763 {
764 mValues[p] = value;
765 mFields[p]->GetValidator()->TransferToWindow();
766
767 float lower = mParameters[p].minValue;
768 float upper = mParameters[p].maxValue;
769 float range = upper - lower;
770
771 if (mParameters[p].isQuantized)
772 {
773 float qs = mParameters[p].quantizeStep;
774
775 if (qs != 0.0)
776 {
777 value = (int)((value - lower) / qs + 0.5) * qs + lower;
778 }
779 }
780
781 mSliders[p]->SetValue((int)(((value - lower) / range) * 1000.0 + 0.5));
782 }
783 }
784}

References mChoices, mFields, mParameters, mPlugin, mSliders, mToggles, and mValues.

Referenced by OnChoice(), and TransferDataToWindow().

Here is the caller graph for this function:

Member Data Documentation

◆ mChoices

ArrayOf<wxChoice *> VampEffect::mChoices
private

Definition at line 114 of file VampEffect.h.

Referenced by PopulateOrExchange(), and UpdateFromPlugin().

◆ mFields

ArrayOf<wxTextCtrl *> VampEffect::mFields
private

Definition at line 111 of file VampEffect.h.

Referenced by OnSlider(), OnTextCtrl(), PopulateOrExchange(), and UpdateFromPlugin().

◆ mHasParameters

bool VampEffect::mHasParameters
private

Definition at line 97 of file VampEffect.h.

Referenced by IsInteractive().

◆ mInSlider

bool VampEffect::mInSlider
private

Definition at line 103 of file VampEffect.h.

◆ mInText

bool VampEffect::mInText
private

Definition at line 104 of file VampEffect.h.

◆ mKey

Vamp::HostExt::PluginLoader::PluginKey VampEffect::mKey
private

Definition at line 99 of file VampEffect.h.

Referenced by Init().

◆ mLabels

ArrayOf<wxStaticText *> VampEffect::mLabels
private

Definition at line 112 of file VampEffect.h.

Referenced by PopulateOrExchange().

◆ mName

wxString VampEffect::mName
private

Definition at line 100 of file VampEffect.h.

Referenced by GetSymbol().

◆ mOutput

int VampEffect::mOutput
private

Definition at line 96 of file VampEffect.h.

Referenced by AddFeatures().

◆ mParameters

Vamp::Plugin::ParameterList VampEffect::mParameters
private

◆ mPath

PluginPath VampEffect::mPath
private

Definition at line 95 of file VampEffect.h.

Referenced by GetPath().

◆ mPlugin

std::unique_ptr<Vamp::Plugin> VampEffect::mPlugin
private

◆ mProgram

wxChoice* VampEffect::mProgram
private

Definition at line 115 of file VampEffect.h.

Referenced by PopulateOrExchange().

◆ mRate

double VampEffect::mRate
private

Definition at line 101 of file VampEffect.h.

Referenced by Init(), and Process().

◆ mSliders

ArrayOf<wxSlider *> VampEffect::mSliders
private

Definition at line 110 of file VampEffect.h.

Referenced by OnTextCtrl(), PopulateOrExchange(), and UpdateFromPlugin().

◆ mToggles

ArrayOf<wxCheckBox *> VampEffect::mToggles
private

Definition at line 113 of file VampEffect.h.

Referenced by OnCheckBox(), PopulateOrExchange(), and UpdateFromPlugin().

◆ mUIParent

wxWeakRef<wxWindow> VampEffect::mUIParent {}
private

Definition at line 92 of file VampEffect.h.

Referenced by PopulateOrExchange(), TransferDataFromWindow(), and TransferDataToWindow().

◆ mValues

Floats VampEffect::mValues
private

Definition at line 108 of file VampEffect.h.

Referenced by OnSlider(), OnTextCtrl(), PopulateOrExchange(), and UpdateFromPlugin().


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