Audacity 3.2.0
Functions
anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp} Namespace Reference

Functions

constexpr auto WidthPxToDb (double x, int width, double xPixelsPerDb)
 
constexpr auto WidthDbToPx (double db, int width, double xPixelsPerDb)
 
constexpr auto HeightDbToPx (double db, double yPixelsPerDb)
 
auto GetBrush (double kneeX, double kneeY, const wxColor &colorAtKnee, const wxSize &size, const wxGraphicsContext &gc)
 
void DrawTransferFunction (wxPaintDC &dc, const wxRect &rect, const CompressorSettings &settings)
 

Function Documentation

◆ DrawTransferFunction()

void anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp}::DrawTransferFunction ( wxPaintDC &  dc,
const wxRect &  rect,
const CompressorSettings settings 
)

Definition at line 71 of file DynamicRangeProcessorTransferFunctionPanel.cpp.

73{
74 const auto X = rect.GetWidth();
75 const auto Y = rect.GetHeight();
76 const auto xPixelsPerDb =
78 const auto yPixelsPerDb =
80
81 std::vector<wxPoint2DDouble> points;
82 points.reserve(X);
83 for (int x = rect.GetX(); x < X; ++x)
84 {
85 const auto db = WidthPxToDb(x, X, xPixelsPerDb);
86 const auto y = HeightDbToPx(
88 yPixelsPerDb);
89 points.emplace_back(x, y);
90 }
91
92 using namespace DynamicRangeProcessorPanel;
93
94 const auto gc = MakeGraphicsContext(dc);
95
96 const auto kneeX = WidthDbToPx(settings.thresholdDb, X, xPixelsPerDb);
97 const auto kneeY =
98 HeightDbToPx(settings.thresholdDb + settings.makeupGainDb, yPixelsPerDb);
99
100 // Fill the area above the curve
101 wxGraphicsPath path = gc->CreatePath();
102 path.MoveToPoint(X, 0);
103 path.AddLineToPoint(0, 0);
104 std::for_each(points.begin(), points.end(), [&path](const auto& point) {
105 path.AddLineToPoint(point);
106 });
107 path.CloseSubpath();
108 gc->SetBrush(GetBrush(kneeX, kneeY, attackColor, rect.GetSize(), *gc));
109 gc->FillPath(path);
110
111 // Fill the area below the curve
112 path = gc->CreatePath();
113 path.MoveToPoint(X, Y);
114 path.AddLineToPoint(0, Y);
115 std::for_each(points.begin(), points.end(), [&path](const auto& point) {
116 path.AddLineToPoint(point);
117 });
118 path.CloseSubpath();
119 gc->SetBrush(GetBrush(kneeX, kneeY, releaseColor, rect.GetSize(), *gc));
120 gc->FillPath(path);
121
122 // Draw the curve
123 const auto gc2 = MakeGraphicsContext(dc);
125 gc2->DrawLines(points.size(), points.data());
126}
static Settings & settings()
Definition: TrackInfo.cpp:51
static float EvaluateTransferFunction(const DynamicRangeProcessorSettings &settings, float inputDb)
std::unique_ptr< wxGraphicsContext > MakeGraphicsContext(const wxPaintDC &dc)
auto GetBrush(double kneeX, double kneeY, const wxColor &colorAtKnee, const wxSize &size, const wxGraphicsContext &gc)

References DynamicRangeProcessorPanel::attackColor, CompressorProcessor::EvaluateTransferFunction(), GetBrush(), HeightDbToPx(), DynamicRangeProcessorPanel::MakeGraphicsContext(), DynamicRangeProcessorTransferFunctionPanel::rangeDb, DynamicRangeProcessorPanel::releaseColor, settings(), DynamicRangeProcessorPanel::targetCompressionColor, DynamicRangeProcessorPanel::targetCompressionLineWidth, WidthDbToPx(), and WidthPxToDb().

Referenced by DynamicRangeProcessorTransferFunctionPanel::OnPaint().

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

◆ GetBrush()

auto anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp}::GetBrush ( double  kneeX,
double  kneeY,
const wxColor &  colorAtKnee,
const wxSize &  size,
const wxGraphicsContext &  gc 
)

Definition at line 56 of file DynamicRangeProcessorTransferFunctionPanel.cpp.

59{
60 using namespace DynamicRangeProcessorPanel;
61 constexpr auto w = .75;
62 const wxColor edgeColor = GetColorMix(backgroundColor, colorAtKnee, w);
63
64 const auto xf = size.GetWidth() / 2.; // "f" for "focus"
65 const auto yf = size.GetHeight() / 2.;
66 const auto radius = size.GetWidth();
67 return gc.CreateRadialGradientBrush(
68 kneeX, kneeY, xf, yf, radius, colorAtKnee, edgeColor);
69}
wxColor GetColorMix(const wxColor &a, const wxColor &b, double aWeight)

References DynamicRangeProcessorPanel::backgroundColor, DynamicRangeProcessorPanel::GetColorMix(), and size.

Referenced by DrawTransferFunction().

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

◆ HeightDbToPx()

constexpr auto anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp}::HeightDbToPx ( double  db,
double  yPixelsPerDb 
)
constexpr

Definition at line 51 of file DynamicRangeProcessorTransferFunctionPanel.cpp.

52{
53 return -db * yPixelsPerDb;
54}

Referenced by DrawTransferFunction().

Here is the caller graph for this function:

◆ WidthDbToPx()

constexpr auto anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp}::WidthDbToPx ( double  db,
int  width,
double  xPixelsPerDb 
)
constexpr

Definition at line 46 of file DynamicRangeProcessorTransferFunctionPanel.cpp.

47{
48 return width - 1 + db * xPixelsPerDb;
49}

Referenced by DrawTransferFunction().

Here is the caller graph for this function:

◆ WidthPxToDb()

constexpr auto anonymous_namespace{DynamicRangeProcessorTransferFunctionPanel.cpp}::WidthPxToDb ( double  x,
int  width,
double  xPixelsPerDb 
)
constexpr

Definition at line 41 of file DynamicRangeProcessorTransferFunctionPanel.cpp.

42{
43 return (x + 1 - width) / xPixelsPerDb;
44}

Referenced by DrawTransferFunction().

Here is the caller graph for this function: