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

#include <VSTEffect.h>

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

Public Member Functions

 VSTEffectValidator (VSTEffectInstance &instance, EffectUIClientInterface &effect, EffectSettingsAccess &access, wxWindow *pParent, int numParams)
 
 ~VSTEffectValidator () override
 
VSTEffectInstanceGetInstance () const
 
bool ValidateUI () override
 Get settings data from the panel; may make error dialogs and return false. More...
 
bool UpdateUI () override
 Update appearance of the panel for changes in settings. More...
 
void OnClose () override
 
void BuildPlain (EffectSettingsAccess &access, EffectType effectType, double projectRate)
 
void BuildFancy (EffectInstance &instance)
 
void OnTimer ()
 
void RefreshParameters (int skip=-1) const
 
void Automate (int index, float value) override
 
void OnSlider (wxCommandEvent &evt)
 
int ShowDialog (bool nonModal)
 
bool IsGraphicalUI () override
 
void Flush () override
 
- Public Member Functions inherited from EffectUIValidator
 EffectUIValidator (EffectUIClientInterface &effect, EffectSettingsAccess &access)
 
virtual ~EffectUIValidator ()
 
virtual bool ValidateUI ()=0
 Get settings data from the panel; may make error dialogs and return false. More...
 
virtual bool UpdateUI ()
 Update appearance of the panel for changes in settings. More...
 
virtual bool IsGraphicalUI ()
 
virtual void Disconnect ()
 On the first call only, may disconnect from further event handling. More...
 
virtual void OnClose ()
 
- Public Member Functions inherited from Observer::Publisher< EffectSettingChanged >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 
virtual void NeedIdle ()
 
virtual void SizeWindow (int w, int h)
 
virtual void Automate (int index, float value)
 
virtual void Flush ()
 

Public Attributes

std::unique_ptr< VSTEffectTimermTimer
 

Protected Member Functions

void SizeWindow (int w, int h) override
 
- Protected Member Functions inherited from EffectUIValidator
template<typename EventTag , typename Class , typename Event >
void BindTo (wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
 
- Protected Member Functions inherited from Observer::Publisher< EffectSettingChanged >
CallbackReturn Publish (const EffectSettingChanged &message)
 Send a message to connected callbacks. More...
 

Private Member Functions

void NotifyParameterChanged (int index, float value)
 
void OnIdle (wxIdleEvent &evt)
 
bool FetchSettingsFromInstance (EffectSettings &settings)
 
bool StoreSettingsToInstance (const EffectSettings &settings)
 
void NeedEditIdle (bool state)
 
void NeedIdle () override
 
void OnSizeWindow (wxCommandEvent &evt)
 

Private Attributes

VSTEffectInstancemInstance
 
int mTimerGuard { 0 }
 
bool mWantsEditIdle { false }
 
bool mWantsIdle { false }
 
std::vector< std::pair< int, double > > mLastMovements {}
 
ArrayOf< wxStaticText * > mNames
 
ArrayOf< wxSlider * > mSliders
 
ArrayOf< wxStaticText * > mDisplays
 
ArrayOf< wxStaticText * > mLabels
 
NumericTextCtrlmDuration
 
wxWindow * mParent
 
wxWeakRef< wxDialog > mDialog
 
VSTControlmControl {}
 
std::vector< wxString > mParamNames
 
int mNumParams { 0 }
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< EffectSettingChanged >
using message_type = EffectSettingChanged
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const EffectSettingChanged &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Member Functions inherited from EffectUIValidator
static bool EnableApply (wxWindow *parent, bool enable=true)
 Enable or disable the Apply button of the dialog that contains parent. More...
 
static bool EnablePreview (wxWindow *parent, bool enable=true)
 
- Static Public Attributes inherited from EffectUIValidator
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Attributes inherited from EffectUIValidator
EffectUIClientInterfacemEffect
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 592 of file VSTEffect.h.

Constructor & Destructor Documentation

◆ VSTEffectValidator()

VSTEffectValidator::VSTEffectValidator ( VSTEffectInstance instance,
EffectUIClientInterface effect,
EffectSettingsAccess access,
wxWindow *  pParent,
int  numParams 
)

Note the parameter names for later use

Definition at line 3923 of file VSTEffect.cpp.

3931 : EffectUIValidator(effect, access),
3932 mInstance(instance),
3933 mParent(pParent),
3934 mDialog( static_cast<wxDialog*>(wxGetTopLevelParent(pParent)) ),
3935 mNumParams(numParams)
3936{
3937 // In case of nondestructive processing, put an initial message in the
3938 // queue for the instance
3941 });
3942
3943 auto settings = mAccess.Get();
3945
3948 mParamNames.push_back(pi.mName);
3949 return true;
3950 } );
3951
3952 mTimer = std::make_unique<VSTEffectTimer>(this);
3953
3954 wxTheApp->Bind(wxEVT_IDLE, &VSTEffectValidator::OnIdle, this);
3955}
static Settings & settings()
Definition: TrackInfo.cpp:87
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
EffectSettingsAccess & mAccess
Definition: EffectPlugin.h:297
EffectUIValidator(EffectUIClientInterface &effect, EffectSettingsAccess &access)
VSTEffectInstance & mInstance
Definition: VSTEffect.h:641
std::vector< wxString > mParamNames
Definition: VSTEffect.h:670
wxWindow * mParent
Definition: VSTEffect.h:664
std::unique_ptr< VSTEffectTimer > mTimer
Definition: VSTEffect.h:620
void OnIdle(wxIdleEvent &evt)
Definition: VSTEffect.cpp:2344
VSTEffectInstance & GetInstance() const
Definition: VSTEffect.cpp:3958
wxWeakRef< wxDialog > mDialog
Definition: VSTEffect.h:665
bool StoreSettingsToInstance(const EffectSettings &settings)
Definition: VSTEffect.cpp:4057
Externalized state of a plug-in.
std::unique_ptr< EffectInstance::Message > MakeMessageFS(const VSTEffectSettings &settings) const
Definition: VSTEffect.cpp:3901
void ForEachParameter(ParameterVisitor visitor) const
Definition: VSTEffect.cpp:3747
static VSTEffectSettings & GetSettings(EffectSettings &settings)
Definition: VSTEffect.h:116

