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
 Call once to set up state for whole list of tracks to be processed. More...
 
bool Process (EffectInstance &instance, EffectSettings &settings) override
 Actually do the effect here. More...
 
std::unique_ptr< EffectUIValidatorPopulateOrExchange (ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) override
 Add controls to effect panel; always succeeds. More...
 
bool TransferDataToWindow (const EffectSettings &settings) override
 Update controls for the settings. More...
 
bool TransferDataFromWindow (EffectSettings &settings) override
 Update the given settings from controls. More...
 
- Public Member Functions inherited from StatefulEffect
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 ()
 Call once to set up state for whole list of tracks to be processed. More...
 
virtual bool Process (EffectInstance &instance, EffectSettings &settings)=0
 Actually do the effect here. More...
 
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
 
- 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
 
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, const EffectOutputs *pOutputs) 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
 
OptionalMessage 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
 
OptionalMessage 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
 
void SetTracks (TrackList *pTracks)
 
- 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, const EffectOutputs *pOutputs)=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 OptionalMessage 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 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, 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
 
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
 

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

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 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 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, const EffectOutputs *pOutputs)
 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 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 37 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 68 of file VampEffect.cpp.

72: mPlugin(std::move(plugin)),
73 mPath(path),
74 mOutput(output),
75 mHasParameters(hasParameters),
76 mRate(0)
77{
78 mKey = mPath.BeforeFirst(wxT('/')).ToUTF8();
79 mName = mPath.AfterFirst(wxT('/'));
80}
wxT("CloseDown"))
double mRate
Definition: VampEffect.h:98
PluginPath mPath
Definition: VampEffect.h:92
int mOutput
Definition: VampEffect.h:93
wxString mName
Definition: VampEffect.h:97
std::unique_ptr< Vamp::Plugin > mPlugin
Definition: VampEffect.h:91
bool mHasParameters
Definition: VampEffect.h:94
Vamp::HostExt::PluginLoader::PluginKey mKey
Definition: VampEffect.h:96

References wxT().

Here is the call graph for this function:

◆ ~VampEffect()

VampEffect::~VampEffect ( )
virtual

Definition at line 82 of file VampEffect.cpp.

83{
84}

Member Function Documentation

◆ AddFeatures()

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

Definition at line 716 of file VampEffect.cpp.

718{
719 for (Vamp::Plugin::FeatureList::iterator fli = features[mOutput].begin();
720 fli != features[mOutput].end(); ++fli)
721 {
722 Vamp::RealTime ftime0 = fli->timestamp;
723 double ltime0 = ftime0.sec + (double(ftime0.nsec) / 1000000000.0);
724
725 Vamp::RealTime ftime1 = ftime0;
726 if (fli->hasDuration) ftime1 = ftime0 + fli->duration;
727 double ltime1 = ftime1.sec + (double(ftime1.nsec) / 1000000000.0);
728
729 wxString label = LAT1CTOWX(fli->label.c_str());
730 if (label == wxString())
731 {
732 if (fli->values.empty())
733 {
734 label = wxString::Format(LAT1CTOWX("%.3f"), ltime0);
735 }
736 else
737 {
738 label = wxString::Format(LAT1CTOWX("%.3f"), *fli->values.begin());
739 }
740 }
741
742 ltrack->AddLabel(SelectedRegion(ltime0, ltime1), label);
743 }
744}
#define LAT1CTOWX(X)
Definition: Internat.h:160
TranslatableString label
Definition: TagsEditor.cpp:163
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 140 of file VampEffect.cpp.

141{
142 return mPlugin->getMaxChannelCount();
143}

References mPlugin.

◆ GetDescription()

TranslatableString VampEffect::GetDescription ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 110 of file VampEffect.cpp.

111{
112 return Verbatim(
113 wxString::FromUTF8(mPlugin->getCopyright().c_str()) );
114}
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.

Reimplemented from Effect.

Definition at line 125 of file VampEffect.cpp.

