Audacity 3.2.0
Public Member Functions | Public Attributes | List of all members
LadspaEffect::Validator Struct Reference
Inheritance diagram for LadspaEffect::Validator:
[legend]
Collaboration diagram for LadspaEffect::Validator:
[legend]

Public Member Functions

 Validator (EffectUIClientInterface &effect, 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)
 
const LadspaEffectGetEffect ()
 
- Public Member Functions inherited from EffectUIValidator
 EffectUIValidator (EffectUIClientInterface &effect, EffectSettingsAccess &access)
 
virtual ~EffectUIValidator ()
 
virtual bool ValidateUI ()=0
 Get settings data from the panel; may make error dialogs and return false. More...
 
virtual bool UpdateUI ()
 Update appearance of the panel for changes in settings. More...
 
virtual bool IsGraphicalUI ()
 
virtual void Disconnect ()
 On the first call only, may disconnect from further event handling. More...
 
virtual void OnClose ()
 
- Public Member Functions inherited from Observer::Publisher< EffectSettingChanged >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Public Attributes

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 Member Functions inherited from EffectUIValidator
static bool EnableApply (wxWindow *parent, bool enable=true)
 Enable or disable the Apply button of the dialog that contains parent. More...
 
static bool EnablePreview (wxWindow *parent, bool enable=true)
 
- Static Public Attributes inherited from EffectUIValidator
static constexpr int kPlayID = 20102
 
- Static Public Attributes inherited from Observer::Publisher< EffectSettingChanged >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from EffectUIValidator
template<typename EventTag , typename Class , typename Event >
void BindTo (wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
 
- Protected Member Functions inherited from Observer::Publisher< EffectSettingChanged >
CallbackReturn Publish (const EffectSettingChanged &message)
 Send a message to connected callbacks. More...
 
- Protected Attributes inherited from EffectUIValidator
EffectUIClientInterfacemEffect
 
EffectSettingsAccessmAccess
 
bool mUIClosed { false }
 

Detailed Description

Definition at line 1192 of file LadspaEffect.cpp.

Constructor & Destructor Documentation

◆ Validator()

LadspaEffect::Validator::Validator ( EffectUIClientInterface effect,
EffectSettingsAccess access,
double  sampleRate,
EffectType  type,
const LadspaEffectOutputs pOutputs 
)
inline

Definition at line 1193 of file LadspaEffect.cpp.

1196 : EffectUIValidator{ effect, access }
1197 , mSampleRate{ sampleRate }
1198 , mType{ type }
1199 // Copy settings
1200 , mSettings{ GetSettings(access.Get()) }
1201 , mpOutputs{ pOutputs }
1202 {}
virtual const EffectSettings & Get()=0
Interface for transferring values from a panel of effect controls.
Definition: EffectPlugin.h:239
static LadspaEffectSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Definition: Effect.h:262
const LadspaEffectOutputs *const mpOutputs
LadspaEffectSettings mSettings
const EffectType mType

Member Function Documentation

◆ Disconnect()

void LadspaEffect::Validator::Disconnect ( )
overridevirtual

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

Default implemantation does nothing

Reimplemented from EffectUIValidator.

Definition at line 1539 of file LadspaEffect.cpp.

1540{
1541 for (auto &meter : mMeters)
1542 if (meter) {
1543 meter->Disconnect();
1544 meter = nullptr;
1545 }
1546}
std::vector< LadspaEffectMeter * > mMeters

◆ GetEffect()

const LadspaEffect & LadspaEffect::Validator::GetEffect ( )
inline

Definition at line 1218 of file LadspaEffect.cpp.

1219 { return static_cast<const LadspaEffect &>(mEffect); }
EffectUIClientInterface & mEffect
Definition: EffectPlugin.h:296
An Effect that calls up a LADSPA plug in, i.e. many possible effects from this one class.
Definition: LadspaEffect.h:67

References EffectUIValidator::mEffect.

◆ OnCheckBox()

void LadspaEffect::Validator::OnCheckBox ( wxCommandEvent &  evt)

Definition at line 1702 of file LadspaEffect.cpp.

1703{
1704 int p = evt.GetId() - ID_Toggles;
1705 // 0.5 is a half of the interval
1706 UpdateControl(p, mToggles[p]->GetValue(), 0.5f);
1707 ValidateUI();
1708}
@ ID_Toggles
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
void UpdateControl(int index, float value, float epsilon)
ArrayOf< wxCheckBox * > mToggles

References ID_Toggles, and Effect::ValidateUI().

Referenced by PopulateUI().

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

◆ OnSlider()

void LadspaEffect::Validator::OnSlider ( wxCommandEvent &  evt)

Definition at line 1710 of file LadspaEffect.cpp.

1711{
1712 int p = evt.GetId() - ID_Sliders;
1713
1714 float val;
1715 float lower = float(0.0);
1716 float upper = float(10.0);
1717 float range;
1718 bool forceint = false;
1719
1722 lower = hint.LowerBound;
1724 upper = hint.UpperBound;
1726 lower *= mSampleRate;
1727 upper *= mSampleRate;
1728 forceint = true;
1729 }
1730
1731 range = upper - lower;
1732 val = (mSliders[p]->GetValue() / 1000.0) * range + lower;
1733 wxString str;
1734 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
1735 str.Printf(wxT("%d"), (int)(val + 0.5));
1736 else
1738
1739 mFields[p]->SetValue(str);
1740
1742 ValidateUI();
1743}
wxT("CloseDown"))
#define str(a)
constexpr float ControlValueTolerance
@ ID_Sliders
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:161
const LADSPA_Descriptor * mData
Definition: LadspaEffect.h:159
#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< wxTextCtrl * > mFields
ArrayOf< wxSlider * > mSliders
const LadspaEffect & GetEffect()

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, str, Internat::ToDisplayString(), _LADSPA_PortRangeHint::UpperBound, Effect::ValidateUI(), and wxT().

