Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
LadspaEditor Struct Reference

#include <LadspaEditor.h>

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

Public Member Functions

 LadspaEditor (const EffectUIServices &effect, const LadspaInstance &instance, unsigned numInputControls, unsigned numOutputControls, EffectSettingsAccess &access, double sampleRate, EffectType type, const LadspaEffectOutputs *pOutputs)
 
bool UpdateUI () override
 Update appearance of the panel for changes in settings. More...
 
bool ValidateUI () override
 Get settings data from the panel; may make error dialogs and return false. More...
 
void Disconnect () override
 On the first call only, may disconnect from further event handling. More...
 
void PopulateUI (ShuttleGui &S)
 
void OnCheckBox (wxCommandEvent &evt)
 
void OnSlider (wxCommandEvent &evt)
 
void OnTextCtrl (wxCommandEvent &evt)
 
void RefreshControls ()
 
void UpdateControl (int index, float value, float epsilon)
 
void UpdateControls (const LadspaEffectSettings &src)
 
- 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...
 

Static Public Member Functions

static LadspaEffectSettingsGetSettings (EffectSettings &settings)
 Assume settings originated from MakeSettings() and copies thereof. More...
 
static const LadspaEffectSettingsGetSettings (const EffectSettings &settings)
 Assume settings originated from MakeSettings() and copies thereof. 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)
 

Public Attributes

const LadspaInstancemInstance
 
const unsigned mNumInputControls
 
const unsigned mNumOutputControls
 
const double mSampleRate
 
const EffectType mType
 
LadspaEffectSettings mSettings
 
const LadspaEffectOutputs *const mpOutputs
 
NumericTextCtrlmDuration {}
 
wxWeakRef< wxDialog > mDialog
 
wxWindow * mParent {}
 
ArrayOf< wxSlider * > mSliders
 
ArrayOf< wxTextCtrl * > mFields
 
ArrayOf< wxStaticText * > mLabels
 
ArrayOf< wxCheckBox * > mToggles
 
std::vector< LadspaEffectMeter * > mMeters
 

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 Attributes inherited from EffectEditor
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- 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...
 
- Protected Attributes inherited from EffectEditor
const EffectUIServicesmUIServices
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 28 of file LadspaEditor.h.

Constructor & Destructor Documentation

◆ LadspaEditor()

LadspaEditor::LadspaEditor ( const EffectUIServices effect,
const LadspaInstance instance,
unsigned  numInputControls,
unsigned  numOutputControls,
EffectSettingsAccess access,
double  sampleRate,
EffectType  type,
const LadspaEffectOutputs pOutputs 
)

Definition at line 428 of file LadspaEditor.cpp.

433 : EffectEditor{ effect, access }
434 , mInstance{ instance }
435 , mNumInputControls{ numInputControls }
436 , mNumOutputControls{ numOutputControls }
438 , mType{ type }
439 // Copy settings
440 , mSettings{ GetSettings(access.Get()) }
441 , mpOutputs{ pOutputs }
442{}
virtual const EffectSettings & Get()=0
const unsigned mNumInputControls
Definition: LadspaEditor.h:64
const EffectType mType
Definition: LadspaEditor.h:68
const double mSampleRate
Definition: LadspaEditor.h:67
static LadspaEffectSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: LadspaEditor.h:30
LadspaEffectSettings mSettings
Definition: LadspaEditor.h:69
const LadspaEffectOutputs *const mpOutputs
Definition: LadspaEditor.h:70
const unsigned mNumOutputControls
Definition: LadspaEditor.h:65
const LadspaInstance & mInstance
Definition: LadspaEditor.h:63

Member Function Documentation

◆ Disconnect()

void LadspaEditor::Disconnect ( )
overridevirtual

On the first call only, may disconnect from further event handling.

Default implemantation does nothing

Reimplemented from EffectEditor.

Definition at line 455 of file LadspaEditor.cpp.

456{
457 for (auto &meter : mMeters)
458 if (meter) {
459 meter->Disconnect();
460 meter = nullptr;
461 }
462}
std::vector< LadspaEffectMeter * > mMeters
Definition: LadspaEditor.h:79

References mMeters.

◆ GetSettings() [1/2]

static const LadspaEffectSettings & LadspaEditor::GetSettings ( const EffectSettings settings)
inlinestatic

