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

#include <VSTEffect.h>

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

Public Member Functions

 VSTEffectEditor (VSTEffectInstance &instance, bool gui, const EffectUIServices &services, EffectSettingsAccess &access, wxWindow *pParent, int numParams)
 
 ~VSTEffectEditor () 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 EffectEditor
 EffectEditor (const EffectUIServices &services, EffectSettingsAccess &access)
 
virtual ~EffectEditor ()
 
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 EffectEditor
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
 
const bool mGui
 
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 EffectEditor
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 EffectEditor
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Attributes inherited from EffectEditor
const EffectUIServicesmUIServices
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 600 of file VSTEffect.h.

Constructor & Destructor Documentation

◆ VSTEffectEditor()

VSTEffectEditor::VSTEffectEditor ( VSTEffectInstance instance,
bool  gui,
const EffectUIServices services,
EffectSettingsAccess access,
wxWindow *  pParent,
int  numParams 
)

Note the parameter names for later use

Definition at line 3932 of file VSTEffect.cpp.

3940 : EffectEditor(services, access),
3941 mInstance(instance),
3942 mGui{ gui },
3943 mParent(pParent),
3944 mDialog( static_cast<wxDialog*>(wxGetTopLevelParent(pParent)) ),
3945 mNumParams(numParams)
3946{
3947 // In case of nondestructive processing, put an initial message in the
3948 // queue for the instance
3951 });
3952
3953 auto settings = mAccess.Get();
3955
3958 mParamNames.push_back(pi.mName);
3959 return true;
3960 } );
3961
3962 mTimer = std::make_unique<VSTEffectTimer>(this);
3963
3964 wxTheApp->Bind(wxEVT_IDLE, &VSTEffectEditor::OnIdle, this);
3965}
static Settings & settings()
Definition: TrackInfo.cpp:87
EffectEditor(const EffectUIServices &services, EffectSettingsAccess &access)
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
std::vector< wxString > mParamNames
Definition: VSTEffect.h:679
wxWindow * mParent
Definition: VSTEffect.h:673
bool StoreSettingsToInstance(const EffectSettings &settings)
Definition: VSTEffect.cpp:4067
const bool mGui
Definition: VSTEffect.h:650
void OnIdle(wxIdleEvent &evt)
Definition: VSTEffect.cpp:2348
VSTEffectInstance & GetInstance() const
Definition: VSTEffect.cpp:3968
std::unique_ptr< VSTEffectTimer > mTimer
Definition: VSTEffect.h:628
VSTEffectInstance & mInstance
Definition: VSTEffect.h:649
wxWeakRef< wxDialog > mDialog
Definition: VSTEffect.h:674
Externalized state of a plug-in.
std::unique_ptr< EffectInstance::Message > MakeMessageFS(const VSTEffectSettings &settings) const
Definition: VSTEffect.cpp:3910
void ForEachParameter(ParameterVisitor visitor) const
Definition: VSTEffect.cpp:3756
static VSTEffectSettings & GetSettings(EffectSettings &settings)
Definition: VSTEffect.h:114

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

Here is the call graph for this function:

◆ ~VSTEffectEditor()

VSTEffectEditor::~VSTEffectEditor ( )
override

Definition at line 3902 of file VSTEffect.cpp.

3903{
3904 // Just for extra safety
3906}
void SetOwningValidator(VSTEffectUIWrapper *vi)
Definition: VSTEffect.cpp:4053

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

Here is the call graph for this function:

Member Function Documentation

◆ Automate()

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

Reimplemented from VSTEffectUIWrapper.

Definition at line 3996 of file VSTEffect.cpp.

3997{
3998 NotifyParameterChanged(index, value);
3999 // Send changed settings (only) to the worker thread
4000 mAccess.Set(GetInstance().MakeMessage(index, value));
4001 mLastMovements.emplace_back(index, value);
4002}
virtual void Set(EffectSettings &&settings, std::unique_ptr< Message > pMessage=nullptr)=0
void NotifyParameterChanged(int index, float value)
Definition: VSTEffect.cpp:2324
std::vector< std::pair< int, double > > mLastMovements
Definition: VSTEffect.h:665

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