Referenced by PopulateUI().

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

◆ OnTextCtrl()

void LadspaEffect::Validator::OnTextCtrl ( wxCommandEvent &  evt)

Definition at line 1745 of file LadspaEffect.cpp.

1746{
1747 int p = evt.GetId() - ID_Texts;
1748
1749 float val;
1750 float lower = float(0.0);
1751 float upper = float(10.0);
1752 float range;
1753
1754 val = Internat::CompatibleToDouble(mFields[p]->GetValue());
1755
1758 lower = hint.LowerBound;
1760 upper = hint.UpperBound;
1762 lower *= mSampleRate;
1763 upper *= mSampleRate;
1764 }
1765 range = upper - lower;
1766 if (val < lower)
1767 val = lower;
1768 if (val > upper)
1769 val = upper;
1770
1771 mSliders[p]->SetValue((int)(((val-lower)/range) * 1000.0 + 0.5));
1772
1774 ValidateUI();
1775}
@ ID_Texts
static bool CompatibleToDouble(const wxString &stringToConvert, double *result)
Convert a string to a number.
Definition: Internat.cpp:133

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, _LADSPA_PortRangeHint::UpperBound, and Effect::ValidateUI().

Referenced by PopulateUI().

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

◆ PopulateUI()

void LadspaEffect::Validator::PopulateUI ( ShuttleGui S)

Definition at line 1242 of file LadspaEffect.cpp.