Assume settings originated from MakeSettings() and copies thereof.

Definition at line 38 of file LadspaEditor.h.

39 {
40 return GetSettings(const_cast<EffectSettings &>(settings));
41 }
static Settings & settings()
Definition: TrackInfo.cpp:69
Externalized state of a plug-in.

References GetSettings(), and settings().

Here is the call graph for this function:

◆ GetSettings() [2/2]

static LadspaEffectSettings & LadspaEditor::GetSettings ( EffectSettings settings)
inlinestatic

Assume settings originated from MakeSettings() and copies thereof.

Definition at line 30 of file LadspaEditor.h.

31 {
32 auto pSettings = settings.cast<LadspaEffectSettings>();
33 assert(pSettings);
34 return *pSettings;
35 }

References settings().

Referenced by GetSettings(), RefreshControls(), and ValidateUI().

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

◆ OnCheckBox()

void LadspaEditor::OnCheckBox ( wxCommandEvent &  evt)

Definition at line 464 of file LadspaEditor.cpp.

465{
466 int p = evt.GetId() - ID_Toggles;
467 // 0.5 is a half of the interval
468 UpdateControl(p, mToggles[p]->GetValue(), 0.5f);
469 ValidateUI();
470}
@ ID_Toggles
ArrayOf< wxCheckBox * > mToggles
Definition: LadspaEditor.h:78
void UpdateControl(int index, float value, float epsilon)
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.

References ID_Toggles, mToggles, UpdateControl(), and ValidateUI().

Referenced by PopulateUI().

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

◆ OnSlider()

void LadspaEditor::OnSlider ( wxCommandEvent &  evt)

Definition at line 472 of file LadspaEditor.cpp.

473{
474 int p = evt.GetId() - ID_Sliders;
475
476 float val;
477 float lower = float(0.0);
478 float upper = float(10.0);
479 float range;
480 bool forceint = false;
481
484 lower = hint.LowerBound;
486 upper = hint.UpperBound;
488 lower *= mSampleRate;
489 upper *= mSampleRate;
490 forceint = true;
491 }
492
493 range = upper - lower;
494 val = (mSliders[p]->GetValue() / 1000.0) * range + lower;
495 wxString str;
496 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
497 str.Printf(wxT("%d"), (int)(val + 0.5));
498 else
500
501 mFields[p]->SetValue(str);
502
504 ValidateUI();
505}
wxT("CloseDown"))
#define str(a)
@ ID_Sliders
constexpr float ControlValueTolerance
static wxString ToDisplayString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, uses the user's locale's decimal separator.
Definition: Internat.cpp:137
#define LADSPA_IS_HINT_BOUNDED_BELOW(x)
Definition: ladspa.h:310
#define LADSPA_IS_HINT_BOUNDED_ABOVE(x)
Definition: ladspa.h:311
#define LADSPA_IS_HINT_INTEGER(x)
Definition: ladspa.h:315
#define LADSPA_IS_HINT_SAMPLE_RATE(x)
Definition: ladspa.h:313
const LADSPA_PortRangeHint * PortRangeHints
Definition: ladspa.h:419
_LADSPA_PortRangeHint is a structure that gives parameter validation information for a LADSPA (Linux ...
Definition: ladspa.h:337
LADSPA_PortRangeHintDescriptor HintDescriptor
Definition: ladspa.h:340
LADSPA_Data LowerBound
Definition: ladspa.h:345
LADSPA_Data UpperBound
Definition: ladspa.h:350
ArrayOf< wxSlider * > mSliders
Definition: LadspaEditor.h:75
ArrayOf< wxTextCtrl * > mFields
Definition: LadspaEditor.h:76
const LADSPA_Descriptor *const mData

References ControlValueTolerance, _LADSPA_PortRangeHint::HintDescriptor, ID_Sliders, LADSPA_IS_HINT_BOUNDED_ABOVE, LADSPA_IS_HINT_BOUNDED_BELOW, LADSPA_IS_HINT_INTEGER, LADSPA_IS_HINT_SAMPLE_RATE, _LADSPA_PortRangeHint::LowerBound, LadspaInstance::mData, mFields, mInstance, mSampleRate, mSliders, _LADSPA_Descriptor::PortRangeHints, str, Internat::ToDisplayString(), UpdateControl(), _LADSPA_PortRangeHint::UpperBound, ValidateUI(), and wxT().

Referenced by PopulateUI().

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

◆ OnTextCtrl()

void LadspaEditor::OnTextCtrl ( wxCommandEvent &  evt)

Definition at line 507 of file LadspaEditor.cpp.

508{
509 int p = evt.GetId() - ID_Texts;
510
511 float val;
512 float lower = float(0.0);
513 float upper = float(10.0);
514 float range;
515
516 val = Internat::CompatibleToDouble(mFields[p]->GetValue());
517
520 lower = hint.LowerBound;
522 upper = hint.UpperBound;
524 lower *= mSampleRate;
525 upper *= mSampleRate;
526 }
527 range = upper - lower;
528 if (val < lower)
529 val = lower;
530 if (val > upper)
531 val = upper;
532
533 mSliders[p]->SetValue((int)(((val-lower)/range) * 1000.0 + 0.5));
534
536 ValidateUI();
537}
@ ID_Texts
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:109