Here is the call graph for this function:

◆ BuildFancy()

void VSTEffectEditor::BuildFancy ( EffectInstance instance)

Definition at line 2564 of file VSTEffect.cpp.

2565{
2566 auto& vstEffInstance = dynamic_cast<VSTEffectInstance&>(instance);
2567
2568 // Turn the power on...some effects need this when the editor is open
2569 vstEffInstance.PowerOn();
2570
2571 auto control = Destroy_ptr<VSTControl>{ safenew VSTControl };
2572 if (!control)
2573 {
2574 return;
2575 }
2576
2577 if (!control->Create(mParent, &vstEffInstance))
2578 {
2579 return;
2580 }
2581
2582 {
2583 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
2584
2585 mainSizer->Add((mControl = control.release()), 0, wxALIGN_CENTER);
2586
2587 mParent->SetMinSize(wxDefaultSize);
2588 mParent->SetSizer(mainSizer.release());
2589 }
2590
2591 NeedEditIdle(true);
2592
2593 mDialog->Bind(wxEVT_SIZE, OnSize);
2594
2595
2596 BindTo(*mDialog, EVT_SIZEWINDOW, &VSTEffectEditor::OnSizeWindow);
2597
2598#ifdef __WXMAC__
2599#ifdef __WX_EVTLOOP_BUSY_WAITING__
2600 wxEventLoop::SetBusyWaiting(true);
2601#endif
2602#endif
2603
2604 return;
2605}
#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:2546
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectEditor.h:85
VSTControl * mControl
Definition: VSTEffect.h:676
void OnSizeWindow(wxCommandEvent &evt)
Definition: VSTEffect.cpp:2790
void NeedEditIdle(bool state)
Definition: VSTEffect.cpp:2252

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

Here is the call graph for this function:

◆ BuildPlain()

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

Definition at line 2607 of file VSTEffect.cpp.