References VSTEffectWrapper::ForEachParameter(), EffectSettingsAccess::Get(), GetInstance(), VSTEffectWrapper::GetSettings(), EffectUIValidator::mAccess, VSTEffectWrapper::MakeMessageFS(), mInstance, VSTEffectWrapper::ParameterInfo::mName, EffectSettingsAccess::ModifySettings(), mParamNames, mTimer, OnIdle(), settings(), and StoreSettingsToInstance().

Here is the call graph for this function:

◆ ~VSTEffectValidator()

VSTEffectValidator::~VSTEffectValidator ( )
override

Definition at line 3893 of file VSTEffect.cpp.

3894{
3895 // Just for extra safety
3897}
void SetOwningValidator(VSTEffectUIWrapper *vi)
Definition: VSTEffect.cpp:4043

References GetInstance(), and VSTEffectInstance::SetOwningValidator().

Here is the call graph for this function:

Member Function Documentation

◆ Automate()

void VSTEffectValidator::Automate ( int  index,
float  value 
)
overridevirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 3986 of file VSTEffect.cpp.

3987{
3988 NotifyParameterChanged(index, value);
3989 // Send changed settings (only) to the worker thread
3990 mAccess.Set(GetInstance().MakeMessage(index, value));
3991 mLastMovements.emplace_back(index, value);
3992}
virtual void Set(EffectSettings &&settings, std::unique_ptr< Message > pMessage=nullptr)=0
void NotifyParameterChanged(int index, float value)
Definition: VSTEffect.cpp:2320
std::vector< std::pair< int, double > > mLastMovements
Definition: VSTEffect.h:656

References GetInstance(), EffectUIValidator::mAccess, mLastMovements, NotifyParameterChanged(), and EffectSettingsAccess::Set().

Here is the call graph for this function:

◆ BuildFancy()

void VSTEffectValidator::BuildFancy ( EffectInstance instance)

Definition at line 2555 of file VSTEffect.cpp.