1243{
1244 auto &effect = GetEffect();
1245 auto &controls = mSettings.controls;
1246 auto parent = S.GetParent();
1247
1248 mParent = parent;
1249
1250 const auto &data = *effect.mData;
1251 mToggles.reinit( data.PortCount );
1252 mSliders.reinit( data.PortCount );
1253 mFields.reinit( data.PortCount, true);
1254 mLabels.reinit( data.PortCount );
1255 mMeters.resize( data.PortCount );
1256
1257 wxASSERT(mParent); // To justify safenew
1258 wxScrolledWindow *const w = safenew wxScrolledWindow(mParent,
1259 wxID_ANY,
1260 wxDefaultPosition,
1261 wxDefaultSize,
1262 wxVSCROLL | wxTAB_TRAVERSAL);
1263
1264 {
1265 auto mainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1266 w->SetScrollRate(0, 20);
1267
1268 // This fools NVDA into not saying "Panel" when the dialog gets focus
1269 w->SetName(wxT("\a"));
1270 w->SetLabel(wxT("\a"));
1271
1272 mainSizer->Add(w, 1, wxEXPAND);
1273 mParent->SetSizer(mainSizer.release());
1274 }
1275
1276 wxSizer *marginSizer;
1277 {
1278 auto uMarginSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1279 marginSizer = uMarginSizer.get();
1280
1281 // Make user-adjustible input controls
1282 if (effect.mNumInputControls) {
1283 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w, _("Effect Settings"));
1284
1285 auto gridSizer = std::make_unique<wxFlexGridSizer>(5, 0, 0);
1286 gridSizer->AddGrowableCol(3);
1287
1288 wxControl *item;
1289
1290 // Add the duration control for generators
1291 if (mType == EffectTypeGenerate) {
1292 item = safenew wxStaticText(w, 0, _("Duration:"));
1293 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
1294 auto &extra = mAccess.Get().extra;
1298 extra.GetDurationFormat(),
1299 extra.GetDuration(),
1302 .AutoPos(true));
1303 mDuration->SetName( XO("Duration") );
1304 gridSizer->Add(mDuration, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
1305 gridSizer->Add(1, 1, 0);
1306 gridSizer->Add(1, 1, 0);
1307 gridSizer->Add(1, 1, 0);
1308 }
1309
1310 for (unsigned long p = 0; p < data.PortCount; ++p) {
1311 LADSPA_PortDescriptor d = data.PortDescriptors[p];
1313 {
1314 continue;
1315 }
1316
1317 wxString labelText = LAT1CTOWX(data.PortNames[p]);
1318 item = safenew wxStaticText(w, 0, wxString::Format(_("%s:"), labelText));
1319 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
1320
1321 wxString fieldText;
1322 LADSPA_PortRangeHint hint = data.PortRangeHints[p];
1323
1325 mToggles[p] = safenew wxCheckBox(w, ID_Toggles + p, wxT(""));
1326 mToggles[p]->SetName(labelText);
1327 mToggles[p]->SetValue(controls[p] > 0);
1328 BindTo(*mToggles[p],
1329 wxEVT_COMMAND_CHECKBOX_CLICKED, &Validator::OnCheckBox);
1330 gridSizer->Add(mToggles[p], 0, wxALL, 5);
1331
1332 gridSizer->Add(1, 1, 0);
1333 gridSizer->Add(1, 1, 0);
1334 gridSizer->Add(1, 1, 0);
1335 continue;
1336 }
1337
1338 wxString bound;
1339 float lower = -FLT_MAX;
1340 float upper = FLT_MAX;
1341 bool haslo = false;
1342 bool hashi = false;
1343 bool forceint = false;
1344
1346 lower = hint.LowerBound;
1347 haslo = true;
1348 }
1349
1351 upper = hint.UpperBound;
1352 hashi = true;
1353 }
1354
1356 lower *= mSampleRate;
1357 upper *= mSampleRate;
1358 forceint = true;
1359 }
1360
1361 // Limit to the UI precision
1362 lower = ceilf(lower * 1000000.0) / 1000000.0;
1363 upper = floorf(upper * 1000000.0) / 1000000.0;
1364 controls[p] = roundf(controls[p] * 1000000.0) / 1000000.0;
1365
1366 if (haslo && controls[p] < lower)
1367 controls[p] = lower;
1368
1369 if (hashi && controls[p] > upper)
1370 controls[p] = upper;
1371
1372 // Don't specify a value at creation time. This prevents unwanted events
1373 // being sent to the OnTextCtrl() handler before the associated slider
1374 // has been created.
1375 mFields[p] = safenew wxTextCtrl(w, ID_Texts + p);
1376 mFields[p]->SetName(labelText);
1377 BindTo(*mFields[p],
1379 gridSizer->Add(mFields[p], 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
1380
1381 wxString str;
1382 if (haslo) {
1383 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
1384 {
1385 str.Printf(wxT("%d"), (int)(lower + 0.5));
1386 }
1387 else
1388 {
1390 }
1391 item = safenew wxStaticText(w, 0, str);
1392 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
1393 }
1394 else
1395 gridSizer->Add(1, 1, 0);
1396
1398 0, 0, 1000,
1399 wxDefaultPosition,
1400 wxSize(200, -1));
1401#if wxUSE_ACCESSIBILITY
1402 // so that name can be set on a standard control
1403 mSliders[p]->SetAccessible(safenew WindowAccessible(mSliders[p]));
1404#endif
1405 mSliders[p]->SetName(labelText);
1406 BindTo(*mSliders[p],
1407 wxEVT_COMMAND_SLIDER_UPDATED, &Validator::OnSlider);
1408 gridSizer->Add(mSliders[p], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5);
1409
1410 if (hashi) {
1411 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
1412 str.Printf(wxT("%d"), (int)(upper + 0.5));
1413 else
1415 item = safenew wxStaticText(w, 0, str);
1416 gridSizer->Add(item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT | wxALL, 5);
1417 }
1418 else
1419 gridSizer->Add(1, 1, 0);
1420
1421 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint) {
1422 fieldText.Printf(wxT("%d"), (int)(controls[p] + 0.5));
1423
1424 IntegerValidator<float> vld(&controls[p]);
1425 vld.SetRange(haslo ? lower : INT_MIN,
1426 hashi ? upper : INT_MAX);
1427 mFields[p]->SetValidator(vld);
1428 }
1429 else {
1430 fieldText = Internat::ToDisplayString(controls[p]);
1431
1432 // > 12 decimal places can cause rounding errors in display.
1433 FloatingPointValidator<float> vld(6, &controls[p]);
1434 vld.SetRange(lower, upper);
1435
1436 // Set number of decimal places
1437 if (upper - lower < 10.0)
1438 vld.SetStyle(NumValidatorStyle::THREE_TRAILING_ZEROES);
1439 else if (upper - lower < 100.0)
1440 vld.SetStyle(NumValidatorStyle::TWO_TRAILING_ZEROES);
1441 else
1442 vld.SetStyle(NumValidatorStyle::ONE_TRAILING_ZERO);
1443
1444 mFields[p]->SetValidator(vld);
1445 }
1446
1447 // Set the textctrl value. This will trigger an event so OnTextCtrl()
1448 // can update the slider.
1449 mFields[p]->SetValue(fieldText);
1450 }
1451
1452 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
1453 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
1454 }
1455
1456 // Make output meters
1457 if (effect.mNumOutputControls > 0) {
1458 auto paramSizer = std::make_unique<wxStaticBoxSizer>(wxVERTICAL, w, _("Effect Output"));
1459
1460 auto gridSizer = std::make_unique<wxFlexGridSizer>(2, 0, 0);
1461 gridSizer->AddGrowableCol(1);
1462
1463 wxControl *item;
1464
1465 for (unsigned long p = 0; p < data.PortCount; ++p) {
1466 LADSPA_PortDescriptor d = data.PortDescriptors[p];
1468 continue;
1469
1470 wxString labelText = LAT1CTOWX(data.PortNames[p]);
1471 item = safenew wxStaticText(
1472 w, 0, wxString::Format(_("%s:"), labelText));
1473 gridSizer->Add(
1474 item, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxALL, 5);
1475
1476 //LADSPA_PortRangeHint hint = data.PortRangeHints[p];
1477
1478 wxString bound;
1479 float lower = 0.0;
1480 float upper = 1.0;
1481
1482 // Limit to the UI precision
1483 lower = ceilf(lower * 1000000.0) / 1000000.0;
1484 upper = floorf(upper * 1000000.0) / 1000000.0;
1485 controls[p] = lower;
1486
1487 // Capture const reference to output control value for later
1488 // display update
1489 static float sink;
1490 auto pOutput = mpOutputs ? &mpOutputs->controls[p] : &sink;
1492 w, *pOutput, lower, upper);
1493 mMeters[p]->SetLabel(labelText); // for screen readers
1494 gridSizer->Add(mMeters[p], 1, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL, 5);
1495 }
1496
1497 paramSizer->Add(gridSizer.release(), 0, wxEXPAND | wxALL, 5);
1498 marginSizer->Add(paramSizer.release(), 0, wxEXPAND | wxALL, 5);
1499 }
1500
1501 w->SetSizer(uMarginSizer.release());
1502 }
1503
1504 w->Layout();
1505
1506 // Try to give the window a sensible default/minimum size
1507 wxSize sz1 = marginSizer->GetMinSize();
1508 wxSize sz2 = mParent->GetMinSize();
1509 w->SetMinSize( { std::min(sz1.x, sz2.x), std::min(sz1.y, sz2.y) } );
1510
1511 // And let the parent reduce to the NEW minimum if possible
1512 mParent->SetMinSize({ -1, -1 });
1513}
int min(int a, int b)
@ EffectTypeGenerate
XO("Cut/Copy/Paste")
#define LAT1CTOWX(X)
Definition: Internat.h:160
#define _(s)
Definition: Internat.h:75
@ ID_Duration
#define safenew
Definition: MemoryX.h:10
wxEVT_COMMAND_TEXT_UPDATED
Definition: Nyquist.cpp:132
#define S(N)
Definition: ToChars.cpp:64
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:57
EffectSettingsAccess & mAccess
Definition: EffectPlugin.h:297
void BindTo(wxEvtHandler &src, const EventTag &eventType, void(Class::*pmf)(Event &))
Definition: EffectPlugin.h:290
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
void OnSlider(wxCommandEvent &evt)
ArrayOf< wxStaticText * > mLabels
void OnCheckBox(wxCommandEvent &evt)
void OnTextCtrl(wxCommandEvent &evt)
NumericTextCtrl * mDuration
std::vector< float > controls
Definition: LadspaEffect.h:62
std::vector< float > controls
Definition: LadspaEffect.h:50
Options & AutoPos(bool enable)

