17#include <wx/dcclient.h>
18#include <wx/graphics.h>
40 std::function<
void()> onClipped)
42 , mMeterValuesQueue { std::make_unique<
44 , mPlaybackStartStopSubscription {
static_cast<
48 [&](
const std::optional<
65 , mOnClipped { onClipped }
66 , mDbBottomEdgeValue { -dbRange }
72 if (instance.GetSampleRate().has_value())
76 instance.SetMeterValuesQueue(mMeterValuesQueue);
78 SetDoubleBuffered(
true);
111 const auto left = rect.GetLeft();
112 const auto top = rect.GetTop();
113 const auto width = rect.GetWidth();
114 const auto height = rect.GetHeight();
116 gc->SetPen(*wxTRANSPARENT_PEN);
118 gc->DrawRectangle(left, top, width, height);
120 auto leftRect = rect;
121 leftRect.SetWidth(rect.GetWidth() / 2 - 2);
122 leftRect.Offset(1, 0);
125 auto rightRect = leftRect;
126 rightRect.Offset(leftRect.GetWidth(), 0);
130 gc->SetBrush(wxNullBrush);
131 gc->DrawRectangle(left, top, width, height);
135 wxPaintDC& dc,
const wxColor& color,
const wxRect& rect,
141 const auto downwards =
146 const double left = rect.GetLeft();
147 const double top = rect.GetTop();
148 const double width = rect.GetWidth();
149 const double height = rect.GetHeight();
151 constexpr auto lineWidth = 6.;
155 const auto yAdjust = lineWidth / 2 * (downwards ? -1 : 1);
156 const double dbY = height * dbFrac + yAdjust;
158 const double fiveSecMaxDbY =
161 const auto levelTop = downwards ? top : dbY;
162 const auto levelHeight = downwards ? dbY : height - dbY;
163 const auto maxLevelTop = downwards ? levelHeight - top : maxDbY;
164 const auto maxLevelHeight = std::abs(maxDbY - dbY);
166 const auto rectLeft = left + 3;
167 const auto rectWidth = width - 4;
168 const auto opaqueColor = wxColor { color.GetRGB() };
169 gc->SetBrush(
GetColorMix(opaqueColor, wxTransparentColor, 0.8));
170 gc->DrawRectangle(rectLeft, levelTop, rectWidth, levelHeight);
171 gc->SetBrush(
GetColorMix(opaqueColor, wxTransparentColor, 0.6));
172 gc->DrawRectangle(rectLeft, maxLevelTop, rectWidth, maxLevelHeight);
173 gc->SetBrush(opaqueColor);
174 gc->DrawRectangle(rectLeft, dbY - 2, rectWidth, lineWidth);
175 gc->DrawRectangle(rectLeft, maxDbY - 2, rectWidth, lineWidth);
176 gc->SetPen({ opaqueColor,
static_cast<int>(lineWidth / 2) });
178 left + rectWidth / 2, fiveSecMaxDbY, left + rectWidth, fiveSecMaxDbY);
186 auto lowestCompressionGain = 0.f;
187 auto highestOutputGain = std::numeric_limits<float>::lowest();
190 lowestCompressionGain =
192 highestOutputGain = std::max(
values.outputDb, highestOutputGain);
197 mOutputMeter->Update(highestOutputGain, updateFiveSecondMax);
static constexpr auto compressorMeterUpdatePeriodMs
bool AcceptsFocus() const override
const std::function< void()> mOnClipped
void SetDbRange(float dbRange)
std::unique_ptr< MeterValueProvider > mCompressionMeter
void OnTimer(wxTimerEvent &evt)
void PaintMeter(wxPaintDC &dc, const wxColor &color, const wxRect &rect, const MeterValueProvider &provider)
void OnPaint(wxPaintEvent &evt)
std::unique_ptr< MeterValueProvider > mOutputMeter
bool AcceptsFocusFromKeyboard() const override
const std::shared_ptr< DynamicRangeProcessorMeterValuesQueue > mMeterValuesQueue
virtual float GetCurrentMax() const =0
virtual float GetGlobalMax() const =0
static std::unique_ptr< MeterValueProvider > Create(Direction direction)
virtual float GetFiveSecMax() const =0
virtual Direction GetDirection() const =0
An object that sends messages to an open-ended list of subscribed callbacks.
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
wxColor GetColorMix(const wxColor &a, const wxColor &b, double aWeight)
static const wxColour actualCompressionColor
std::unique_ptr< wxGraphicsContext > MakeGraphicsContext(const wxPaintDC &dc)
wxRect GetPanelRect(const wxPanelWrapper &panel)
static const wxColour lineColor
wxGraphicsBrush GetGraphBackgroundBrush(wxGraphicsContext &gc, int height)
static const wxColour outputColor
constexpr auto ticksPerSec
constexpr auto audioFramePerSec
constexpr auto audioFramesPerTick
enum AudioIOEvent::Type type