2556{
2557 auto& vstEffInstance = dynamic_cast<VSTEffectInstance&>(instance);
2558
2559 // Turn the power on...some effects need this when the editor is open
2560 vstEffInstance.PowerOn();
2561
2562 auto control = Destroy_ptr<VSTControl>{ safenew VSTControl };
2563 if (!control)
2564 {
2565 return;
2566 }
2567
2568 if (!control->Create(mParent, &vstEffInstance))
2569 {
2570 return;
2571 }
2572
2573 {
2574 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
2575
2576 mainSizer->Add((mControl = control.release()), 0, wxALIGN_CENTER);
2577
2578 mParent->SetMinSize(wxDefaultSize);
2579 mParent->SetSizer(mainSizer.release());
2580 }
2581
2582 NeedEditIdle(true);
2583
2584 mDialog->Bind(wxEVT_SIZE, OnSize);
2585
2586
2588
2589#ifdef __WXMAC__
2590#ifdef __WX_EVTLOOP_BUSY_WAITING__
2591 wxEventLoop::SetBusyWaiting(true);
2592#endif
2593#endif
2594
2595 return;
2596}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:162
static void OnSize(wxSizeEvent &evt)
Definition: VSTEffect.cpp:2537
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectPlugin.h:290
VSTControl * mControl
Definition: VSTEffect.h:667
void NeedEditIdle(bool state)
Definition: VSTEffect.cpp:2248
void OnSizeWindow(wxCommandEvent &evt)
Definition: VSTEffect.cpp:2781

References EffectUIValidator::BindTo(), mControl, mDialog, mParent, NeedEditIdle(), OnSize(), OnSizeWindow(), VSTEffectInstance::PowerOn(), and safenew.

Here is the call graph for this function:

◆ BuildPlain()

void VSTEffectValidator::BuildPlain ( EffectSettingsAccess access,
EffectType  effectType,
double  projectRate 
)

Definition at line 2598 of file VSTEffect.cpp.

2599{
2600 wxASSERT(mParent); // To justify safenew
2601 wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent,
2602 wxID_ANY,
2603 wxDefaultPosition,
2604 wxDefaultSize,
2605 wxVSCROLL | wxTAB_TRAVERSAL);
2606
2607 {
2608 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
2609
2610 // Try to give the window a sensible default/minimum size
2611 scroller->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
2612 mParent->GetSize().GetHeight() / 2));
2613 scroller->SetScrollRate(0, 20);
2614
2615 // This fools NVDA into not saying "Panel" when the dialog gets focus
2616 scroller->SetName(wxT("\a"));
2617 scroller->SetLabel(wxT("\a"));
2618
2619 mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5);
2620 mParent->SetSizer(mainSizer.release());
2621 }
2622
2623 mNames.reinit(static_cast<size_t> (mNumParams));
2624 mSliders.reinit(static_cast<size_t> (mNumParams));
2625 mDisplays.reinit(static_cast<size_t>(mNumParams));
2626 mLabels.reinit(static_cast<size_t> (mNumParams));
2627
2628 {
2629 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, scroller, _("Effect Settings"));
2630
2631 {
2632 auto gridSizer = std::make_unique<wxFlexGridSizer>(4, 0, 0);
2633 gridSizer->AddGrowableCol(1);
2634
2635 // Add the duration control for generators
2636 if (effectType == EffectTypeGenerate)
2637 {
2638 wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:"));
2639 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2640 auto &extra = access.Get().extra;
2642 NumericTextCtrl(scroller, ID_Duration,
2644 extra.GetDurationFormat(),
2645 extra.GetDuration(),
2646 projectRate,
2648 .AutoPos(true));
2649 mDuration->SetName( XO("Duration") );
2650 gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
2651 gridSizer->Add(1, 1, 0);
2652 gridSizer->Add(1, 1, 0);
2653 }
2654
2655 // Find the longest parameter name.
2656 int namew = 0;
2657 int w;
2658 int h;
2659 for (int i = 0; i < mNumParams; i++)
2660 {
2661 wxString text = GetInstance().GetString(effGetParamName, i);
2662
2663 if (text.Right(1) != wxT(':'))
2664 {
2665 text += wxT(':');
2666 }
2667
2668 scroller->GetTextExtent(text, &w, &h);
2669 if (w > namew)
2670 {
2671 namew = w;
2672 }
2673 }
2674
2675 scroller->GetTextExtent(wxT("HHHHHHHH"), &w, &h);
2676
2677 for (int i = 0; i < mNumParams; i++)
2678 {
2679 mNames[i] = safenew wxStaticText(scroller,
2680 wxID_ANY,
2681 wxEmptyString,
2682 wxDefaultPosition,
2683 wxSize(namew, -1),
2684 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
2685 gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2686
2687 mSliders[i] = safenew wxSliderWrapper(scroller,
2688 ID_Sliders + i,
2689 0,
2690 0,
2691 1000,
2692 wxDefaultPosition,
2693 wxSize(200, -1));
2694 gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
2695#if wxUSE_ACCESSIBILITY
2696 // so that name can be set on a standard control
2697 mSliders[i]->SetAccessible(safenew WindowAccessible(mSliders[i]));
2698#endif
2699
2700 // Bind the slider to ::OnSlider
2701 BindTo(*mSliders[i], wxEVT_COMMAND_SLIDER_UPDATED, &VSTEffectValidator::OnSlider);
2702
2703 mDisplays[i] = safenew wxStaticText(scroller,
2704 wxID_ANY,
2705 wxEmptyString,
2706 wxDefaultPosition,
2707 wxSize(w, -1),
2708 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
2709 gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2710
2711 mLabels[i] = safenew wxStaticText(scroller,
2712 wxID_ANY,
2713 wxEmptyString,
2714 wxDefaultPosition,
2715 wxSize(w, -1),
2716 wxALIGN_LEFT | wxST_NO_AUTORESIZE);
2717 gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
2718 }
2719
2720 paramSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5);
2721 }
2722 scroller->SetSizer(paramSizer.release());
2723 }
2724
2726
2727 mSliders[0]->SetFocus();
2728}
wxT("CloseDown"))
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:75
@ ID_Duration
Definition: VSTEffect.cpp:594
@ ID_Sliders
Definition: VSTEffect.cpp:595
const int effGetParamName
Definition: aeffectx.h:101
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
void SetName(const TranslatableString &name)
ArrayOf< wxStaticText * > mNames
Definition: VSTEffect.h:658
NumericTextCtrl * mDuration
Definition: VSTEffect.h:662
void RefreshParameters(int skip=-1) const
Definition: VSTEffect.cpp:2730
ArrayOf< wxSlider * > mSliders
Definition: VSTEffect.h:659
ArrayOf< wxStaticText * > mLabels
Definition: VSTEffect.h:661
void OnSlider(wxCommandEvent &evt)
Definition: VSTEffect.cpp:2803
ArrayOf< wxStaticText * > mDisplays
Definition: VSTEffect.h:660
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
EffectSettingsExtra extra
Options & AutoPos(bool enable)
int GetString(wxString &outstr, int opcode, int index=0) const
Definition: VSTEffect.cpp:2416

