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

#include <VSTEditor.h>

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

Public Member Functions

 VSTEditor (VSTInstance &instance, EffectType type, bool gui, const EffectUIServices &services, EffectSettingsAccess &access, wxWindow *pParent, int numParams)
 
 ~VSTEditor () override
 
VSTInstanceGetInstance () 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 Idle ()
 
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< VSTTimermTimer
 

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 Idle () override
 
void OnSizeWindow (wxCommandEvent &evt)
 

Private Attributes

VSTInstancemInstance
 
const EffectType mType
 
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 31 of file VSTEditor.h.

Constructor & Destructor Documentation

◆ VSTEditor()

VSTEditor::VSTEditor ( VSTInstance instance,
EffectType  type,
bool  gui,
const EffectUIServices services,
EffectSettingsAccess access,
wxWindow *  pParent,
int  numParams 
)

Note the parameter names for later use

Definition at line 516 of file VSTEditor.cpp.

525 : EffectEditor(services, access),
526 mType{ type },
527 mInstance(instance),
528 mGui{ gui },
529 mParent(pParent),
530 mDialog( static_cast<wxDialog*>(wxGetTopLevelParent(pParent)) ),
531 mNumParams(numParams)
532{
533 // In case of nondestructive processing, put an initial message in the
534 // queue for the instance
537 });
538
539 auto settings = mAccess.Get();
541
544 mParamNames.push_back(pi.mName);
545 return true;
546 } );
547
548 mTimer = std::make_unique<VSTTimer>(this);
549
550 wxTheApp->Bind(wxEVT_IDLE, &VSTEditor::OnIdle, this);
551}
static Settings & settings()
Definition: TrackInfo.cpp:51
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
wxWindow * mParent
Definition: VSTEditor.h:106
std::unique_ptr< VSTTimer > mTimer
Definition: VSTEditor.h:59
std::vector< wxString > mParamNames
Definition: VSTEditor.h:112
bool StoreSettingsToInstance(const EffectSettings &settings)
Definition: VSTEditor.cpp:572
const bool mGui
Definition: VSTEditor.h:82
wxWeakRef< wxDialog > mDialog
Definition: VSTEditor.h:107
int mNumParams
Definition: VSTEditor.h:114
const EffectType mType
Definition: VSTEditor.h:81
void OnIdle(wxIdleEvent &evt)
Definition: VSTEditor.cpp:177
VSTInstance & GetInstance() const
Definition: VSTEditor.cpp:554
VSTInstance & mInstance
Definition: VSTEditor.h:80
Externalized state of a plug-in.
static VSTSettings & GetSettings(EffectSettings &settings)
Definition: VSTWrapper.h:103
void ForEachParameter(ParameterVisitor visitor) const
std::unique_ptr< EffectInstance::Message > MakeMessageFS(const VSTSettings &settings) const

References VSTWrapper::ForEachParameter(), EffectSettingsAccess::Get(), GetInstance(), VSTWrapper::GetSettings(), EffectEditor::mAccess, VSTWrapper::MakeMessageFS(), mInstance, EffectSettingsAccess::ModifySettings(), mParamNames, mTimer, OnIdle(), MIR::anonymous_namespace{MirUtils.cpp}::pi, settings(), and StoreSettingsToInstance().

Here is the call graph for this function:

◆ ~VSTEditor()

VSTEditor::~VSTEditor ( )
override

Definition at line 510 of file VSTEditor.cpp.

511{
512 // Just for extra safety
514}
void SetOwningValidator(VSTUIWrapper *vi)

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

Here is the call graph for this function:

Member Function Documentation

◆ Automate()

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

Reimplemented from VSTUIWrapper.

Definition at line 559 of file VSTEditor.cpp.

560{
561 NotifyParameterChanged(index, value);
562 // Send changed settings (only) to the worker thread
563 mAccess.Set(GetInstance().MakeMessage(index, value));
564 mLastMovements.emplace_back(index, value);
565}
virtual void Set(EffectSettings &&settings, std::unique_ptr< Message > pMessage=nullptr)=0
void NotifyParameterChanged(int index, float value)
Definition: VSTEditor.cpp:153
std::vector< std::pair< int, double > > mLastMovements
Definition: VSTEditor.h:98

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

Here is the call graph for this function:

◆ BuildFancy()