2608{
2609 wxASSERT(mParent); // To justify safenew
2610 wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent,
2611 wxID_ANY,
2612 wxDefaultPosition,
2613 wxDefaultSize,
2614 wxVSCROLL | wxTAB_TRAVERSAL);
2615
2616 {
2617 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
2618
2619 // Try to give the window a sensible default/minimum size
2620 scroller->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
2621 mParent->GetSize().GetHeight() / 2));
2622 scroller->SetScrollRate(0, 20);
2623
2624 // This fools NVDA into not saying "Panel" when the dialog gets focus
2625 scroller->SetName(wxT("\a"));
2626 scroller->SetLabel(wxT("\a"));
2627
2628 mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5);
2629 mParent->SetSizer(mainSizer.release());
2630 }
2631
2632 mNames.reinit(static_cast<size_t> (mNumParams));
2633 mSliders.reinit(static_cast<size_t> (mNumParams));
2634 mDisplays.reinit(static_cast<size_t>(mNumParams));
2635 mLabels.reinit(static_cast<size_t> (mNumParams));
2636
2637 {
2638 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, scroller, _("Effect Settings"));
2639
2640 {
2641 auto gridSizer = std::make_unique<wxFlexGridSizer>(4, 0, 0);
2642 gridSizer->AddGrowableCol(1);
2643
2644 // Add the duration control for generators
2645 if (effectType == EffectTypeGenerate)
2646 {
2647 wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:"));
2648 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2649 auto &extra = access.Get().extra;
2652 scroller, ID_Duration,
2654 extra.GetDurationFormat(),
2655 extra.GetDuration(),
2657 .AutoPos(true));
2658 mDuration->SetName( XO("Duration") );
2659 gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
2660 gridSizer->Add(1, 1, 0);
2661 gridSizer->Add(1, 1, 0);
2662 }
2663
2664 // Find the longest parameter name.
2665 int namew = 0;
2666 int w;
2667 int h;
2668 for (int i = 0; i < mNumParams; i++)
2669 {
2670 wxString text = GetInstance().GetString(effGetParamName, i);
2671
2672 if (text.Right(1) != wxT(':'))
2673 {
2674 text += wxT(':');
2675 }
2676
2677 scroller->GetTextExtent(text, &w, &h);
2678 if (w > namew)
2679 {
2680 namew = w;
2681 }
2682 }
2683
2684 scroller->GetTextExtent(wxT("HHHHHHHH"), &w, &h);
2685
2686 for (int i = 0; i < mNumParams; i++)
2687 {
2688 mNames[i] = safenew wxStaticText(scroller,
2689 wxID_ANY,
2690 wxEmptyString,
2691 wxDefaultPosition,
2692 wxSize(namew, -1),
2693 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
2694 gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2695
2696 mSliders[i] = safenew wxSliderWrapper(scroller,
2697 ID_Sliders + i,
2698 0,
2699 0,
2700 1000,
2701 wxDefaultPosition,
2702 wxSize(200, -1));
2703 gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
2704#if wxUSE_ACCESSIBILITY
2705 // so that name can be set on a standard control
2706 mSliders[i]->SetAccessible(safenew WindowAccessible(mSliders[i]));
2707#endif
2708
2709 // Bind the slider to ::OnSlider
2710 BindTo(*mSliders[i], wxEVT_COMMAND_SLIDER_UPDATED, &VSTEffectEditor::OnSlider);
2711
2712 mDisplays[i] = safenew wxStaticText(scroller,
2713 wxID_ANY,
2714 wxEmptyString,
2715 wxDefaultPosition,
2716 wxSize(w, -1),
2717 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
2718 gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
2719
2720 mLabels[i] = safenew wxStaticText(scroller,
2721 wxID_ANY,
2722 wxEmptyString,
2723 wxDefaultPosition,
2724 wxSize(w, -1),
2725 wxALIGN_LEFT | wxST_NO_AUTORESIZE);
2726 gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
2727 }
2728
2729 paramSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5);
2730 }
2731 scroller->SetSizer(paramSizer.release());
2732 }
2733
2735
2736 mSliders[0]->SetFocus();
2737}
wxT("CloseDown"))
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
const NumericConverterType NumericConverterType_TIME
@ 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
static FormatterContext SampleRateContext(double sampleRate)
void SetName(const TranslatableString &name)
ArrayOf< wxStaticText * > mLabels
Definition: VSTEffect.h:670
ArrayOf< wxSlider * > mSliders
Definition: VSTEffect.h:668
ArrayOf< wxStaticText * > mNames
Definition: VSTEffect.h:667
void OnSlider(wxCommandEvent &evt)
Definition: VSTEffect.cpp:2812
NumericTextCtrl * mDuration
Definition: VSTEffect.h:671
ArrayOf< wxStaticText * > mDisplays
Definition: VSTEffect.h:669
void RefreshParameters(int skip=-1) const
Definition: VSTEffect.cpp:2739
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:2425

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

Here is the call graph for this function:

◆ FetchSettingsFromInstance()

bool VSTEffectEditor::FetchSettingsFromInstance ( EffectSettings settings)
private

Definition at line 4059 of file VSTEffect.cpp.

4060{
4061 return mInstance.FetchSettings(
4062 // Change this when GetSettings becomes a static function
4063 static_cast<const VSTEffect&>(mUIServices).GetSettings(settings));
4064}
LV2EffectSettings & GetSettings(EffectSettings &settings)
Definition: LV2Ports.h:215
const EffectUIServices & mUIServices
Definition: EffectEditor.h:91
bool FetchSettings(VSTEffectSettings &vst3Settings, bool doFetch=true) const
Definition: VSTEffect.cpp:3783

References VSTEffectWrapper::FetchSettings(), GetSettings(), mInstance, EffectEditor::mUIServices, and settings().