References _, NumericTextCtrl::Options::AutoPos(), EffectUIValidator::BindTo(), EffectTypeGenerate, effGetParamName, EffectSettings::extra, EffectSettingsAccess::Get(), GetInstance(), VSTEffectWrapper::GetString(), ID_Duration, ID_Sliders, mDisplays, mDuration, mLabels, mNames, mNumParams, mParent, mSliders, OnSlider(), RefreshParameters(), ArrayOf< X >::reinit(), safenew, NumericTextCtrl::SetName(), NumericConverter::TIME, wxT(), and XO().

Here is the call graph for this function:

◆ FetchSettingsFromInstance()

bool VSTEffectValidator::FetchSettingsFromInstance ( EffectSettings settings)
private

Definition at line 4049 of file VSTEffect.cpp.

4050{
4051 return mInstance.FetchSettings(
4052 // Change this when GetSettings becomes a static function
4053 static_cast<const VSTEffect&>(mEffect).GetSettings(settings));
4054}
LV2EffectSettings & GetSettings(EffectSettings &settings)
Definition: LV2Ports.h:215
EffectUIClientInterface & mEffect
Definition: EffectPlugin.h:296
bool FetchSettings(VSTEffectSettings &vst3Settings, bool doFetch=true) const
Definition: VSTEffect.cpp:3774

References VSTEffectWrapper::FetchSettings(), GetSettings(), EffectUIValidator::mEffect, mInstance, and settings().

Referenced by ValidateUI().

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

◆ Flush()

void VSTEffectValidator::Flush ( )
overridevirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 2200 of file VSTEffect.cpp.

2201{
2202 mAccess.Flush();
2203}
virtual void Flush()=0
Make the last Set changes "persistent" in underlying storage.

References EffectSettingsAccess::Flush(), and EffectUIValidator::mAccess.

Here is the call graph for this function:

◆ GetInstance()

VSTEffectInstance & VSTEffectValidator::GetInstance ( ) const

Definition at line 3958 of file VSTEffect.cpp.