References Internat::CompatibleToDouble(), ControlValueTolerance, _LADSPA_PortRangeHint::HintDescriptor, ID_Texts, LADSPA_IS_HINT_BOUNDED_ABOVE, LADSPA_IS_HINT_BOUNDED_BELOW, LADSPA_IS_HINT_SAMPLE_RATE, _LADSPA_PortRangeHint::LowerBound, LadspaInstance::mData, mFields, mInstance, mSampleRate, mSliders, _LADSPA_Descriptor::PortRangeHints, UpdateControl(), _LADSPA_PortRangeHint::UpperBound, and ValidateUI().

Referenced by PopulateUI().

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

◆ PopulateUI()

void LadspaEditor::PopulateUI ( ShuttleGui S)

Definition at line 156 of file LadspaEditor.cpp.

157{
158 auto &controls = mSettings.controls;
159 auto parent = S.GetParent();
160
161 mParent = parent;
162
163 const auto &data = *mInstance.mData;
164 mToggles.reinit( data.PortCount );
165 mSliders.reinit( data.PortCount );
166 mFields.reinit( data.PortCount, true);
167 mLabels.reinit( data.PortCount );
168 mMeters.resize( data.PortCount );
169
170 wxASSERT(mParent); // To justify safenew
171 wxScrolledWindow *const w = safenew wxScrolledWindow(mParent,
172 wxID_ANY,
173 wxDefaultPosition,
174 wxDefaultSize,
175 wxVSCROLL | wxTAB_TRAVERSAL);
176
177 {
178 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
179 w->SetScrollRate(0, 20);
180
181 // This fools NVDA into not saying "Panel" when the dialog gets focus
182 w->SetName(wxT("\a"));
183 w->SetLabel(wxT("\a"));
184
185 mainSizer->Add(w, 1, wxEXPAND);
186 mParent->SetSizer(mainSizer.release());
187 }
188
189 wxSizer *marginSizer;
190 {
191 auto uMarginSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
192 marginSizer = uMarginSizer.get();
193
194 // Make user-adjustible input controls
195 if (mNumInputControls) {
196 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w, _("Effect Settings"));
197
198 auto gridSizer = std::make_unique<wxFlexGridSizer>(5, 0, 0);
199 gridSizer->AddGrowableCol(3);
200
201 wxControl *item;
202
203 // Add the duration control for generators
204 if (mType == EffectTypeGenerate) {
205 item = safenew wxStaticText(w, 0, _("Duration:"));
206 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
207 auto &extra = mAccess.Get().extra;
210 w, ID_Duration,
212 extra.GetDurationFormat(),
213 extra.GetDuration(),
215 .AutoPos(true));
216 mDuration->SetName( XO("Duration") );
217 gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
218 gridSizer->Add(1, 1, 0);
219 gridSizer->Add(1, 1, 0);
220 gridSizer->Add(1, 1, 0);
221 }
222
223 for (unsigned long p = 0; p < data.PortCount; ++p) {
224 LADSPA_PortDescriptor d = data.PortDescriptors[p];
226 {
227 continue;
228 }
229
230 wxString labelText = LAT1CTOWX(data.PortNames[p]);
231 item = safenew wxStaticText(w, 0, wxString::Format(_("%s:"), labelText));
232 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
233
234 wxString fieldText;
235 LADSPA_PortRangeHint hint = data.PortRangeHints[p];
236
238 mToggles[p] = safenew wxCheckBox(w, ID_Toggles + p, wxT(""));
239 mToggles[p]->SetName(labelText);
240 mToggles[p]->SetValue(controls[p] > 0);
241 BindTo(*mToggles[p],
242 wxEVT_COMMAND_CHECKBOX_CLICKED, &LadspaEditor::OnCheckBox);
243 gridSizer->Add(mToggles[p], 0, wxALL, 5);
244
245 gridSizer->Add(1, 1, 0);
246 gridSizer->Add(1, 1, 0);
247 gridSizer->Add(1, 1, 0);
248 continue;
249 }
250
251 wxString bound;
252 float lower = -FLT_MAX;
253 float upper = FLT_MAX;
254 bool haslo = false;
255 bool hashi = false;
256 bool forceint = false;
257
259 lower = hint.LowerBound;
260 haslo = true;
261 }
262
264 upper = hint.UpperBound;
265 hashi = true;
266 }
267
269 lower *= mSampleRate;
270 upper *= mSampleRate;
271 forceint = true;
272 }
273
274 // Limit to the UI precision
275 lower = ceilf(lower * 1000000.0) / 1000000.0;
276 upper = floorf(upper * 1000000.0) / 1000000.0;
277 controls[p] = roundf(controls[p] * 1000000.0) / 1000000.0;
278
279 if (haslo && controls[p] < lower)
280 controls[p] = lower;
281
282 if (hashi && controls[p] > upper)
283 controls[p] = upper;
284
285 // Don't specify a value at creation time. This prevents unwanted events
286 // being sent to the OnTextCtrl() handler before the associated slider
287 // has been created.
288 mFields[p] = safenew wxTextCtrl(w, ID_Texts + p);
289 mFields[p]->SetName(labelText);
290 BindTo(*mFields[p],
292 gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
293
294 wxString str;
295 if (haslo) {
296 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
297 {
298 str.Printf(wxT("%d"), (int)(lower + 0.5));
299 }
300 else
301 {
303 }
304 item = safenew wxStaticText(w, 0, str);
305 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
306 }
307 else
308 gridSizer->Add(1, 1, 0);
309
311 0, 0, 1000,
312 wxDefaultPosition,
313 wxSize(200, -1));
314#if wxUSE_ACCESSIBILITY
315 // so that name can be set on a standard control
316 mSliders[p]->SetAccessible(safenew WindowAccessible(mSliders[p]));
317#endif
318 mSliders[p]->SetName(labelText);
319 BindTo(*mSliders[p],
320 wxEVT_COMMAND_SLIDER_UPDATED, &LadspaEditor::OnSlider);
321 gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
322
323 if (hashi) {
324 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
325 str.Printf(wxT("%d"), (int)(upper + 0.5));
326 else
328 item = safenew wxStaticText(w, 0, str);
329 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
330 }
331 else
332 gridSizer->Add(1, 1, 0);
333
334 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) {
335 fieldText.Printf(wxT("%d"), (int)(controls[p] + 0.5));
336
337 IntegerValidator<float> vld(&controls[p]);
338 vld.SetRange(haslo ? lower : INT_MIN,
339 hashi ? upper : INT_MAX);
340 mFields[p]->SetValidator(vld);
341 }
342 else {
343 fieldText = Internat::ToDisplayString(controls[p]);
344
345 // > 12 decimal places can cause rounding errors in display.
346 FloatingPointValidator<float> vld(6, &controls[p]);
347 vld.SetRange(lower, upper);
348
349 // Set number of decimal places
350 if (upper - lower < 10.0)
351 vld.SetStyle(NumValidatorStyle::THREE_TRAILING_ZEROES);
352 else if (upper - lower < 100.0)
353 vld.SetStyle(NumValidatorStyle::TWO_TRAILING_ZEROES);
354 else
355 vld.SetStyle(NumValidatorStyle::ONE_TRAILING_ZERO);
356
357 mFields[p]->SetValidator(vld);
358 }
359
360 // Set the textctrl value. This will trigger an event so OnTextCtrl()
361 // can update the slider.
362 mFields[p]->SetValue(fieldText);
363 }
364
365 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
366 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
367 }
368
369 // Make output meters
370 if (mNumOutputControls > 0) {
371 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w, _("Effect Output"));
372
373 auto gridSizer = std::make_unique<wxFlexGridSizer>(2, 0, 0);
374 gridSizer->AddGrowableCol(1);
375
376 wxControl *item;
377
378 for (unsigned long p = 0; p < data.PortCount; ++p) {
379 LADSPA_PortDescriptor d = data.PortDescriptors[p];
381 continue;
382
383 wxString labelText = LAT1CTOWX(data.PortNames[p]);
384 item = safenew wxStaticText(
385 w, 0, wxString::Format(_("%s:"), labelText));
386 gridSizer->Add(
387 item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
388
389 //LADSPA_PortRangeHint hint = data.PortRangeHints[p];
390
391 wxString bound;
392 float lower = 0.0;
393 float upper = 1.0;
394
395 // Limit to the UI precision
396 lower = ceilf(lower * 1000000.0) / 1000000.0;
397 upper = floorf(upper * 1000000.0) / 1000000.0;
398 controls[p] = lower;
399
400 // Capture const reference to output control value for later
401 // display update
402 static float sink;
403 auto pOutput = mpOutputs ? &mpOutputs->controls[p] : &sink;
405 w, *pOutput, lower, upper);
406 mMeters[p]->SetLabel(labelText); // for screen readers
407 gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
408 }
409
410 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
411 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
412 }
413
414 w->SetSizer(uMarginSizer.release());
415 }
416
417 w->Layout();
418
419 // Try to give the window a sensible default/minimum size
420 wxSize sz1 = marginSizer->GetMinSize();
421 wxSize sz2 = mParent->GetMinSize();
422 w->SetMinSize( { std::min(sz1.x, sz2.x), std::min(sz1.y, sz2.y) } );
423
424 // And let the parent reduce to the NEW minimum if possible
425 mParent->SetMinSize({ -1, -1 });
426}
int min(int a, int b)
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define LAT1CTOWX(X)
Definition: Internat.h:158
#define _(s)
Definition: Internat.h:73
@ ID_Duration
#define safenew
Definition: MemoryX.h:9
const NumericConverterType & NumericConverterType_TIME()
wxEVT_COMMAND_TEXT_UPDATED
Definition: Nyquist.cpp:135
#define S(N)
Definition: ToChars.cpp:64
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:56
EffectSettingsAccess & mAccess
Definition: EffectEditor.h:92
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectEditor.h:85
static FormatterContext SampleRateContext(double sampleRate)
void SetName(const TranslatableString &name)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
#define LADSPA_IS_HINT_TOGGLED(x)
Definition: ladspa.h:312
int LADSPA_PortDescriptor
Definition: ladspa.h:152
#define LADSPA_IS_PORT_INPUT(x)
Definition: ladspa.h:168
#define LADSPA_IS_PORT_AUDIO(x)
Definition: ladspa.h:171
#define LADSPA_IS_PORT_OUTPUT(x)
Definition: ladspa.h:169
EffectSettingsExtra extra
wxWindow * mParent
Definition: LadspaEditor.h:74
NumericTextCtrl * mDuration
Definition: LadspaEditor.h:72
ArrayOf< wxStaticText * > mLabels
Definition: LadspaEditor.h:77
void OnCheckBox(wxCommandEvent &evt)
void OnSlider(wxCommandEvent &evt)
void OnTextCtrl(wxCommandEvent &evt)
std::vector< float > controls
std::vector< float > controls
Options & AutoPos(bool enable)