Referenced by ValidateUI().

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

◆ Flush()

void VSTEffectEditor::Flush ( )
overridevirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 2204 of file VSTEffect.cpp.

2205{
2206 mAccess.Flush();
2207}
virtual void Flush()=0
Make the last Set changes "persistent" in underlying storage.

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

Here is the call graph for this function:

◆ GetInstance()

VSTEffectInstance & VSTEffectEditor::GetInstance ( ) const

Definition at line 3968 of file VSTEffect.cpp.

3969{
3970 return mInstance;
3971}

References mInstance.

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

Here is the caller graph for this function:

◆ IsGraphicalUI()

bool VSTEffectEditor::IsGraphicalUI ( )
overridevirtual

Default implementation returns false

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

Reimplemented from EffectEditor.

Definition at line 1450 of file VSTEffect.cpp.

1451{
1452 return mGui;
1453}

References mGui.

◆ NeedEditIdle()

void VSTEffectEditor::NeedEditIdle ( bool  state)
private

Definition at line 2252 of file VSTEffect.cpp.

2253{
2254 mWantsEditIdle = state;
2255 mTimer->Start(100);
2256}
bool mWantsEditIdle
Definition: VSTEffect.h:661

References mTimer, and mWantsEditIdle.

Referenced by BuildFancy(), and OnClose().

Here is the caller graph for this function:

◆ NeedIdle()

void VSTEffectEditor::NeedIdle ( )
overrideprivatevirtual

Reimplemented from VSTEffectUIWrapper.

Definition at line 2246 of file VSTEffect.cpp.

2247{
2248 mWantsIdle = true;
2249 mTimer->Start(100);
2250}

References mTimer, and mWantsIdle.

◆ NotifyParameterChanged()

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

Definition at line 2324 of file VSTEffect.cpp.

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

References VSTEffectWrapper::ForEachParameter(), EffectSettingsAccess::Get(), GetInstance(), VSTEffectWrapper::GetSettings(), EffectEditor::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 VSTEffectEditor::OnClose ( )
overridevirtual

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

Reimplemented from EffectEditor.

Definition at line 4093 of file VSTEffect.cpp.

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

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

Here is the call graph for this function:

◆ OnIdle()

void VSTEffectEditor::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 2348 of file VSTEffect.cpp.

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

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

Referenced by VSTEffectEditor().

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

◆ OnSizeWindow()

void VSTEffectEditor::OnSizeWindow ( wxCommandEvent &  evt)
private

Definition at line 2790 of file VSTEffect.cpp.

2791{
2792 if (!mControl)
2793 {
2794 return;
2795 }
2796
2797 mControl->SetMinSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
2798 mControl->SetSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
2799
2800 // DO NOT CHANGE THE ORDER OF THESE
2801 //
2802 // Guitar Rig (and possibly others) Cocoa VSTs can resize too large
2803 // if the bounds are unlimited.
2804 mDialog->SetMinSize(wxDefaultSize);
2805 mDialog->SetMaxSize(wxDefaultSize);
2806 mDialog->Layout();
2807 mDialog->SetMinSize(mDialog->GetBestSize());
2808 mDialog->SetMaxSize(mDialog->GetBestSize());
2809 mDialog->Fit();
2810}

References mControl, and mDialog.

Referenced by BuildFancy().

Here is the caller graph for this function:

◆ OnSlider()

void VSTEffectEditor::OnSlider ( wxCommandEvent &  evt)

Definition at line 2812 of file VSTEffect.cpp.

2813{
2814 wxSlider *s = (wxSlider *) evt.GetEventObject();
2815 int i = s->GetId() - ID_Sliders;
2816 float value = s->GetValue() / 1000.0;
2817
2818 NotifyParameterChanged(i, value);
2819 // Send changed settings (only) to the worker thread
2820 mAccess.Set(GetInstance().MakeMessage(i, value));
2821 mLastMovements.emplace_back(i, value);
2822}