3959{
3960 return mInstance;
3961}

References mInstance.

Referenced by Automate(), BuildPlain(), NotifyParameterChanged(), OnClose(), OnIdle(), OnSlider(), OnTimer(), RefreshParameters(), ValidateUI(), VSTEffectValidator(), and ~VSTEffectValidator().

Here is the caller graph for this function:

◆ IsGraphicalUI()

bool VSTEffectValidator::IsGraphicalUI ( )
overridevirtual

Default implementation returns false

Returns
true if using a native plug-in UI, not widgets

Reimplemented from EffectUIValidator.

Definition at line 1447 of file VSTEffect.cpp.

1448{
1449 return mEffect.IsGraphicalUI();
1450}
virtual bool IsGraphicalUI()=0

References EffectUIClientInterface::IsGraphicalUI(), and EffectUIValidator::mEffect.

Here is the call graph for this function:

◆ NeedEditIdle()

void VSTEffectValidator::NeedEditIdle ( bool  state)
private

Definition at line 2248 of file VSTEffect.cpp.

2249{
2250 mWantsEditIdle = state;
2251 mTimer->Start(100);
2252}

References mTimer, and mWantsEditIdle.

Referenced by BuildFancy(), and OnClose().

Here is the caller graph for this function:

◆ NeedIdle()

void VSTEffectValidator::NeedIdle ( )
overrideprivatevirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 2242 of file VSTEffect.cpp.

2243{
2244 mWantsIdle = true;
2245 mTimer->Start(100);
2246}

References mTimer, and mWantsIdle.

◆ NotifyParameterChanged()

void VSTEffectValidator::NotifyParameterChanged ( int  index,
float  value 
)
private

Definition at line 2320 of file VSTEffect.cpp.

2321{
2323
2325 [index, value, &settings, this](const auto& pi)
2326 {
2327 if (pi.mID != index)
2328 return true;
2329
2330 auto it = settings.mParamsMap.find(pi.mName);
2331
2332 // For consistency with other plugin families
2333 constexpr float epsilon = 1.0e-5f;
2334
2335 if (
2336 it == settings.mParamsMap.end() || !it->second.has_value() ||
2337 std::abs(*it->second - value) > epsilon)
2338 Publish(EffectSettingChanged { size_t(index), value });
2339
2340 return false;
2341 });
2342}
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207
Message sent by validator when a setting is changed by a user.
Definition: EffectPlugin.h:225

References VSTEffectWrapper::ForEachParameter(), EffectSettingsAccess::Get(), GetInstance(), VSTEffectWrapper::GetSettings(), EffectUIValidator::mAccess, Observer::Publisher< EffectSettingChanged >::Publish(), and settings().

Referenced by Automate(), and OnSlider().

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

◆ OnClose()

void VSTEffectValidator::OnClose ( )
overridevirtual

Handle the UI OnClose event. Default implementation calls mEffect.CloseUI()

Reimplemented from EffectUIValidator.

Definition at line 4082 of file VSTEffect.cpp.

4083{
4084
4085#ifdef __WXMAC__
4086#ifdef __WX_EVTLOOP_BUSY_WAITING__
4087 wxEventLoop::SetBusyWaiting(false);
4088#endif
4089 if (mControl)
4090 mControl->Close();
4091#endif
4092
4093 // Tell the instance not to use me anymore - if we do not do this,
4094 // hiding the gui and then showing it again *while playing*, would leave
4095 // the instance with a dangling pointer to the old owning validator
4096 // for a fraction of time, thereby causing a crash.
4098
4099 NeedEditIdle(false);
4100
4101 mNames.reset();
4102 mSliders.reset();
4103 mDisplays.reset();
4104 mLabels.reset();
4105
4106 mParent = NULL;
4107 mDialog = NULL;
4108
4109 mAccess.Flush();
4110
4111 ValidateUI();
4112}
void Close()
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: VSTEffect.cpp:4065

References VSTControl::Close(), EffectSettingsAccess::Flush(), GetInstance(), EffectUIValidator::mAccess, mControl, mDialog, mDisplays, mLabels, mNames, mParent, mSliders, NeedEditIdle(), VSTEffectInstance::SetOwningValidator(), and ValidateUI().

Here is the call graph for this function:

◆ OnIdle()

void VSTEffectValidator::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 2344 of file VSTEffect.cpp.

