22#define M_PI 3.1415926535897932384626433832795
25#define M_PI_2 1.57079632679489661923132169163975
28#include <wx/checkbox.h>
33#include <wx/stattext.h>
34#include <wx/weakref.h>
38#include "../widgets/valnum.h"
43 XO(
"Upper Threshold"),
47 XO(
"Number of repeats"),
50 return names[ index ];
140 if ( !
mUIParent->TransferDataFromWindow())
164 return mInstance.mMaster;
169std::unique_ptr<EffectEditor>
176 auto result = std::make_unique<Editor>(*
this,
dynamic_cast<DistortionBase::Instance&
>(instance), access, myEffSettings);
177 result->PopulateOrExchange(
S);
184 mUIParent =
S.GetParent();
185 auto& ms = mSettings;
188 S.StartVerticalLay();
190 S.StartMultiColumn(4, wxCENTER);
193 .MinSize( { -1, -1 } )
195 .AddChoice(
XXO(
"Distortion type:"),
200 mDCBlockCheckBox =
S.AddCheckBox(
XXO(
"DC blocking filter"),
209 S.StartStatic(
XO(
"Threshold controls"));
211 S.StartMultiColumn(4, wxEXPAND);
215 S.AddSpace(250,0);
S.AddSpace(0,0);
S.AddSpace(0,0);
S.AddSpace(0,0);
219 false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
222 .Validator<FloatingPointValidator<double>>(
223 2, &ms.mThreshold_dB, NumValidatorStyle::DEFAULT,
225 .AddTextBox( {},
wxT(
""), 10);
231 .Style(wxSL_HORIZONTAL)
241 false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
244 .Validator<FloatingPointValidator<double>>(
245 2, &ms.mNoiseFloor, NumValidatorStyle::DEFAULT,
248 .AddTextBox( {},
wxT(
""), 10);
254 .Style(wxSL_HORIZONTAL)
264 S.StartStatic(
XO(
"Parameter controls"));
266 S.StartMultiColumn(4, wxEXPAND);
270 S.AddSpace(250,0);
S.AddSpace(0,0);
S.AddSpace(0,0);
S.AddSpace(0,0);
274 false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
277 .Validator<FloatingPointValidator<double>>(
278 2, &ms.mParam1, NumValidatorStyle::DEFAULT,
281 .AddTextBox( {},
wxT(
""), 10);
287 .Style(wxSL_HORIZONTAL)
295 false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
298 .Validator<FloatingPointValidator<double>>(
299 2, &ms.mParam2, NumValidatorStyle::DEFAULT,
302 .AddTextBox( {},
wxT(
""), 10);
308 .Style(wxSL_HORIZONTAL)
317 false, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT);
320 .Validator<IntegerValidator<int>>(
321 &ms.mRepeats, NumValidatorStyle::DEFAULT,
324 .AddTextBox( {},
wxT(
""), 10);
330 .Style(wxSL_HORIZONTAL)
348 const auto& ms = mSettings;
350 if (!mUIParent->TransferDataToWindow())
355 const double threshold =
DB_TO_LINEAR(ms.mThreshold_dB);
358 mDCBlockCheckBox->SetValue( ms.mDCBlock);
359 mNoiseFloorS-> SetValue((
int)ms.mNoiseFloor + 0.5);
360 mParam1S-> SetValue((
int)ms.mParam1 + 0.5);
361 mParam2S-> SetValue((
int)ms.mParam2 + 0.5);
362 mRepeatsS-> SetValue( ms.mRepeats);
364 GetState().mbSavedFilterState = ms.mDCBlock;
373 mTypeChoiceCtrl->GetValidator()->TransferFromWindow();
383 auto& ms = mSettings;
385 ms.mDCBlock = mDCBlockCheckBox->GetValue();
387 GetState().mbSavedFilterState = ms.mDCBlock;
396 const auto& ms = mSettings;
398 mThresholdT->GetValidator()->TransferFromWindow();
399 const double threshold =
DB_TO_LINEAR(ms.mThreshold_dB);
408 auto& ms = mSettings;
415 mThresholdT->GetValidator()->TransferToWindow();
423 const auto& ms = mSettings;
425 mNoiseFloorT->GetValidator()->TransferFromWindow();
426 mNoiseFloorS->SetValue((
int) floor(ms.mNoiseFloor + 0.5));
434 auto& ms = mSettings;
436 ms.mNoiseFloor = (double) evt.GetInt();
437 mNoiseFloorT->GetValidator()->TransferToWindow();
446 const auto& ms = mSettings;
448 mParam1T->GetValidator()->TransferFromWindow();
449 mParam1S->SetValue((
int) floor(ms.mParam1 + 0.5));
457 auto& ms = mSettings;
459 ms.mParam1 = (double) evt.GetInt();
460 mParam1T->GetValidator()->TransferToWindow();
468 const auto& ms = mSettings;
470 mParam2T->GetValidator()->TransferFromWindow();
471 mParam2S->SetValue((
int) floor(ms.mParam2 + 0.5));
479 auto& ms = mSettings;
481 ms.mParam2 = (double) evt.GetInt();
482 mParam2T->GetValidator()->TransferToWindow();
490 const auto& ms = mSettings;
492 mRepeatsT->GetValidator()->TransferFromWindow();
493 mRepeatsS->SetValue(ms.mRepeats);
501 auto& ms = mSettings;
503 ms.mRepeats = evt.GetInt();
504 mRepeatsT->GetValidator()->TransferToWindow();
512 const auto& ms = mSettings;
515 switch (ms.mTableChoiceIndx)
518 UpdateControlText(mThresholdT, mOldThresholdTxt,
true);
519 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
520 UpdateControlText(mParam1T, mOldParam1Txt,
true);
521 UpdateControlText(mParam2T, mOldParam2Txt,
true);
522 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
527 UpdateControl(
ID_Param2,
true,
XO(
"Make-up Gain"));
532 UpdateControlText(mThresholdT, mOldThresholdTxt,
true);
533 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
534 UpdateControlText(mParam1T, mOldParam1Txt,
true);
535 UpdateControlText(mParam2T, mOldParam2Txt,
true);
536 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
541 UpdateControl(
ID_Param2,
true,
XO(
"Make-up Gain"));
546 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
547 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
548 UpdateControlText(mParam1T, mOldParam1Txt,
true);
549 UpdateControlText(mParam2T, mOldParam2Txt,
true);
550 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
554 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
555 UpdateControl(
ID_Param2,
true,
XO(
"Output level"));
560 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
561 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
562 UpdateControlText(mParam1T, mOldParam1Txt,
true);
563 UpdateControlText(mParam2T, mOldParam2Txt,
true);
564 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
568 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
569 UpdateControl(
ID_Param2,
true,
XO(
"Output level"));
574 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
575 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
576 UpdateControlText(mParam1T, mOldParam1Txt,
true);
577 UpdateControlText(mParam2T, mOldParam2Txt,
true);
578 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
582 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
583 UpdateControl(
ID_Param2,
true,
XO(
"Output level"));
588 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
589 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
590 UpdateControlText(mParam1T, mOldParam1Txt,
true);
591 UpdateControlText(mParam2T, mOldParam2Txt,
true);
592 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
true);
596 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
597 UpdateControl(
ID_Param2,
true,
XO(
"Output level"));
598 UpdateControl(
ID_Repeats,
true,
XO(
"Repeat processing"));
602 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
603 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
604 UpdateControlText(mParam1T, mOldParam1Txt,
true);
605 UpdateControlText(mParam2T, mOldParam2Txt,
true);
606 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
610 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
611 UpdateControl(
ID_Param2,
true,
XO(
"Harmonic brightness"));
616 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
617 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
618 UpdateControlText(mParam1T, mOldParam1Txt,
true);
619 UpdateControlText(mParam2T, mOldParam2Txt,
true);
620 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
624 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
625 UpdateControl(
ID_Param2,
true,
XO(
"Output level"));
630 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
631 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
true);
632 UpdateControlText(mParam1T, mOldParam1Txt,
true);
633 UpdateControlText(mParam2T, mOldParam2Txt,
false);
634 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
true);
638 UpdateControl(
ID_Param1,
true,
XO(
"Levelling fine adjustment"));
640 UpdateControl(
ID_Repeats,
true,
XO(
"Degree of Levelling"));
644 UpdateControlText(mThresholdT, mOldThresholdTxt,
false);
645 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
646 UpdateControlText(mParam1T, mOldParam1Txt,
true);
647 UpdateControlText(mParam2T, mOldParam2Txt,
false);
648 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
652 UpdateControl(
ID_Param1,
true,
XO(
"Distortion amount"));
658 UpdateControlText(mThresholdT, mOldThresholdTxt,
true);
659 UpdateControlText(mNoiseFloorT, mOldmNoiseFloorTxt,
false);
660 UpdateControlText(mParam1T, mOldParam1Txt,
true);
661 UpdateControlText(mParam2T, mOldParam2Txt,
true);
662 UpdateControlText(mRepeatsT, mOldRepeatsTxt,
false);
667 UpdateControl(
ID_Param2,
true,
XO(
"Residual level"));
685 auto& ms = mSettings;
687 auto suffix =
XO(
"(Not Used):");
692 if (enabled) suffix =
XO(
"(-100 to 0 dB):");
696 const double threshold =
DB_TO_LINEAR(ms.mThreshold_dB);
699 auto translated =
name.Translation();
700 mThresholdTxt->SetLabel(translated);
701 mThresholdS->SetName(translated);
702 mThresholdT->SetName(translated);
703 mThresholdS->Enable(enabled);
704 mThresholdT->Enable(enabled);
709 if (enabled) suffix =
XO(
"(-80 to -20 dB):");
712 auto translated =
name.Translation();
713 mNoiseFloorTxt->SetLabel(translated);
714 mNoiseFloorS->SetName(translated);
715 mNoiseFloorT->SetName(translated);
716 mNoiseFloorS->Enable(enabled);
717 mNoiseFloorT->Enable(enabled);
722 if (enabled) suffix =
XO(
"(0 to 100):");
725 auto translated =
name.Translation();
726 mParam1Txt->SetLabel(translated);
727 mParam1S->SetName(translated);
728 mParam1T->SetName(translated);
729 mParam1S->Enable(enabled);
730 mParam1T->Enable(enabled);
735 if (enabled) suffix =
XO(
"(0 to 100):");
738 auto translated =
name.Translation();
739 mParam2Txt->SetLabel(translated);
740 mParam2S->SetName(translated);
741 mParam2T->SetName(translated);
742 mParam2S->Enable(enabled);
743 mParam2T->Enable(enabled);
748 if (enabled) suffix =
XO(
"(0 to 5):");
751 auto translated =
name.Translation();
752 mRepeatsTxt->SetLabel(translated);
753 mRepeatsS->SetName(translated);
754 mRepeatsT->SetName(translated);
755 mRepeatsS->Enable(enabled);
756 mRepeatsT->Enable(enabled);
761 mDCBlockCheckBox->SetValue(GetState().mbSavedFilterState);
762 ms.mDCBlock = GetState().mbSavedFilterState;
765 mDCBlockCheckBox->SetValue(
false);
769 mDCBlockCheckBox->Enable(enabled);
780 if (textCtrl->GetValue().empty())
781 textCtrl->SetValue(
string);
783 string = textCtrl->GetValue();
786 if (!textCtrl->GetValue().empty())
787 string = textCtrl->GetValue();
788 textCtrl->SetValue(
wxT(
""));
TranslatableString defaultLabel(int index)
XXO("&Cut/Copy/Paste Toolbar")
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
static Settings & settings()
bool ValidateUI(const EffectPlugin &context, EffectSettings &) const override
static constexpr EffectParameter DCBlock
static const EnumValueSymbol kTableTypeStrings[nTableTypes]
static constexpr EffectParameter NoiseFloor
static constexpr EffectParameter Threshold_dB
static constexpr EffectParameter Repeats
static constexpr EffectParameter Param1
static constexpr EffectParameter Param2
std::unique_ptr< EffectEditor > MakeEditor(ShuttleGui &S, EffectInstance &instance, EffectSettingsAccess &access, const EffectOutputs *pOutputs) const override
Called only from PopulateUI, to add controls to effect panel.
EffectSettingsAccess & mAccess
Performs effect computation.
Hold values to send to effect output meters.
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
static EffectDistortionSettings & GetSettings(EffectSettings &settings)
Assume settings originated from MakeSettings() and copies thereof.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
A Validator is an object which checks whether a wxVariant satisfies a certain criterion....
BuiltinEffectsModule::Registration< EffectDistortion > reg
wxStaticText * mRepeatsTxt
virtual ~Editor()=default
void OnParam2Text(wxCommandEvent &evt)
bool ValidateUI() override
Get settings data from the panel; may make error dialogs and return false.
DistortionBase::Instance & mInstance
wxString mOldmNoiseFloorTxt
void UpdateControl(control id, bool enable, TranslatableString name)
void OnRepeatsText(wxCommandEvent &evt)
void OnRepeatsSlider(wxCommandEvent &evt)
void OnTypeChoice(wxCommandEvent &evt)
wxStaticText * mThresholdTxt
void OnDCBlockCheckbox(wxCommandEvent &evt)
wxStaticText * mParam2Txt
Editor(const EffectUIServices &services, DistortionBase::Instance &instance, EffectSettingsAccess &access, const EffectDistortionSettings &settings)
EffectDistortionSettings mSettings
bool UpdateUI() override
Update appearance of the panel for changes in settings.
void UpdateControlText(wxTextCtrl *textCtrl, wxString &string, bool enabled)
wxString mOldThresholdTxt
wxCheckBox * mDCBlockCheckBox
void OnNoiseFloorText(wxCommandEvent &evt)
wxWeakRef< wxWindow > mUIParent
void OnParam2Slider(wxCommandEvent &evt)
void OnThresholdText(wxCommandEvent &evt)
wxChoice * mTypeChoiceCtrl
void OnParam1Slider(wxCommandEvent &evt)
void OnParam1Text(wxCommandEvent &evt)
wxStaticText * mParam1Txt
void OnThresholdSlider(wxCommandEvent &evt)
void PopulateOrExchange(ShuttleGui &S)
wxTextCtrl * mNoiseFloorT
wxStaticText * mNoiseFloorTxt
void OnNoiseFloorSlider(wxCommandEvent &evt)
EffectDistortionState & GetState()
const Type scale
Scaling factor, for slider control.
const Type def
Default value.
const Type min
Minimum value.
const Type max
Maximum value.
Message sent by EffectEditor when a setting is changed by the user.
Externalized state of a plug-in.