References _, NumericTextCtrl::Options::AutoPos(), EffectEditor::BindTo(), LadspaEffectSettings::controls, LadspaEffectOutputs::controls, EffectTypeGenerate, EffectSettings::extra, EffectSettingsAccess::Get(), _LADSPA_PortRangeHint::HintDescriptor, ID_Duration, ID_Sliders, ID_Texts, ID_Toggles, LADSPA_IS_HINT_BOUNDED_ABOVE, LADSPA_IS_HINT_BOUNDED_BELOW, LADSPA_IS_HINT_INTEGER, LADSPA_IS_HINT_SAMPLE_RATE, LADSPA_IS_HINT_TOGGLED, LADSPA_IS_PORT_AUDIO, LADSPA_IS_PORT_INPUT, LADSPA_IS_PORT_OUTPUT, LAT1CTOWX, _LADSPA_PortRangeHint::LowerBound, EffectEditor::mAccess, LadspaInstance::mData, mDuration, mFields, min(), mInstance, mLabels, mMeters, mNumInputControls, mNumOutputControls, mParent, mpOutputs, mSampleRate, mSettings, mSliders, mToggles, mType, NumericConverterType_TIME(), OnCheckBox(), OnSlider(), OnTextCtrl(), ArrayOf< X >::reinit(), S, safenew, FormatterContext::SampleRateContext(), NumericTextCtrl::SetName(), str, Internat::ToDisplayString(), _LADSPA_PortRangeHint::UpperBound, wxEVT_COMMAND_TEXT_UPDATED, wxT(), and XO().