2345{
2346 evt.Skip();
2347 if (!mLastMovements.empty()) {
2348 // Be sure the instance has got any messages
2349 mAccess.Flush();
2351 // Update settings, for stickiness
2352 // But don't do a complete FetchSettingsFromInstance
2353 for (auto [index, value] : mLastMovements) {
2354 if (index >= 0 && index < mParamNames.size()) {
2355 const auto &string = mParamNames[index];
2356 auto &mySettings = VSTEffectWrapper::GetSettings(settings);
2357 mySettings.mParamsMap[string] = value;
2358 }
2359 }
2360 // Succeed but with a null message
2361 return nullptr;
2362 });
2363 for (auto [index, _] : mLastMovements)
2364 RefreshParameters(index);
2365 mLastMovements.clear();
2366 }
2367
2369
2370 if ( GetInstance().OnePresetWasLoadedWhilePlaying() )
2371 {
2373 }
2374
2375}
void DeferChunkApplication()
Definition: VSTEffect.cpp:1251

References _, VSTEffectInstance::DeferChunkApplication(), EffectSettingsAccess::Flush(), GetInstance(), EffectUIValidator::mAccess, mLastMovements, EffectSettingsAccess::ModifySettings(), mParamNames, RefreshParameters(), and settings().

Referenced by VSTEffectValidator().

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

◆ OnSizeWindow()

void VSTEffectValidator::OnSizeWindow ( wxCommandEvent &  evt)
private

Definition at line 2781 of file VSTEffect.cpp.

2782{
2783 if (!mControl)
2784 {
2785 return;
2786 }
2787
2788 mControl->SetMinSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
2789 mControl->SetSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
2790
2791 // DO NOT CHANGE THE ORDER OF THESE
2792 //
2793 // Guitar Rig (and possibly others) Cocoa VSTs can resize too large
2794 // if the bounds are unlimited.
2795 mDialog->SetMinSize(wxDefaultSize);
2796 mDialog->SetMaxSize(wxDefaultSize);
2797 mDialog->Layout();
2798 mDialog->SetMinSize(mDialog->GetBestSize());
2799 mDialog->SetMaxSize(mDialog->GetBestSize());
2800 mDialog->Fit();
2801}

References mControl, and mDialog.

Referenced by BuildFancy().

Here is the caller graph for this function:

◆ OnSlider()

void VSTEffectValidator::OnSlider ( wxCommandEvent &  evt)

Definition at line 2803 of file VSTEffect.cpp.

2804{
2805 wxSlider *s = (wxSlider *) evt.GetEventObject();
2806 int i = s->GetId() - ID_Sliders;
2807 float value = s->GetValue() / 1000.0;
2808
2809 NotifyParameterChanged(i, value);
2810 // Send changed settings (only) to the worker thread
2811 mAccess.Set(GetInstance().MakeMessage(i, value));
2812 mLastMovements.emplace_back(i, value);
2813}

References GetInstance(), ID_Sliders, EffectUIValidator::mAccess, mLastMovements, NotifyParameterChanged(), and EffectSettingsAccess::Set().

Referenced by BuildPlain().

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

◆ OnTimer()

void VSTEffectValidator::OnTimer ( )

Definition at line 2205 of file VSTEffect.cpp.

2206{
2207 wxRecursionGuard guard(mTimerGuard);
2208
2209 // Ignore it if we're recursing
2210 if (guard.IsInside())
2211 {
2212 return;
2213 }
2214
2215 if (GetInstance().mVstVersion >= 2 && mWantsIdle)
2216 {
2217 int ret = GetInstance().callDispatcher(effIdle, 0, 0, NULL, 0.0);
2218 if (!ret)
2219 {
2220 mWantsIdle = false;
2221 }
2222 }
2223
2224 if (mWantsEditIdle)
2225 {
2226 GetInstance().callDispatcher(effEditIdle, 0, 0, NULL, 0.0);
2227 }
2228}
const int effEditIdle
Definition: aeffectx.h:108
const int effIdle
Definition: aeffectx.h:127
intptr_t callDispatcher(int opcode, int index, intptr_t value, void *ptr, float opt) override
Definition: VSTEffect.cpp:2447

References VSTEffectWrapper::callDispatcher(), effEditIdle, effIdle, GetInstance(), mTimerGuard, mWantsEditIdle, and mWantsIdle.

Referenced by VSTEffectTimer::Notify().

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