References _, NumericTextCtrl::Options::AutoPos(), EffectTypeGenerate, _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, min(), OnCheckBox(), OnSlider(), OnTextCtrl(), S, safenew, str, NumericConverter::TIME, Internat::ToDisplayString(), _LADSPA_PortRangeHint::UpperBound, wxEVT_COMMAND_TEXT_UPDATED, wxT(), and XO().

Here is the call graph for this function:

◆ RefreshControls()

void LadspaEffect::Validator::RefreshControls ( )

Definition at line 1777 of file LadspaEffect.cpp.

1778{
1779 if (!mParent)
1780 return;
1781
1782 // Copy from the dialog
1784
1785 auto& controls = mSettings.controls;
1786
1787 const auto &data = *GetEffect().mData;
1788 for (unsigned long p = 0; p < data.PortCount; ++p) {
1790 if (!(LADSPA_IS_PORT_CONTROL(d)))
1791 continue;
1792
1793 wxString fieldText;
1794 LADSPA_PortRangeHint hint = data.PortRangeHints[p];
1795
1796 bool forceint = false;
1798 forceint = true;
1799
1800 if (LADSPA_IS_PORT_OUTPUT(d))
1801 continue;
1802
1804 mToggles[p]->SetValue(controls[p] > 0);
1805 continue;
1806 }
1807
1808 if (LADSPA_IS_HINT_INTEGER(hint.HintDescriptor) || forceint)
1809 fieldText.Printf(wxT("%d"), (int)(controls[p] + 0.5));
1810 else
1811 fieldText = Internat::ToDisplayString(controls[p]);
1812
1813 // Set the textctrl value. This will trigger an event so OnTextCtrl()
1814 // can update the slider.
1815 mFields[p]->SetValue(fieldText);
1816 }
1817}
#define LADSPA_IS_PORT_CONTROL(x)
Definition: ladspa.h:170
const LADSPA_PortDescriptor * PortDescriptors
Definition: ladspa.h:410
void UpdateControls(const LadspaEffectSettings &src)