References GetInstance(), ID_Sliders, EffectEditor::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 VSTEffectEditor::OnTimer ( )

Definition at line 2209 of file VSTEffect.cpp.

2210{
2211 wxRecursionGuard guard(mTimerGuard);
2212
2213 // Ignore it if we're recursing
2214 if (guard.IsInside())
2215 {
2216 return;
2217 }
2218
2219 if (GetInstance().mVstVersion >= 2 && mWantsIdle)
2220 {
2221 int ret = GetInstance().callDispatcher(effIdle, 0, 0, NULL, 0.0);
2222 if (!ret)
2223 {
2224 mWantsIdle = false;
2225 }
2226 }
2227
2228 if (mWantsEditIdle)
2229 {
2230 GetInstance().callDispatcher(effEditIdle, 0, 0, NULL, 0.0);
2231 }
2232}
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:2456

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 VSTEffectEditor::RefreshParameters ( int  skip = -1) const

Definition at line 2739 of file VSTEffect.cpp.

2740{
2741 if (!mNames)
2742 {
2743 return;
2744 }
2745
2746 for (int i = 0; i < mNumParams; i++)
2747 {
2748 wxString text = GetInstance().GetString(effGetParamName, i);
2749
2750 text = text.Trim(true).Trim(false);
2751
2752 wxString name = text;
2753
2754 if (text.Right(1) != wxT(':'))
2755 {
2756 text += wxT(':');
2757 }
2758 mNames[i]->SetLabel(text);
2759
2760 // For some parameters types like on/off, setting the slider value has
2761 // a side effect that causes it to only move when the parameter changes
2762 // from off to on. However, this prevents changing the value using the
2763 // keyboard, so we skip the active slider if any.
2764 if (i != skip)
2765 {
2766 mSliders[i]->SetValue(GetInstance().callGetParameter(i) * 1000);
2767 }
2768 name = text;
2769
2771 if (text.empty())
2772 {
2773 text.Printf(wxT("%.5g"), GetInstance().callGetParameter(i));
2774 }
2775 mDisplays[i]->SetLabel(wxString::Format(wxT("%8s"), text));
2776 name += wxT(' ') + text;
2777
2779 if (!text.empty())
2780 {
2781 text.Printf(wxT("%-8s"), GetInstance().GetString(effGetParamLabel, i));
2782 mLabels[i]->SetLabel(wxString::Format(wxT("%8s"), text));
2783 name += wxT(' ') + text;
2784 }
2785
2786 mSliders[i]->SetName(name);
2787 }
2788}
const TranslatableString name
Definition: Distortion.cpp:76
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 VSTEffectEditor::ShowDialog ( bool  nonModal)

Definition at line 1437 of file VSTEffect.cpp.

1438{
1439 mDialog->CentreOnParent();
1440
1441 if (nonModal)
1442 {
1443 mDialog->Show();
1444 return 0;
1445 }
1446
1447 return mDialog->ShowModal();
1448}

References mDialog.

Referenced by VSTEffect::ShowClientInterface().

Here is the caller graph for this function:

◆ SizeWindow()

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

Reimplemented from VSTEffectUIWrapper.

Definition at line 2381 of file VSTEffect.cpp.

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

References mParent.

◆ StoreSettingsToInstance()

bool VSTEffectEditor::StoreSettingsToInstance ( const EffectSettings settings)
private

Definition at line 4067 of file VSTEffect.cpp.

4068{
4069 return mInstance.StoreSettings(
4070 // Change this when GetSettings becomes a static function
4071 static_cast<const VSTEffect&>(mUIServices).GetSettings(settings));
4072}
bool StoreSettings(const VSTEffectSettings &vst3settings) const
Definition: VSTEffect.cpp:3833

References GetSettings(), mInstance, EffectEditor::mUIServices, settings(), and VSTEffectWrapper::StoreSettings().

Referenced by VSTEffectEditor().

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

◆ UpdateUI()

bool VSTEffectEditor::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectEditor.