◆ RefreshParameters()

void VSTEffectValidator::RefreshParameters ( int  skip = -1) const

Definition at line 2730 of file VSTEffect.cpp.

2731{
2732 if (!mNames)
2733 {
2734 return;
2735 }
2736
2737 for (int i = 0; i < mNumParams; i++)
2738 {
2739 wxString text = GetInstance().GetString(effGetParamName, i);
2740
2741 text = text.Trim(true).Trim(false);
2742
2743 wxString name = text;
2744
2745 if (text.Right(1) != wxT(':'))
2746 {
2747 text += wxT(':');
2748 }
2749 mNames[i]->SetLabel(text);
2750
2751 // For some parameters types like on/off, setting the slider value has
2752 // a side effect that causes it to only move when the parameter changes
2753 // from off to on. However, this prevents changing the value using the
2754 // keyboard, so we skip the active slider if any.
2755 if (i != skip)
2756 {
2757 mSliders[i]->SetValue(GetInstance().callGetParameter(i) * 1000);
2758 }
2759 name = text;
2760
2762 if (text.empty())
2763 {
2764 text.Printf(wxT("%.5g"), GetInstance().callGetParameter(i));
2765 }
2766 mDisplays[i]->SetLabel(wxString::Format(wxT("%8s"), text));
2767 name += wxT(' ') + text;
2768
2770 if (!text.empty())
2771 {
2772 text.Printf(wxT("%-8s"), GetInstance().GetString(effGetParamLabel, i));
2773 mLabels[i]->SetLabel(wxString::Format(wxT("%8s"), text));
2774 name += wxT(' ') + text;
2775 }
2776
2777 mSliders[i]->SetName(name);
2778 }
2779}
const TranslatableString name
Definition: Distortion.cpp:74
const int effGetParamDisplay
Definition: aeffectx.h:100
const int effGetParamLabel
Definition: aeffectx.h:99

References effGetParamDisplay, effGetParamLabel, effGetParamName, GetInstance(), VSTEffectWrapper::GetString(), mDisplays, mLabels, mNames, mNumParams, mSliders, name, and wxT().

Referenced by BuildPlain(), OnIdle(), and UpdateUI().

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

◆ ShowDialog()

int VSTEffectValidator::ShowDialog ( bool  nonModal)

Definition at line 1434 of file VSTEffect.cpp.

1435{
1436 mDialog->CentreOnParent();
1437
1438 if (nonModal)
1439 {
1440 mDialog->Show();
1441 return 0;
1442 }
1443
1444 return mDialog->ShowModal();
1445}

References mDialog.

Referenced by VSTEffect::ShowClientInterface().

Here is the caller graph for this function:

◆ SizeWindow()

void VSTEffectValidator::SizeWindow ( int  w,
int  h 
)
overrideprotectedvirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 2377 of file VSTEffect.cpp.

2378{
2379 // Queue the event to make the resizes smoother
2380 if (mParent)
2381 {
2382 wxCommandEvent sw(EVT_SIZEWINDOW);
2383 sw.SetInt(w);
2384 sw.SetExtraLong(h);
2385 mParent->GetEventHandler()->AddPendingEvent(sw);
2386 }
2387
2388 return;
2389}

References mParent.

◆ StoreSettingsToInstance()

bool VSTEffectValidator::StoreSettingsToInstance ( const EffectSettings settings)
private

Definition at line 4057 of file VSTEffect.cpp.

4058{
4059 return mInstance.StoreSettings(
4060 // Change this when GetSettings becomes a static function
4061 static_cast<const VSTEffect&>(mEffect).GetSettings(settings));
4062}
bool StoreSettings(const VSTEffectSettings &vst3settings) const
Definition: VSTEffect.cpp:3824

References GetSettings(), EffectUIValidator::mEffect, mInstance, settings(), and VSTEffectWrapper::StoreSettings().

Referenced by VSTEffectValidator().

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

◆ UpdateUI()

bool VSTEffectValidator::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectUIValidator.

Definition at line 3873 of file VSTEffect.cpp.

3874{
3875 // Update the controls on the plain UI
3877
3878 return true;
3879}

References RefreshParameters().

Here is the call graph for this function:

◆ ValidateUI()

bool VSTEffectValidator::ValidateUI ( )
overridevirtual

Get settings data from the panel; may make error dialogs and return false.

Returns
true only if panel settings are acceptable