References EffectWithSettings< LadspaEffectSettings, PerTrackEffect >::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, Internat::ToDisplayString(), and wxT().

Here is the call graph for this function:

◆ UpdateControl()

void LadspaEffect::Validator::UpdateControl ( int  index,
float  value,
float  epsilon 
)

Definition at line 1819 of file LadspaEffect.cpp.

1820{
1821 auto& controls = mSettings.controls;
1822
1823 assert(index < static_cast<int>(controls.size()));
1824
1825 if (std::abs(controls[index] - value) < epsilon)
1826 return;
1827
1828 controls[index] = value;
1829 Publish({ size_t(index), value });
1830}
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
Definition: Observer.h:207

◆ UpdateControls()

void LadspaEffect::Validator::UpdateControls ( const LadspaEffectSettings src)

Definition at line 1832 of file LadspaEffect.cpp.

1833{
1834 const auto& data = *GetEffect().mData;
1835
1836 for (size_t portIndex = 0, portsCount = src.controls.size();
1837 portIndex < portsCount;
1838 ++portIndex)
1839 {
1840 LADSPA_PortDescriptor d = data.PortDescriptors[portIndex];
1841
1843 continue;
1844
1846
1847 const bool isIntValue = (LADSPA_IS_HINT_TOGGLED(hint.HintDescriptor)) ||
1850
1852 portIndex, src.controls[portIndex],
1853 isIntValue ? 0.5f : ControlValueTolerance);
1854 }
1855}

