16#include <wx/checkbox.h>
20#include <wx/textctrl.h>
22#if wxUSE_ACCESSIBILITY
44 constexpr auto minRange = 3.f;
45 return std::max(minRange, maxCompressionDb / 2);
54 return compressorSettings ?
60 wxWindow* parent, wxOrientation orientation,
float dbRange,
64 const wxSize minSize { -1, -1 };
67 parent,
id, orientation, minSize,
74 .
Flip(orientation == wxVERTICAL)
83 return (std::exp(
C * x) - 1) / (std::exp(
C) - 1.);
90 const auto a = 1.0 / (max -
min);
91 const auto b = -
min / (max -
min);
100 return (std::log(x * (std::exp(
C) - 1) + 1)) /
C;
105 const auto a = 1.0 / (max -
min);
106 const auto b = -
min / (max -
min);
112 const auto scaled = value / setting.
param->TextToSlider();
115 setting.
param->SliderMin(), setting.
param->SliderMax(),
124 setting.
param->SliderMin(),
127 return unscaled * setting.
param->TextToSlider();
135 , mUIParent { parent }
136 , mTopLevelParent(static_cast<wxDialog&>(*wxGetTopLevelParent(parent)))
137 , mCompressorInstance { instance }
138 , mIsRealtime { isRealtime }
143 std::vector<ExtendedCompressorParameter> parameters)
145 assert(std::is_sorted(
146 parameters.begin(), parameters.end(),
147 [](
const auto& a,
const auto& b) { return a.category < b.category; }));
157 if (compressorSettings)
159 S.StartMultiColumn(2, wxEXPAND);
181 const auto onDbRangeChanged = [
this](
float newDbRange) {
186 wxWindow::FindWindowById(
id,
mUIParent)))
188 panel->ruler.SetRange(0., -newDbRange);
192 const auto compressionMeterPanel =
195 compressionMeterPanel->SetDbRange(newDbRange);
200 histPanel->ShowInput(
settings.showInput);
201 histPanel->ShowOutput(
settings.showOutput);
202 histPanel->ShowActual(
settings.showActual);
203 histPanel->ShowTarget(
settings.showTarget);
205 S.StartMultiColumn(compressorSettings ? 3 : 1, wxEXPAND);
209 if (compressorSettings)
217 S.SetSizerProportion(1);
218 S.StartMultiColumn(5, wxEXPAND);
226 .Position(wxALIGN_LEFT | wxALIGN_TOP | wxEXPAND)
228 .AddWindow(histPanel);
232 const auto onClipped = [
this] {
239 .Position(wxALIGN_LEFT | wxALIGN_TOP | wxEXPAND)
244 ->Bind(wxEVT_LEFT_UP, [
this](wxMouseEvent& evt) {
256 .Position(wxEXPAND | wxALIGN_TOP)
258 .AddWindow(rulerPanel);
268#define GET_REF(settingName) \
269 GetCompressorSettings() ? GetCompressorSettings()->settingName : \
270 GetLimiterSettings()->settingName
272 S.StartVerticalLay(wxALIGN_BOTTOM, 0);
274 S.StartHorizontalLay(wxALIGN_LEFT, 0);
277 const auto input =
S.AddCheckBox(
XO(
"I&nput"),
settings.showInput);
278 input->Bind(wxEVT_CHECKBOX, [
this](wxCommandEvent& evt) {
280 evt.IsChecked(),
GET_REF(showInput), &HistPanel::ShowInput);
283 input->SetName(
_(
"Show input"));
285 const auto output =
S.AddCheckBox(
XO(
"O&utput"),
settings.showOutput);
286 output->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& evt) {
288 evt.IsChecked(),
GET_REF(showOutput), &HistPanel::ShowOutput);
291 output->SetName(
_(
"Show output"));
295 S.AddCheckBox(
XO(
"A&ctual compression"),
settings.showActual);
296 actual->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& evt) {
298 evt.IsChecked(),
GET_REF(showActual), &HistPanel::ShowActual);
301 actual->SetName(
_(
"Show actual compression"));
305 S.AddCheckBox(
XO(
"Tar&get compression"),
settings.showTarget);
306 target->Bind(wxEVT_CHECKBOX, [&](wxCommandEvent& evt) {
308 evt.IsChecked(),
GET_REF(showTarget), &HistPanel::ShowTarget);
311 target->SetName(
_(
"Show target compression"));
313#if wxUSE_ACCESSIBILITY
321 S.EndHorizontalLay();
331 S.MinSize({ width, height })
334 wxALIGN_RIGHT | wxALIGN_BOTTOM)
335 ->Bind(wxEVT_LEFT_UP, [
this](wxMouseEvent& evt) {
339 panel->ResetClipped();
341 const auto indicator =
350 S.StartMultiColumn(3);
354 constexpr auto tfWidth = 200;
359 .Position(wxALIGN_BOTTOM)
368 S.Prop(1).Position(wxEXPAND).AddWindow(
376 using It = std::vector<ExtendedCompressorParameter>::iterator;
377 const auto addTextboxAndSliders = [&](
380 S.StartStatic(prompt);
381 S.StartMultiColumn(3, wxEXPAND);
392 const auto firstSmoothingParameterIt =
394 return p.category == ControllerCategory::TimeSmoothing;
399 addTextboxAndSliders(
401 firstSmoothingParameterIt);
402 addTextboxAndSliders(
403 XO(
"Smoothing"), firstSmoothingParameterIt,
mParameters.end());
411 setting.
text =
S.Validator<FloatingPointValidator<double>>(
412 1, &setting.
value, NumValidatorStyle::ONE_TRAILING_ZERO,
416 setting.
text->Bind(wxEVT_TEXT, [&](wxCommandEvent& evt) {
427 .Style(wxSL_HORIZONTAL)
428 .MinSize({ 100, -1 })
431 setting.
param->SliderMin());
433 setting.
slider->Bind(wxEVT_SLIDER, [&](wxCommandEvent& evt) {
435 setting.
text->GetValidator()->TransferToWindow();
447 setting.
slider->Bind(wxEVT_SCROLL_LINEDOWN, [&](wxScrollEvent& evt) {
450 setting.
value += 0.1;
456 setting.
slider->Bind(wxEVT_SCROLL_LINEUP, [&](wxScrollEvent& evt) {
459 setting.
value -= 0.1;
497 bool newVal,
double& setting,
502 const auto panel =
dynamic_cast<HistPanel*
>(
504 (panel->*setter)(newVal);
Toolkit-neutral facade for basic user interface services.
#define GET_REF(settingName)
static Settings & settings()
static float GetMaxCompressionDb(const DynamicRangeProcessorSettings &settings)
std::vector< ExtendedCompressorParameter > mParameters
void OnCheckbox(bool newVal, double &setting, void(DynamicRangeProcessorHistoryPanel::*)(bool))
void AddCompressionCurvePanel(ShuttleGui &S, const CompressorSettings &)
void AddSliderPanel(ShuttleGui &S)
void AddClipIndicator(ShuttleGui &S)
virtual const CompressorSettings * GetCompressorSettings() const
void Initialize(std::vector< ExtendedCompressorParameter > parameters)
DynamicRangeProcessorEditor(wxWindow *parent, CompressorInstance &instance, bool isRealtime, const EffectUIServices &services, EffectSettingsAccess &access)
virtual const LimiterSettings * GetLimiterSettings() const
void AddTextboxAndSlider(ShuttleGui &S, ExtendedCompressorParameter ¶m)
void AddCheckboxPanel(ShuttleGui &S, const DynamicRangeProcessorSettings &settings)
bool UpdateUI() final override
Update appearance of the panel for changes in settings.
bool ValidateUI() final override
Get settings data from the panel; may make error dialogs and return false.
wxWeakRef< wxWindow > mUIParent
void PopulateOrExchange(ShuttleGui &S)
CompressorInstance & mCompressorInstance
static bool EnableApply(wxWindow *parent, bool enable=true)
Enable or disable the Apply button of the dialog that contains parent.
EffectSettingsAccess & mAccess
void ModifySettings(Function &&function)
Do a correct read-modify-write of settings.
virtual const EffectSettings & Get()=0
CallbackReturn Publish(const EffectSettingChanged &message)
Send a message to connected callbacks.
RulerPanel class allows you to work with a Ruler like any other wxWindow.
std::pair< double, double > Range
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
wxColour & Colour(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
const T * cast() const noexcept
Like pointer-valued any_cast but a non-static member function.
static constexpr auto graphMinHeight
static constexpr auto graphMinRangeDb
constexpr auto transferFunctionPanelId
auto TextToSliderValue(ExtendedCompressorParameter &setting)
auto MapExponentially(double min, double max, double x)
constexpr auto compressionMeterPanelWidth
constexpr auto historyRulerPanelId
constexpr auto compressionMeterRulerPanelId
DynamicRangeProcessorSettings GetSettings(EffectSettingsAccess &access)
float GetDbRange(float maxCompressionDb)
auto MapLogarithmically(double min, double max, double x)
DynamicRangeProcessorTransferFunctionPanel TFPanel
constexpr auto historyPanelId
DynamicRangeProcessorHistoryPanel HistPanel
auto MakeRulerPanel(wxWindow *parent, wxOrientation orientation, float dbRange, int id=wxID_ANY)
constexpr auto compressionMeterPanelId
auto SliderToTextValue(double value, const ExtendedCompressorParameter &setting)
constexpr auto rulerWidth
constexpr auto checkboxId
constexpr auto borderSize
constexpr auto clipIndicatorId
const char * end(const char *str) noexcept
const char * begin(const char *str) noexcept
fastfloat_really_inline void round(adjusted_mantissa &am, callback cb) noexcept
const TranslatableString caption
const bool exponentialSlider
Message sent by EffectEditor when a setting is changed by the user.
Externalized state of a plug-in.
const std::shared_ptr< DynamicRangeProcessorParameter > param
const DynamicRangeProcessorParameterAttributes & attributes
Options & TickColour(const wxColour c)
Options & TicksAtExtremes(bool t)
Options & LabelEdges(bool l)