Definition at line 3882 of file VSTEffect.cpp.

3883{
3884 // Update the controls on the plain UI
3886
3887 return true;
3888}

References RefreshParameters().

Here is the call graph for this function:

◆ ValidateUI()

bool VSTEffectEditor::ValidateUI ( )
overridevirtual

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

Returns
true only if panel settings are acceptable

Implements EffectEditor.

Definition at line 4075 of file VSTEffect.cpp.

4076{
4078 {
4079 const auto& eff =
4080 static_cast<const VSTEffect&>(VSTEffectEditor::mUIServices);
4081 if (eff.GetType() == EffectTypeGenerate)
4082 settings.extra.SetDuration(mDuration->GetValue());
4083
4085
4086 return GetInstance().MakeMessage();
4087 });
4088
4089 return true;
4090}
bool FetchSettingsFromInstance(EffectSettings &settings)
Definition: VSTEffect.cpp:4059
std::unique_ptr< Message > MakeMessage() const override
Called on the main thread, in which the result may be cloned.
Definition: VSTEffect.cpp:1021

References EffectTypeGenerate, FetchSettingsFromInstance(), GetInstance(), NumericConverter::GetValue(), EffectEditor::mAccess, VSTEffectInstance::MakeMessage(), mDuration, EffectSettingsAccess::ModifySettings(), EffectEditor::mUIServices, 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* VSTEffectEditor::mControl {}
private

Definition at line 676 of file VSTEffect.h.

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

◆ mDialog

wxWeakRef<wxDialog> VSTEffectEditor::mDialog
private

Definition at line 674 of file VSTEffect.h.

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

◆ mDisplays

ArrayOf<wxStaticText*> VSTEffectEditor::mDisplays
private

Definition at line 669 of file VSTEffect.h.

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

◆ mDuration

NumericTextCtrl* VSTEffectEditor::mDuration
private

Definition at line 671 of file VSTEffect.h.

Referenced by BuildPlain(), and ValidateUI().

◆ mGui

const bool VSTEffectEditor::mGui
private

Definition at line 650 of file VSTEffect.h.

Referenced by IsGraphicalUI().

◆ mInstance

VSTEffectInstance& VSTEffectEditor::mInstance
private

◆ mLabels

ArrayOf<wxStaticText*> VSTEffectEditor::mLabels
private

Definition at line 670 of file VSTEffect.h.

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

◆ mLastMovements

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

Definition at line 665 of file VSTEffect.h.

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

◆ mNames

ArrayOf<wxStaticText*> VSTEffectEditor::mNames
private

Definition at line 667 of file VSTEffect.h.

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

◆ mNumParams

int VSTEffectEditor::mNumParams { 0 }
private

Definition at line 681 of file VSTEffect.h.

Referenced by BuildPlain(), and RefreshParameters().

◆ mParamNames

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

Definition at line 679 of file VSTEffect.h.

Referenced by OnIdle(), and VSTEffectEditor().

◆ mParent

wxWindow* VSTEffectEditor::mParent
private

Definition at line 673 of file VSTEffect.h.

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

◆ mSliders

ArrayOf<wxSlider*> VSTEffectEditor::mSliders
private

Definition at line 668 of file VSTEffect.h.

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

◆ mTimer

std::unique_ptr<VSTEffectTimer> VSTEffectEditor::mTimer

Definition at line 628 of file VSTEffect.h.

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

◆ mTimerGuard

int VSTEffectEditor::mTimerGuard { 0 }
private

Definition at line 659 of file VSTEffect.h.

Referenced by OnTimer().

◆ mWantsEditIdle

bool VSTEffectEditor::mWantsEditIdle { false }
private

Definition at line 661 of file VSTEffect.h.

Referenced by NeedEditIdle(), and OnTimer().

◆ mWantsIdle

bool VSTEffectEditor::mWantsIdle { false }
private

Definition at line 662 of file VSTEffect.h.

Referenced by NeedIdle(), and OnTimer().


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