References LadspaEffectSettings::controls, ControlValueTolerance, _LADSPA_PortRangeHint::HintDescriptor, LADSPA_IS_HINT_INTEGER, LADSPA_IS_HINT_SAMPLE_RATE, LADSPA_IS_HINT_TOGGLED, LADSPA_IS_PORT_CONTROL, and LADSPA_IS_PORT_OUTPUT.

◆ UpdateUI()

bool LadspaEffect::Validator::UpdateUI ( )
overridevirtual

Update appearance of the panel for changes in settings.

Default implementation does nothing, returns true

Returns
true if successful

Reimplemented from EffectUIValidator.

Definition at line 1236 of file LadspaEffect.cpp.

1237{
1239 return true;
1240}

◆ ValidateUI()

bool LadspaEffect::Validator::ValidateUI ( )
overridevirtual

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

Returns
true only if panel settings are acceptable

Implements EffectUIValidator.

Definition at line 1528 of file LadspaEffect.cpp.

1529{
1532 settings.extra.SetDuration(mDuration->GetValue());
1534 return nullptr;
1535 });
1536 return true;
1537}
static Settings & settings()
Definition: TrackInfo.cpp:87
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
Externalized state of a plug-in.

References EffectTypeGenerate, EffectWithSettings< LadspaEffectSettings, PerTrackEffect >::GetSettings(), and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mDialog

wxWeakRef<wxDialog> LadspaEffect::Validator::mDialog

Definition at line 1227 of file LadspaEffect.cpp.

◆ mDuration

NumericTextCtrl* LadspaEffect::Validator::mDuration {}

Definition at line 1226 of file LadspaEffect.cpp.

◆ mFields

ArrayOf<wxTextCtrl*> LadspaEffect::Validator::mFields

Definition at line 1230 of file LadspaEffect.cpp.

◆ mLabels

ArrayOf<wxStaticText*> LadspaEffect::Validator::mLabels

Definition at line 1231 of file LadspaEffect.cpp.

◆ mMeters

std::vector<LadspaEffectMeter *> LadspaEffect::Validator::mMeters

Definition at line 1233 of file LadspaEffect.cpp.

◆ mParent

wxWindow* LadspaEffect::Validator::mParent {}

Definition at line 1228 of file LadspaEffect.cpp.

◆ mpOutputs

const LadspaEffectOutputs* const LadspaEffect::Validator::mpOutputs

Definition at line 1224 of file LadspaEffect.cpp.

◆ mSampleRate

const double LadspaEffect::Validator::mSampleRate

Definition at line 1221 of file LadspaEffect.cpp.

◆ mSettings

LadspaEffectSettings LadspaEffect::Validator::mSettings

Definition at line 1223 of file LadspaEffect.cpp.

◆ mSliders

ArrayOf<wxSlider*> LadspaEffect::Validator::mSliders

Definition at line 1229 of file LadspaEffect.cpp.

◆ mToggles

ArrayOf<wxCheckBox*> LadspaEffect::Validator::mToggles

Definition at line 1232 of file LadspaEffect.cpp.

◆ mType

const EffectType LadspaEffect::Validator::mType

Definition at line 1222 of file LadspaEffect.cpp.


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