void VSTEditor::BuildFancy ( EffectInstance instance)

Definition at line 242 of file VSTEditor.cpp.

243{
244 auto& vstEffInstance = dynamic_cast<VSTInstance&>(instance);
245
246 // Turn the power on...some effects need this when the editor is open
247 vstEffInstance.PowerOn();
248
250 if (!control)
251 {
252 return;
253 }
254
255 if (!control->Create(mParent, &vstEffInstance))
256 {
257 return;
258 }
259
260 {
261 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
262
263 mainSizer->Add((mControl = control.release()), 0, wxALIGN_CENTER);
264
265 mParent->SetMinSize(wxDefaultSize);
266 mParent->SetSizer(mainSizer.release());
267 }
268
269 NeedEditIdle(true);
270
271 mDialog->Bind(wxEVT_SIZE, OnSize);
272
273
274 BindTo(*mDialog, EVT_SIZEWINDOW, &VSTEditor::OnSizeWindow);
275
276#ifdef __WXMAC__
277#ifdef __WX_EVTLOOP_BUSY_WAITING__
278 wxEventLoop::SetBusyWaiting(true);
279#endif
280#endif
281
282 return;
283}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:164
static void OnSize(wxSizeEvent &evt)
Definition: VSTEditor.cpp:224
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectEditor.h:85
VSTControl * mControl
Definition: VSTEditor.h:109
void OnSizeWindow(wxCommandEvent &evt)
Definition: VSTEditor.cpp:468
void NeedEditIdle(bool state)
Definition: VSTEditor.cpp:147
void PowerOn()

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

Here is the call graph for this function:

◆ BuildPlain()

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

Definition at line 285 of file VSTEditor.cpp.

