From ac277c61d7ec16e6c3b0a34a42f2988db81e06fe Mon Sep 17 00:00:00 2001 From: Max Maisel Date: Sat, 15 Feb 2020 14:52:55 +0100 Subject: [PATCH] Add gain and step response plot to Compressor2 effect GUI. Signed-off-by: Max Maisel --- src/effects/Compressor2.cpp | 47 +++++++++++++++++++++++++++++++++++++ src/effects/Compressor2.h | 3 +++ 2 files changed, 50 insertions(+) diff --git a/src/effects/Compressor2.cpp b/src/effects/Compressor2.cpp index 3130ca6f2..345029cb5 100644 --- a/src/effects/Compressor2.cpp +++ b/src/effects/Compressor2.cpp @@ -22,6 +22,7 @@ #include #include +#include "../AColor.h" #include "../Internat.h" #include "../Prefs.h" #include "../ProjectFileManager.h" @@ -29,7 +30,9 @@ #include "../ShuttleGui.h" #include "../WaveTrack.h" #include "../widgets/valnum.h" +#include "../widgets/Plot.h" #include "../widgets/ProgressDialog.h" +#include "../widgets/Ruler.h" #include "../widgets/SliderTextCtrl.h" #include "LoadEffects.h" @@ -254,6 +257,40 @@ bool EffectCompressor2::Process() void EffectCompressor2::PopulateOrExchange(ShuttleGui & S) { + S.SetBorder(10); + + S.StartHorizontalLay(wxEXPAND, true); + { + PlotData* plot; + + mGainPlot = S.MinSize( { 200, 200 } ) + .AddPlot({}, -60, 0, -60, 0, XO("dB"), XO("dB"), + Ruler::LinearDBFormat, Ruler::LinearDBFormat); + + plot = mGainPlot->GetPlotData(0); + plot->pen = std::unique_ptr( + safenew wxPen(AColor::WideEnvelopePen)); + + mResponsePlot = S.MinSize( { 200, 200 } ) + .AddPlot({}, 0, 5, -0.2, 1.2, XO("s"), XO(""), + Ruler::IntFormat, Ruler::RealFormat, 2); + + plot = mResponsePlot->GetPlotData(0); + plot->pen = std::unique_ptr( + safenew wxPen(AColor::WideEnvelopePen)); + plot->xdata = {0, 2, 2, 3, 3, 5}; + plot->ydata = {0, 0, 1, 1, 0, 0}; + + plot = mResponsePlot->GetPlotData(1); + plot->pen = std::unique_ptr( + safenew wxPen(AColor::WideEnvelopePen)); + plot->pen->SetColour(wxColor( 230,80,80 )); // Same color as TrackArtist RMS red. + plot->pen->SetWidth(2); + } + S.EndHorizontalLay(); + + S.SetBorder(5); + S.StartStatic(XO("Algorithm")); { S.StartMultiColumn(2, wxALIGN_LEFT); @@ -437,4 +474,14 @@ void EffectCompressor2::OnUpdateUI(wxCommandEvent & WXUNUSED(evt)) void EffectCompressor2::UpdateUI() { + PlotData* plot; + plot = mGainPlot->GetPlotData(0); + plot->xdata = {-60, -40, 0}; + plot->ydata = {-60, -40, -20}; + mGainPlot->Refresh(false); + + plot = mResponsePlot->GetPlotData(1); + plot->xdata = {0, 2, 2, 3, 3, 5}; + plot->ydata = {0, 0.5, 1, 1, 0.5, 0}; + mResponsePlot->Refresh(false); } diff --git a/src/effects/Compressor2.h b/src/effects/Compressor2.h index 1c9f11f89..eb8f0906f 100644 --- a/src/effects/Compressor2.h +++ b/src/effects/Compressor2.h @@ -20,6 +20,7 @@ #include "Effect.h" +class Plot; class ShuttleGui; class EffectCompressor2 final : public Effect @@ -77,6 +78,8 @@ private: double mMakeupGainPct; double mDryWetPct; + Plot* mGainPlot; + Plot* mResponsePlot; bool mIgnoreGuiEvents; DECLARE_EVENT_TABLE()