126{
127 return VAMPEFFECTS_FAMILY;
128}
#define VAMPEFFECTS_FAMILY
Definition: VampEffect.h:35

References VAMPEFFECTS_FAMILY.

◆ GetPath()

PluginPath VampEffect::GetPath ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 90 of file VampEffect.cpp.

91{
92 return mPath;
93}

References mPath.

◆ GetSymbol()

ComponentInterfaceSymbol VampEffect::GetSymbol ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 95 of file VampEffect.cpp.

96{
97 return mName;
98}

References mName.

Referenced by Process().

Here is the caller graph for this function:

◆ GetType()

EffectType VampEffect::GetType ( ) const
overridevirtual

Type determines how it behaves.

Reimplemented from Effect.

Definition at line 120 of file VampEffect.cpp.

121{
122 return EffectTypeAnalyze;
123}
@ EffectTypeAnalyze

References EffectTypeAnalyze.

◆ GetVendor()

VendorSymbol VampEffect::GetVendor ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 100 of file VampEffect.cpp.

101{
102 return { wxString::FromUTF8(mPlugin->getMaker().c_str()) };
103}

References mPlugin.

◆ GetVersion()

wxString VampEffect::GetVersion ( ) const
overridevirtual

Reimplemented from Effect.

Definition at line 105 of file VampEffect.cpp.

106{
107 return wxString::Format(wxT("%d"), mPlugin->getPluginVersion());
108}

References mPlugin, and wxT().

Here is the call graph for this function:

◆ Init()

bool VampEffect::Init ( )
overridevirtual

Call once to set up state for whole list of tracks to be processed.

Returns
success Default implementation does nothing, returns true Default implementation does nothing, returns true

Reimplemented from StatefulEffectBase.

Definition at line 298 of file VampEffect.cpp.

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

References TrackList::Channels(), anonymous_namespace{TimeTrack.cpp}::GetRate(), EffectBase::inputTracks(), Effect::MessageBox(), 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.

Reimplemented from Effect.

Definition at line 135 of file VampEffect.cpp.

136{
137 return false;
138}

◆ IsInteractive()

bool VampEffect::IsInteractive ( ) const
overridevirtual

Whether the effect needs a dialog for entry of settings.

Reimplemented from Effect.

Definition at line 130 of file VampEffect.cpp.

131{
132 return mHasParameters;
133}

References mHasParameters.

◆ LoadSettings()

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

Restore settings from keys and values.

Returns
true on success

Reimplemented from Effect.

Definition at line 192 of file VampEffect.cpp.

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

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 789 of file VampEffect.cpp.

790{
791 int p = event.GetId() - ID_Toggles;
792
793 mPlugin->setParameter(mParameters[p].identifier, mToggles[p]->GetValue());
794}
@ ID_Toggles
Definition: VampEffect.cpp:52
ArrayOf< wxCheckBox * > mToggles
Definition: VampEffect.h:110

References ID_Toggles, mParameters, mPlugin, and mToggles.

◆ OnChoice()

void VampEffect::OnChoice ( wxCommandEvent &  evt)
private

Definition at line 796 of file VampEffect.cpp.

797{
798 int p = evt.GetId();
799
800 // special value for programs
801 if (p == ID_Program)
802 {
803 Vamp::Plugin::ProgramList programs = mPlugin->getPrograms();
804 mPlugin->selectProgram(programs[evt.GetInt()]);
806 return;
807 }
808
809 mPlugin->setParameter(mParameters[p - ID_Choices].identifier, evt.GetInt());
810}
@ ID_Choices
Definition: VampEffect.cpp:50
@ ID_Program
Definition: VampEffect.cpp:48
void UpdateFromPlugin()
Definition: VampEffect.cpp:746

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 812 of file VampEffect.cpp.

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

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

◆ OnTextCtrl()

void VampEffect::OnTextCtrl ( wxCommandEvent &  evt)
private

Definition at line 839 of file VampEffect.cpp.

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

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