286{
287 wxASSERT(mParent); // To justify safenew
288 wxScrolledWindow *const scroller = safenew wxScrolledWindow(mParent,
289 wxID_ANY,
290 wxDefaultPosition,
291 wxDefaultSize,
292 wxVSCROLL | wxTAB_TRAVERSAL);
293
294 {
295 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
296
297 // Try to give the window a sensible default/minimum size
298 scroller->SetMinSize(wxSize(wxMax(600, mParent->GetSize().GetWidth() * 2 / 3),
299 mParent->GetSize().GetHeight() / 2));
300 scroller->SetScrollRate(0, 20);
301
302 // This fools NVDA into not saying "Panel" when the dialog gets focus
303 scroller->SetName(wxT("\a"));
304 scroller->SetLabel(wxT("\a"));
305
306 mainSizer->Add(scroller, 1, wxEXPAND | wxALL, 5);
307 mParent->SetSizer(mainSizer.release());
308 }
309
310 mNames.reinit(static_cast<size_t> (mNumParams));
311 mSliders.reinit(static_cast<size_t> (mNumParams));
312 mDisplays.reinit(static_cast<size_t>(mNumParams));
313 mLabels.reinit(static_cast<size_t> (mNumParams));
314
315 {
316 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, scroller, _("Effect Settings"));
317
318 {
319 auto gridSizer = std::make_unique<wxFlexGridSizer>(4, 0, 0);
320 gridSizer->AddGrowableCol(1);
321
322 // Add the duration control for generators
323 if (effectType == EffectTypeGenerate)
324 {
325 wxControl *item = safenew wxStaticText(scroller, 0, _("Duration:"));
326 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
327 auto &extra = access.Get().extra;
330 scroller, ID_Duration,
332 extra.GetDurationFormat(),
333 extra.GetDuration(),
335 .AutoPos(true));
336 mDuration->SetName( XO("Duration") );
337 gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
338 gridSizer->Add(1, 1, 0);
339 gridSizer->Add(1, 1, 0);
340 }
341
342 // Find the longest parameter name.
343 int namew = 0;
344 int w;
345 int h;
346 for (int i = 0; i < mNumParams; i++)
347 {
348 wxString text = GetInstance().GetString(effGetParamName, i);
349
350 if (text.Right(1) != wxT(':'))
351 {
352 text += wxT(':');
353 }
354
355 scroller->GetTextExtent(text, &w, &h);
356 if (w > namew)
357 {
358 namew = w;
359 }
360 }
361
362 scroller->GetTextExtent(wxT("HHHHHHHH"), &w, &h);
363
364 for (int i = 0; i < mNumParams; i++)
365 {
366 mNames[i] = safenew wxStaticText(scroller,
367 wxID_ANY,
368 wxEmptyString,
369 wxDefaultPosition,
370 wxSize(namew, -1),
371 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
372 gridSizer->Add(mNames[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
373
374 mSliders[i] = safenew wxSliderWrapper(scroller,
375 ID_Sliders + i,
376 0,
377 0,
378 1000,
379 wxDefaultPosition,
380 wxSize(200, -1));
381 gridSizer->Add(mSliders[i], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
382#if wxUSE_ACCESSIBILITY
383 // so that name can be set on a standard control
384 mSliders[i]->SetAccessible(safenew WindowAccessible(mSliders[i]));
385#endif
386
387 // Bind the slider to ::OnSlider
388 BindTo(*mSliders[i], wxEVT_COMMAND_SLIDER_UPDATED, &VSTEditor::OnSlider);
389
390 mDisplays[i] = safenew wxStaticText(scroller,
391 wxID_ANY,
392 wxEmptyString,
393 wxDefaultPosition,
394 wxSize(w, -1),
395 wxALIGN_RIGHT | wxST_NO_AUTORESIZE);
396 gridSizer->Add(mDisplays[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
397
398 mLabels[i] = safenew wxStaticText(scroller,
399 wxID_ANY,
400 wxEmptyString,
401 wxDefaultPosition,
402 wxSize(w, -1),
403 wxALIGN_LEFT | wxST_NO_AUTORESIZE);
404 gridSizer->Add(mLabels[i], 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
405 }
406
407 paramSizer->Add(gridSizer.release(), 1, wxEXPAND | wxALL, 5);
408 }
409 scroller->SetSizer(paramSizer.release());
410 }
411
413
414 mSliders[0]->SetFocus();
415}
wxT("CloseDown"))
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define _(s)
Definition: Internat.h:73
const NumericConverterType & NumericConverterType_TIME()
@ ID_Duration
Definition: VSTEditor.cpp:81
@ ID_Sliders
Definition: VSTEditor.cpp:82
const int effGetParamName
Definition: aeffectx.h:101
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:59
static FormatterContext SampleRateContext(double sampleRate)
void SetName(const TranslatableString &name)
ArrayOf< wxStaticText * > mLabels
Definition: VSTEditor.h:103
void OnSlider(wxCommandEvent &evt)
Definition: VSTEditor.cpp:490
ArrayOf< wxStaticText * > mDisplays
Definition: VSTEditor.h:102
ArrayOf< wxStaticText * > mNames
Definition: VSTEditor.h:100
void RefreshParameters(int skip=-1) const
Definition: VSTEditor.cpp:417
NumericTextCtrl * mDuration
Definition: VSTEditor.h:104
ArrayOf< wxSlider * > mSliders
Definition: VSTEditor.h:101
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: VSTWrapper.cpp:651

References _, NumericTextCtrl::Options::AutoPos(), EffectEditor::BindTo(), EffectTypeGenerate, effGetParamName, EffectSettings::extra, EffectSettingsAccess::Get(), GetInstance(), VSTWrapper::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 VSTEditor::FetchSettingsFromInstance ( EffectSettings settings)
private

Definition at line 567 of file VSTEditor.cpp.

568{
570}
bool FetchSettings(VSTSettings &vst3Settings, bool doFetch=true) const

References VSTWrapper::FetchSettings(), VSTWrapper::GetSettings(), mInstance, and settings().

Referenced by ValidateUI().

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

◆ Flush()

void VSTEditor::Flush ( )
overridevirtual

Reimplemented from VSTUIWrapper.

Definition at line 106 of file VSTEditor.cpp.

107{
108 mAccess.Flush();
109}
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()

VSTInstance & VSTEditor::GetInstance ( ) const

Definition at line 554 of file VSTEditor.cpp.

555{
556 return mInstance;
557}

References mInstance.

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

Here is the caller graph for this function:

◆ Idle()

void VSTEditor::Idle ( )
overrideprivatevirtual

Reimplemented from VSTUIWrapper.

Definition at line 142 of file VSTEditor.cpp.

143{
144 wxYieldIfNeeded();
145}

◆ IsGraphicalUI()

bool VSTEditor::IsGraphicalUI ( )
overridevirtual

Default implementation returns false

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

Reimplemented from EffectEditor.

Definition at line 101 of file VSTEditor.cpp.

102{
103 return mGui;
104}

References mGui.

◆ NeedEditIdle()

void VSTEditor::NeedEditIdle ( bool  state)
private

Definition at line 147 of file VSTEditor.cpp.

148{
149 mWantsEditIdle = state;
150 mTimer->Start(100);
151}
bool mWantsEditIdle
Definition: VSTEditor.h:94

References mTimer, and mWantsEditIdle.

Referenced by BuildFancy(), and OnClose().

Here is the caller graph for this function:

◆ NeedIdle()

void VSTEditor::NeedIdle ( )
overrideprivatevirtual

Reimplemented from VSTUIWrapper.

Definition at line 136 of file VSTEditor.cpp.

137{
138 mWantsIdle = true;
139 mTimer->Start(100);
140}
bool mWantsIdle
Definition: VSTEditor.h:95

References mTimer, and mWantsIdle.

◆ NotifyParameterChanged()

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

Definition at line 153 of file VSTEditor.cpp.

154{
156
158 [index, value, &settings, this](const auto& pi)
159 {
160 if (pi.mID != index)
161 return true;
162
163 auto it = settings.mParamsMap.find(pi.mName);
164
165 // For consistency with other plugin families
166 constexpr float epsilon = 1.0e-5f;
167
168 if (
169 it == settings.mParamsMap.end() || !it->second.has_value() ||
170 std::abs(*it->second - value) > epsilon)
171 Publish(EffectSettingChanged { size_t(index), value });
172
173 return false;
174 });
175}
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 VSTWrapper::ForEachParameter(), EffectSettingsAccess::Get(), GetInstance(), VSTWrapper::GetSettings(), EffectEditor::mAccess, MIR::anonymous_namespace{MirUtils.cpp}::pi, 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 VSTEditor::OnClose ( )
overridevirtual

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

Reimplemented from EffectEditor.

Definition at line 592 of file VSTEditor.cpp.

593{
594
595#ifdef __WXMAC__
596#ifdef __WX_EVTLOOP_BUSY_WAITING__
597 wxEventLoop::SetBusyWaiting(false);
598#endif
599 if (mControl)
600 mControl->Close();
601#endif
602
603 // Tell the instance not to use me anymore - if we do not do this,
604 // hiding the gui and then showing it again *while playing*, would leave
605 // the instance with a dangling pointer to the old owning validator
606 // for a fraction of time, thereby causing a crash.
608
609 NeedEditIdle(false);
610
611 mNames.reset();
612 mSliders.reset();
613 mDisplays.reset();
614 mLabels.reset();
615
616 mParent = NULL;
617 mDialog = NULL;
618
619 mAccess.Flush();
620
621 ValidateUI();
622}
void Close()
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
Definition: VSTEditor.cpp:577

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

Here is the call graph for this function:

◆ OnIdle()

void VSTEditor::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 177 of file VSTEditor.cpp.

178{
179 evt.Skip();
180 if (!mLastMovements.empty()) {
181 // Be sure the instance has got any messages
182 mAccess.Flush();
184 // Update settings, for stickiness
185 // But don't do a complete FetchSettingsFromInstance
186 for (auto [index, value] : mLastMovements) {
187 if (index >= 0 && index < mParamNames.size()) {
188 const auto &string = mParamNames[index];
189 auto &mySettings = VSTWrapper::GetSettings(settings);
190 mySettings.mParamsMap[string] = value;
191 }
192 }
193 // Succeed but with a null message
194 return nullptr;
195 });
196 for (auto [index, _] : mLastMovements)
197 RefreshParameters(index);
198 mLastMovements.clear();
199 }
200
202
203 if ( GetInstance().OnePresetWasLoadedWhilePlaying() )
204 {
206 }
207
208}
void DeferChunkApplication()

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

Referenced by VSTEditor().

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

◆ OnSizeWindow()

void VSTEditor::OnSizeWindow ( wxCommandEvent &  evt)
private

Definition at line 468 of file VSTEditor.cpp.

469{
470 if (!mControl)
471 {
472 return;
473 }
474
475 mControl->SetMinSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
476 mControl->SetSize(wxSize(evt.GetInt(), (int) evt.GetExtraLong()));
477
478 // DO NOT CHANGE THE ORDER OF THESE
479 //
480 // Guitar Rig (and possibly others) Cocoa VSTs can resize too large
481 // if the bounds are unlimited.
482 mDialog->SetMinSize(wxDefaultSize);
483 mDialog->SetMaxSize(wxDefaultSize);
484 mDialog->Layout();
485 mDialog->SetMinSize(mDialog->GetBestSize());
486 mDialog->SetMaxSize(mDialog->GetBestSize());
487 mDialog->Fit();
488}

References mControl, and mDialog.

Referenced by BuildFancy().

Here is the caller graph for this function:

◆ OnSlider()

void VSTEditor::OnSlider ( wxCommandEvent &  evt)

Definition at line 490 of file VSTEditor.cpp.

491{
492 wxSlider *s = (wxSlider *) evt.GetEventObject();
493 int i = s->GetId() - ID_Sliders;
494 float value = s->GetValue() / 1000.0;
495
496 NotifyParameterChanged(i, value);
497 // Send changed settings (only) to the worker thread
498 mAccess.Set(GetInstance().MakeMessage(i, value));
499 mLastMovements.emplace_back(i, value);
500}

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 VSTEditor::OnTimer ( )

Definition at line 111 of file VSTEditor.cpp.

112{
113 wxRecursionGuard guard(mTimerGuard);
114
115 // Ignore it if we're recursing
116 if (guard.IsInside())
117 {
118 return;
119 }
120
121 if (GetInstance().mVstVersion >= 2 && mWantsIdle)
122 {
123 int ret = GetInstance().callDispatcher(effIdle, 0, 0, NULL, 0.0);
124 if (!ret)
125 {
126 mWantsIdle = false;
127 }
128 }
129
130 if (mWantsEditIdle)
131 {
132 GetInstance().callDispatcher(effEditIdle, 0, 0, NULL, 0.0);
133 }
134}
const int effEditIdle
Definition: aeffectx.h:108
const int effIdle
Definition: aeffectx.h:127
int mTimerGuard
Definition: VSTEditor.h:92
intptr_t callDispatcher(int opcode, int index, intptr_t value, void *ptr, float opt) override
Definition: VSTWrapper.cpp:682

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

Referenced by VSTTimer::Notify().

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

◆ RefreshParameters()

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

Definition at line 417 of file VSTEditor.cpp.

418{
419 if (!mNames)
420 {
421 return;
422 }
423
424 for (int i = 0; i < mNumParams; i++)
425 {
426 wxString text = GetInstance().GetString(effGetParamName, i);
427
428 text = text.Trim(true).Trim(false);
429
430 wxString name = text;
431
432 if (text.Right(1) != wxT(':'))
433 {
434 text += wxT(':');
435 }
436 mNames[i]->SetLabel(text);
437
438 // For some parameters types like on/off, setting the slider value has
439 // a side effect that causes it to only move when the parameter changes
440 // from off to on. However, this prevents changing the value using the
441 // keyboard, so we skip the active slider if any.
442 if (i != skip)
443 {
444 mSliders[i]->SetValue(GetInstance().callGetParameter(i) * 1000);
445 }
446 name = text;
447
449 if (text.empty())
450 {
451 text.Printf(wxT("%.5g"), GetInstance().callGetParameter(i));
452 }
453 mDisplays[i]->SetLabel(wxString::Format(wxT("%8s"), text));
454 name += wxT(' ') + text;
455
457 if (!text.empty())
458 {
459 text.Printf(wxT("%-8s"), GetInstance().GetString(effGetParamLabel, i));
460 mLabels[i]->SetLabel(wxString::Format(wxT("%8s"), text));
461 name += wxT(' ') + text;
462 }
463
464 mSliders[i]->SetName(name);
465 }
466}
wxString name
Definition: TagsEditor.cpp:166
const int effGetParamDisplay
Definition: aeffectx.h:100
const int effGetParamLabel
Definition: aeffectx.h:99

References effGetParamDisplay, effGetParamLabel, effGetParamName, GetInstance(), VSTWrapper::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 VSTEditor::ShowDialog ( bool  nonModal)

Definition at line 88 of file VSTEditor.cpp.

89{
90 mDialog->CentreOnParent();
91
92 if (nonModal)
93 {
94 mDialog->Show();
95 return 0;
96 }
97
98 return mDialog->ShowModal();
99}

References mDialog.

Referenced by VSTEffect::ShowClientInterface().

Here is the caller graph for this function:

◆ SizeWindow()

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

Reimplemented from VSTUIWrapper.

Definition at line 210 of file VSTEditor.cpp.

211{
212 // Queue the event to make the resizes smoother
213 if (mParent)
214 {
215 wxCommandEvent sw(EVT_SIZEWINDOW);
216 sw.SetInt(w);
217 sw.SetExtraLong(h);
218 mParent->GetEventHandler()->AddPendingEvent(sw);
219 }
220
221 return;
222}

References mParent.

◆ StoreSettingsToInstance()

bool VSTEditor::StoreSettingsToInstance ( const EffectSettings settings)
private

Definition at line 572 of file VSTEditor.cpp.

573{
575}
bool StoreSettings(const VSTSettings &vst3settings) const

References VSTWrapper::GetSettings(), mInstance, settings(), and VSTWrapper::StoreSettings().

Referenced by VSTEditor().

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

◆ UpdateUI()

bool VSTEditor::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 502 of file VSTEditor.cpp.

503{
504 // Update the controls on the plain UI
506
507 return true;
508}

References RefreshParameters().

Here is the call graph for this function:

◆ ValidateUI()

bool VSTEditor::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 577 of file VSTEditor.cpp.

578{
580 {
582 settings.extra.SetDuration(mDuration->GetValue());
583
585
586 return GetInstance().MakeMessage();
587 });
588
589 return true;
590}
bool FetchSettingsFromInstance(EffectSettings &settings)
Definition: VSTEditor.cpp:567
std::unique_ptr< Message > MakeMessage() const override
Called on the main thread, in which the result may be cloned.
Definition: VSTInstance.cpp:17

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