Here is the call graph for this function:

◆ RefreshControls()

void LadspaEditor::RefreshControls ( )

Definition at line 539 of file LadspaEditor.cpp.

540{
541 if (!mParent)
542 return;
543
544 // Copy from the dialog
546
547 auto& controls = mSettings.controls;
548
549 const auto &data = *mInstance.mData;
550 for (unsigned long p = 0; p < data.PortCount; ++p) {
552 if (!(LADSPA_IS_PORT_CONTROL(d)))
553 continue;
554
555 wxString fieldText;
556 LADSPA_PortRangeHint hint = data.PortRangeHints[p];
557
558 bool forceint = false;
560 forceint = true;
561
563 continue;
564
566 mToggles[p]->SetValue(controls[p] > 0);
567 continue;
568 }
569
570 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
571 fieldText.Printf(wxT("%d"), (int)(controls[p] + 0.5));
572 else
573 fieldText = Internat::ToDisplayString(controls[p]);
574
575 // Set the textctrl value. This will trigger an event so OnTextCtrl()
576 // can update the slider.
577 mFields[p]->SetValue(fieldText);
578 }
579}
#define LADSPA_IS_PORT_CONTROL(x)
Definition: ladspa.h:170
const LADSPA_PortDescriptor * PortDescriptors
Definition: ladspa.h:410
void UpdateControls(const LadspaEffectSettings &src)

