Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EffectCompressorPanel Class Referencefinal

#include <Compressor.h>

Inheritance diagram for EffectCompressorPanel:
[legend]
Collaboration diagram for EffectCompressorPanel:
[legend]

Public Member Functions

 EffectCompressorPanel (wxWindow *parent, wxWindowID winid, double &threshold, double &noiseFloor, double &ratio)
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void OnPaint (wxPaintEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 

Private Attributes

double & threshold
 
double & noiseFloor
 
double & ratio
 

Detailed Description

Definition at line 130 of file Compressor.h.

Constructor & Destructor Documentation

◆ EffectCompressorPanel()

EffectCompressorPanel::EffectCompressorPanel ( wxWindow *  parent,
wxWindowID  winid,
double &  threshold,
double &  noiseFloor,
double &  ratio 
)

Definition at line 707 of file Compressor.cpp.

711 : wxPanelWrapper(parent, winid),
714  ratio(ratio)
715 {
716 }

Member Function Documentation

◆ OnPaint()

void EffectCompressorPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 718 of file Compressor.cpp.

719 {
720  wxPaintDC dc(this);
721 
722  int width, height;
723  GetSize(&width, &height);
724 
725  double rangeDB = 60;
726 
727  // Ruler
728  int w = 0;
729  int h = 0;
730 
731  Ruler vRuler;
732  vRuler.SetBounds(0, 0, width, height);
733  vRuler.SetOrientation(wxVERTICAL);
734  vRuler.SetRange(0, -rangeDB);
736  vRuler.SetUnits(XO("dB"));
737  vRuler.GetMaxSize(&w, NULL);
738 
739  Ruler hRuler;
740  hRuler.SetBounds(0, 0, width, height);
741  hRuler.SetOrientation(wxHORIZONTAL);
742  hRuler.SetRange(-rangeDB, 0);
744  hRuler.SetUnits(XO("dB"));
745  hRuler.SetFlip(true);
746  hRuler.GetMaxSize(NULL, &h);
747 
748  vRuler.SetBounds(0, 0, w, height - h);
749  hRuler.SetBounds(w, height - h, width, height);
750 
751  vRuler.SetTickColour( theTheme.Colour( clrGraphLabels ));
752  hRuler.SetTickColour( theTheme.Colour( clrGraphLabels ));
753 
754 #if defined(__WXMSW__)
755  dc.Clear();
756 #endif
757 
758  wxRect border;
759  border.x = w;
760  border.y = 0;
761  border.width = width - w;
762  border.height = height - h + 1;
763 
764  dc.SetBrush(*wxWHITE_BRUSH);
765  dc.SetPen(*wxBLACK_PEN);
766  dc.DrawRectangle(border);
767 
768  wxRect envRect = border;
769  envRect.Deflate( 2, 2 );
770 
771  int kneeX = lrint((rangeDB+threshold)*envRect.width/rangeDB);
772  int kneeY = lrint((rangeDB+threshold/ratio)*envRect.height/rangeDB);
773 
774  int finalY = envRect.height;
775  int startY = lrint((threshold*(1.0/ratio-1.0))*envRect.height/rangeDB);
776 
777  // Yellow line for threshold
778 /* dc.SetPen(wxPen(wxColour(220, 220, 0), 1, wxSOLID));
779  AColor::Line(dc,
780  envRect.x,
781  envRect.y + envRect.height - kneeY,
782  envRect.x + envRect.width - 1,
783  envRect.y + envRect.height - kneeY);*/
784 
785  // Was: Nice dark red line for the compression diagram
786 // dc.SetPen(wxPen(wxColour(180, 40, 40), 3, wxSOLID));
787 
788  // Nice blue line for compressor, same color as used in the waveform envelope.
789  dc.SetPen( AColor::WideEnvelopePen) ;
790 
791  AColor::Line(dc,
792  envRect.x,
793  envRect.y + envRect.height - startY,
794  envRect.x + kneeX - 1,
795  envRect.y + envRect.height - kneeY);
796 
797  AColor::Line(dc,
798  envRect.x + kneeX,
799  envRect.y + envRect.height - kneeY,
800  envRect.x + envRect.width - 1,
801  envRect.y + envRect.height - finalY);
802 
803  // Paint border again
804  dc.SetBrush(*wxTRANSPARENT_BRUSH);
805  dc.SetPen(*wxBLACK_PEN);
806  dc.DrawRectangle(border);
807 
808  vRuler.Draw(dc);
809  hRuler.Draw(dc);
810 }

References ThemeBase::Colour(), Ruler::Draw(), Ruler::GetMaxSize(), AColor::Line(), Ruler::LinearDBFormat, lrint, ratio, Ruler::SetBounds(), Ruler::SetFlip(), Ruler::SetFormat(), Ruler::SetOrientation(), Ruler::SetRange(), Ruler::SetTickColour(), Ruler::SetUnits(), theTheme, threshold, AColor::WideEnvelopePen, and XO.

Here is the call graph for this function:

◆ OnSize()

void EffectCompressorPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 812 of file Compressor.cpp.

813 {
814  Refresh(false);
815 }

Member Data Documentation

◆ noiseFloor

double& EffectCompressorPanel::noiseFloor
private

Definition at line 144 of file Compressor.h.

◆ ratio

double& EffectCompressorPanel::ratio
private

Definition at line 145 of file Compressor.h.

Referenced by OnPaint().

◆ threshold

double& EffectCompressorPanel::threshold
private

Definition at line 143 of file Compressor.h.

Referenced by OnPaint().


The documentation for this class was generated from the following files:
Ruler::LinearDBFormat
@ LinearDBFormat
Definition: Ruler.h:34
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
XO
#define XO(s)
Definition: Internat.h:31
Ruler::SetTickColour
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:148
Ruler::SetFormat
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:131
Ruler::Draw
void Draw(wxDC &dc) const
Definition: Ruler.cpp:1428
Ruler::SetUnits
void SetUnits(const TranslatableString &units)
Definition: Ruler.cpp:153
Ruler::SetFlip
void SetFlip(bool flip)
Definition: Ruler.cpp:239
Ruler::GetMaxSize
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1603
EffectCompressorPanel::noiseFloor
double & noiseFloor
Definition: Compressor.h:144
Ruler
Used to display a Ruler.
Definition: Ruler.h:26
AColor::WideEnvelopePen
static wxPen WideEnvelopePen
Definition: AColor.h:105
Ruler::SetRange
void SetRange(double min, double max)
Definition: Ruler.cpp:188
Ruler::SetOrientation
void SetOrientation(int orient)
Definition: Ruler.cpp:174
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
Ruler::SetBounds
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:332
wxPanelWrapper::wxPanelWrapper
wxPanelWrapper()
Definition: wxPanelWrapper.h:44
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
EffectCompressorPanel::ratio
double & ratio
Definition: Compressor.h:145
EffectCompressorPanel::threshold
double & threshold
Definition: Compressor.h:143
lrint
#define lrint(dbl)
Definition: float_cast.h:169