Definition at line 109 of file VSTEditor.h.

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

◆ mDialog

wxWeakRef<wxDialog> VSTEditor::mDialog
private

Definition at line 107 of file VSTEditor.h.

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

◆ mDisplays

ArrayOf<wxStaticText*> VSTEditor::mDisplays
private

Definition at line 102 of file VSTEditor.h.

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

◆ mDuration

NumericTextCtrl* VSTEditor::mDuration
private

Definition at line 104 of file VSTEditor.h.

Referenced by BuildPlain(), and ValidateUI().

◆ mGui

const bool VSTEditor::mGui
private

Definition at line 82 of file VSTEditor.h.

Referenced by IsGraphicalUI().

◆ mInstance

VSTInstance& VSTEditor::mInstance
private

◆ mLabels

ArrayOf<wxStaticText*> VSTEditor::mLabels
private

Definition at line 103 of file VSTEditor.h.

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

◆ mLastMovements

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

Definition at line 98 of file VSTEditor.h.

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

◆ mNames

ArrayOf<wxStaticText*> VSTEditor::mNames
private

Definition at line 100 of file VSTEditor.h.

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

◆ mNumParams

int VSTEditor::mNumParams { 0 }
private

Definition at line 114 of file VSTEditor.h.

Referenced by BuildPlain(), and RefreshParameters().

◆ mParamNames

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

Definition at line 112 of file VSTEditor.h.

Referenced by OnIdle(), and VSTEditor().

◆ mParent

wxWindow* VSTEditor::mParent
private

Definition at line 106 of file VSTEditor.h.

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

◆ mSliders

ArrayOf<wxSlider*> VSTEditor::mSliders
private

Definition at line 101 of file VSTEditor.h.

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

◆ mTimer

std::unique_ptr<VSTTimer> VSTEditor::mTimer

Definition at line 59 of file VSTEditor.h.

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

◆ mTimerGuard

int VSTEditor::mTimerGuard { 0 }
private

Definition at line 92 of file VSTEditor.h.

Referenced by OnTimer().

◆ mType

const EffectType VSTEditor::mType
private

Definition at line 81 of file VSTEditor.h.

Referenced by ValidateUI().

◆ mWantsEditIdle

bool VSTEditor::mWantsEditIdle { false }
private

Definition at line 94 of file VSTEditor.h.

Referenced by NeedEditIdle(), and OnTimer().

◆ mWantsIdle

bool VSTEditor::mWantsIdle { false }
private

Definition at line 95 of file VSTEditor.h.

Referenced by NeedIdle(), and OnTimer().


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