References LadspaEffectSettings::controls, EffectSettingsAccess::Get(), GetSettings(), _LADSPA_PortRangeHint::HintDescriptor, LADSPA_IS_HINT_INTEGER, LADSPA_IS_HINT_SAMPLE_RATE, LADSPA_IS_HINT_TOGGLED, LADSPA_IS_PORT_CONTROL, LADSPA_IS_PORT_OUTPUT, EffectEditor::mAccess, LadspaInstance::mData, mFields, mInstance, mParent, mSettings, mToggles, _LADSPA_Descriptor::PortDescriptors, Internat::ToDisplayString(), UpdateControls(), and wxT().

Referenced by UpdateUI().

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

◆ UpdateControl()

void LadspaEditor::UpdateControl ( int  index,
float  value,
float  epsilon 
)

Definition at line 581 of file LadspaEditor.cpp.

582{
583 auto& controls = mSettings.controls;
584
585 assert(index < static_cast<int>(controls.size()));
586
587 if (std::abs(controls[index] - value) < epsilon)
588 return;
589
590 controls[index] = value;
591 Publish({ size_t(index), value });
592}
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References LadspaEffectSettings::controls, mSettings, and Observer::Publisher< EffectSettingChanged >::Publish().

Referenced by OnCheckBox(), OnSlider(), OnTextCtrl(), and UpdateControls().

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

◆ UpdateControls()

void LadspaEditor::UpdateControls ( const LadspaEffectSettings src)

Definition at line 594 of file LadspaEditor.cpp.

595{
596 const auto& data = *mInstance.mData;
597
598 for (size_t portIndex = 0, portsCount = src.controls.size();
599 portIndex < portsCount;
600 ++portIndex)
601 {
602 LADSPA_PortDescriptor d = data.PortDescriptors[portIndex];
603
605 continue;
606
608
609 const bool isIntValue = (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) ||
612
614 portIndex, src.controls[portIndex],
615 isIntValue ? 0.5f : ControlValueTolerance);
616 }
617}