◆ PopulateOrExchange()

std::unique_ptr< EffectUIValidator > 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 Effect::PopulateUI instead of a DefaultEffectUIValidator; default implementation returns null

Reimplemented from Effect.

Definition at line 529 of file VampEffect.cpp.

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

References ID_Choices, ID_Program, ID_Sliders, ID_Texts, ID_Toggles, mChoices, mFields, mLabels, mParameters, mPlugin, mProgram, mSliders, mToggles, 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

Actually do the effect here.

Returns
success

!! todo: retain parameters previously set

Implements StatefulEffectBase.

Definition at line 343 of file VampEffect.cpp.

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

References _, Effect::AddAnalysisTrack(), AddFeatures(), TrackList::Channels(), Effect::GetBounds(), SampleTrack::GetFloats(), Effect::GetNumWaveGroups(), GetSymbol(), Init(), EffectBase::inputTracks(), limitSampleBufferSize(), Effect::MessageBox(), 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

Reimplemented from Effect.

Definition at line 145 of file VampEffect.cpp.

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

Reimplemented from Effect.

Definition at line 704 of file VampEffect.cpp.

705{
706 if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
707 {
708 return false;
709 }
710
711 return true;
712}
wxWindow * mUIParent
Definition: Effect.h:307

References Effect::mUIParent.

◆ TransferDataToWindow()

bool VampEffect::TransferDataToWindow ( const EffectSettings settings)
overridevirtual

Update controls for the settings.

Reimplemented from Effect.

Definition at line 692 of file VampEffect.cpp.

693{
694 if (!mUIParent->TransferDataToWindow())
695 {
696 return false;
697 }
698
700
701 return true;
702}

References Effect::mUIParent, and UpdateFromPlugin().

Here is the call graph for this function:

◆ UpdateFromPlugin()

void VampEffect::UpdateFromPlugin ( )
private

Definition at line 746 of file VampEffect.cpp.

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

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 111 of file VampEffect.h.

Referenced by PopulateOrExchange(), and UpdateFromPlugin().

◆ mFields

ArrayOf<wxTextCtrl *> VampEffect::mFields
private

Definition at line 108 of file VampEffect.h.

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

◆ mHasParameters

bool VampEffect::mHasParameters
private

Definition at line 94 of file VampEffect.h.

Referenced by IsInteractive().

◆ mInSlider

bool VampEffect::mInSlider
private

Definition at line 100 of file VampEffect.h.

◆ mInText

bool VampEffect::mInText
private

Definition at line 101 of file VampEffect.h.

◆ mKey

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

Definition at line 96 of file VampEffect.h.

Referenced by Init().

◆ mLabels

ArrayOf<wxStaticText *> VampEffect::mLabels
private

Definition at line 109 of file VampEffect.h.

Referenced by PopulateOrExchange().

◆ mName

wxString VampEffect::mName
private

Definition at line 97 of file VampEffect.h.

Referenced by GetSymbol().

◆ mOutput

int VampEffect::mOutput
private

Definition at line 93 of file VampEffect.h.

Referenced by AddFeatures().

◆ mParameters

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

◆ mPath

PluginPath VampEffect::mPath
private

Definition at line 92 of file VampEffect.h.

Referenced by GetPath().

◆ mPlugin

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

◆ mProgram

wxChoice* VampEffect::mProgram
private

Definition at line 112 of file VampEffect.h.

Referenced by PopulateOrExchange().

◆ mRate

double VampEffect::mRate
private

Definition at line 98 of file VampEffect.h.

Referenced by Init(), and Process().

◆ mSliders

ArrayOf<wxSlider *> VampEffect::mSliders
private

Definition at line 107 of file VampEffect.h.

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

◆ mToggles

ArrayOf<wxCheckBox *> VampEffect::mToggles
private

Definition at line 110 of file VampEffect.h.

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

◆ mValues

Floats VampEffect::mValues
private

Definition at line 105 of file VampEffect.h.

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


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