Implements EffectUIValidator.

Definition at line 4065 of file VSTEffect.cpp.

4066{
4068 {
4069 const auto& eff = static_cast<VSTEffect&>(VSTEffectValidator::mEffect);
4070 if (eff.GetType() == EffectTypeGenerate)
4071 settings.extra.SetDuration(mDuration->GetValue());
4072
4074
4075 return GetInstance().MakeMessage();
4076 });
4077
4078 return true;
4079}
std::unique_ptr< Message > MakeMessage() const override
Called on the main thread, in which the result may be cloned.
Definition: VSTEffect.cpp:1021
bool FetchSettingsFromInstance(EffectSettings &settings)
Definition: VSTEffect.cpp:4049

References EffectTypeGenerate, FetchSettingsFromInstance(), GetInstance(), NumericConverter::GetValue(), EffectUIValidator::mAccess, VSTEffectInstance::MakeMessage(), mDuration, EffectUIValidator::mEffect, EffectSettingsAccess::ModifySettings(), and settings().

Referenced by OnClose().

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

Member Data Documentation

◆ mControl

VSTControl* VSTEffectValidator::mControl {}
private

Definition at line 667 of file VSTEffect.h.

Referenced by BuildFancy(), OnClose(), and OnSizeWindow().

◆ mDialog

wxWeakRef<wxDialog> VSTEffectValidator::mDialog
private

Definition at line 665 of file VSTEffect.h.

Referenced by BuildFancy(), OnClose(), OnSizeWindow(), and ShowDialog().

◆ mDisplays

ArrayOf<wxStaticText*> VSTEffectValidator::mDisplays
private

Definition at line 660 of file VSTEffect.h.

Referenced by BuildPlain(), OnClose(), and RefreshParameters().

◆ mDuration

NumericTextCtrl* VSTEffectValidator::mDuration
private

Definition at line 662 of file VSTEffect.h.

Referenced by BuildPlain(), and ValidateUI().

◆ mInstance

VSTEffectInstance& VSTEffectValidator::mInstance
private

◆ mLabels

ArrayOf<wxStaticText*> VSTEffectValidator::mLabels
private

Definition at line 661 of file VSTEffect.h.

Referenced by BuildPlain(), OnClose(), and RefreshParameters().

◆ mLastMovements

std::vector<std::pair<int, double> > VSTEffectValidator::mLastMovements {}
private

Definition at line 656 of file VSTEffect.h.

Referenced by Automate(), OnIdle(), and OnSlider().

◆ mNames

ArrayOf<wxStaticText*> VSTEffectValidator::mNames
private

Definition at line 658 of file VSTEffect.h.

Referenced by BuildPlain(), OnClose(), and RefreshParameters().

◆ mNumParams

int VSTEffectValidator::mNumParams { 0 }
private

Definition at line 672 of file VSTEffect.h.

Referenced by BuildPlain(), and RefreshParameters().

◆ mParamNames

std::vector<wxString> VSTEffectValidator::mParamNames
private

Definition at line 670 of file VSTEffect.h.

Referenced by OnIdle(), and VSTEffectValidator().

◆ mParent

wxWindow* VSTEffectValidator::mParent
private

Definition at line 664 of file VSTEffect.h.

Referenced by BuildFancy(), BuildPlain(), OnClose(), and SizeWindow().

◆ mSliders

ArrayOf<wxSlider*> VSTEffectValidator::mSliders
private

Definition at line 659 of file VSTEffect.h.

Referenced by BuildPlain(), OnClose(), and RefreshParameters().

◆ mTimer

std::unique_ptr<VSTEffectTimer> VSTEffectValidator::mTimer

Definition at line 620 of file VSTEffect.h.

Referenced by NeedEditIdle(), NeedIdle(), and VSTEffectValidator().

◆ mTimerGuard

int VSTEffectValidator::mTimerGuard { 0 }
private

Definition at line 650 of file VSTEffect.h.

Referenced by OnTimer().

◆ mWantsEditIdle

bool VSTEffectValidator::mWantsEditIdle { false }
private

Definition at line 652 of file VSTEffect.h.

Referenced by NeedEditIdle(), and OnTimer().

◆ mWantsIdle

bool VSTEffectValidator::mWantsIdle { false }
private

Definition at line 653 of file VSTEffect.h.

Referenced by NeedIdle(), and OnTimer().


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