References LadspaEffectSettings::controls, ControlValueTolerance, _LADSPA_PortRangeHint::HintDescriptor, LADSPA_IS_HINT_INTEGER, LADSPA_IS_HINT_SAMPLE_RATE, LADSPA_IS_HINT_TOGGLED, LADSPA_IS_PORT_CONTROL, LADSPA_IS_PORT_OUTPUT, LadspaInstance::mData, mInstance, _LADSPA_Descriptor::PortDescriptors, _LADSPA_Descriptor::PortRangeHints, and UpdateControl().

Referenced by RefreshControls().

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

◆ UpdateUI()

bool LadspaEditor::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 150 of file LadspaEditor.cpp.

151{
153 return true;
154}
void RefreshControls()

References RefreshControls().

Here is the call graph for this function:

◆ ValidateUI()

bool LadspaEditor::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 444 of file LadspaEditor.cpp.

445{
448 settings.extra.SetDuration(mDuration->GetValue());
450 return nullptr;
451 });
452 return true;
453}
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.

References EffectTypeGenerate, GetSettings(), NumericConverter::GetValue(), EffectEditor::mAccess, mDuration, EffectSettingsAccess::ModifySettings(), mSettings, mType, and settings().

Referenced by OnCheckBox(), OnSlider(), and OnTextCtrl().

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

Member Data Documentation

◆ mDialog

wxWeakRef<wxDialog> LadspaEditor::mDialog

Definition at line 73 of file LadspaEditor.h.

◆ mDuration

NumericTextCtrl* LadspaEditor::mDuration {}

Definition at line 72 of file LadspaEditor.h.

Referenced by PopulateUI(), and ValidateUI().

◆ mFields

ArrayOf<wxTextCtrl*> LadspaEditor::mFields

Definition at line 76 of file LadspaEditor.h.

Referenced by OnSlider(), OnTextCtrl(), PopulateUI(), and RefreshControls().

◆ mInstance

const LadspaInstance& LadspaEditor::mInstance

Definition at line 63 of file LadspaEditor.h.

Referenced by OnSlider(), OnTextCtrl(), PopulateUI(), RefreshControls(), and UpdateControls().

◆ mLabels

ArrayOf<wxStaticText*> LadspaEditor::mLabels

Definition at line 77 of file LadspaEditor.h.

Referenced by PopulateUI().

◆ mMeters

std::vector<LadspaEffectMeter *> LadspaEditor::mMeters

Definition at line 79 of file LadspaEditor.h.

Referenced by Disconnect(), and PopulateUI().

◆ mNumInputControls

const unsigned LadspaEditor::mNumInputControls

Definition at line 64 of file LadspaEditor.h.

Referenced by PopulateUI().

◆ mNumOutputControls

const unsigned LadspaEditor::mNumOutputControls

Definition at line 65 of file LadspaEditor.h.

Referenced by PopulateUI().

◆ mParent

wxWindow* LadspaEditor::mParent {}

Definition at line 74 of file LadspaEditor.h.

Referenced by PopulateUI(), and RefreshControls().

◆ mpOutputs

const LadspaEffectOutputs* const LadspaEditor::mpOutputs

Definition at line 70 of file LadspaEditor.h.

Referenced by PopulateUI().

◆ mSampleRate

const double LadspaEditor::mSampleRate

Definition at line 67 of file LadspaEditor.h.

Referenced by OnSlider(), OnTextCtrl(), and PopulateUI().

◆ mSettings

LadspaEffectSettings LadspaEditor::mSettings

Definition at line 69 of file LadspaEditor.h.

Referenced by PopulateUI(), RefreshControls(), UpdateControl(), and ValidateUI().

◆ mSliders

ArrayOf<wxSlider*> LadspaEditor::mSliders

Definition at line 75 of file LadspaEditor.h.

Referenced by OnSlider(), OnTextCtrl(), and PopulateUI().

◆ mToggles

ArrayOf<wxCheckBox*> LadspaEditor::mToggles

Definition at line 78 of file LadspaEditor.h.

Referenced by OnCheckBox(), PopulateUI(), and RefreshControls().

◆ mType

const EffectType LadspaEditor::mType

Definition at line 68 of file LadspaEditor.h.

Referenced by PopulateUI(), and ValidateUI().


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