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

#include <Compressor.h>

Inheritance diagram for EffectCompressorPanel:
wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 EffectCompressorPanel (wxWindow *parent, 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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 ~wxTabTraversalWrapper ()
 

Private Member Functions

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

Private Attributes

double & threshold
 
double & noiseFloor
 
double & ratio
 

Detailed Description

Definition at line 138 of file Compressor.h.

Constructor & Destructor Documentation

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

Definition at line 647 of file Compressor.cpp.

651 : wxPanelWrapper(parent),
654  ratio(ratio)
655 {
656 }

Member Function Documentation

void EffectCompressorPanel::OnPaint ( wxPaintEvent &  evt)
private

Definition at line 658 of file Compressor.cpp.

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, and AColor::WideEnvelopePen.

659 {
660  wxPaintDC dc(this);
661 
662  int width, height;
663  GetSize(&width, &height);
664 
665  double rangeDB = 60;
666 
667  // Ruler
668  int w = 0;
669  int h = 0;
670 
671  Ruler vRuler;
672  vRuler.SetBounds(0, 0, width, height);
673  vRuler.SetOrientation(wxVERTICAL);
674  vRuler.SetRange(0, -rangeDB);
676  vRuler.SetUnits(_("dB"));
677  vRuler.GetMaxSize(&w, NULL);
678 
679  Ruler hRuler;
680  hRuler.SetBounds(0, 0, width, height);
681  hRuler.SetOrientation(wxHORIZONTAL);
682  hRuler.SetRange(-rangeDB, 0);
684  hRuler.SetUnits(_("dB"));
685  hRuler.SetFlip(true);
686  hRuler.GetMaxSize(NULL, &h);
687 
688  vRuler.SetBounds(0, 0, w, height - h);
689  hRuler.SetBounds(w, height - h, width, height);
690 
691  vRuler.SetTickColour( theTheme.Colour( clrGraphLabels ));
692  hRuler.SetTickColour( theTheme.Colour( clrGraphLabels ));
693 
694 #if defined(__WXMSW__)
695  dc.Clear();
696 #endif
697 
698  wxRect border;
699  border.x = w;
700  border.y = 0;
701  border.width = width - w;
702  border.height = height - h + 1;
703 
704  dc.SetBrush(*wxWHITE_BRUSH);
705  dc.SetPen(*wxBLACK_PEN);
706  dc.DrawRectangle(border);
707 
708  wxRect envRect = border;
709  envRect.Deflate( 2, 2 );
710 
711  int kneeX = lrint((rangeDB+threshold)*envRect.width/rangeDB);
712  int kneeY = lrint((rangeDB+threshold/ratio)*envRect.height/rangeDB);
713 
714  int finalY = envRect.height;
715  int startY = lrint((threshold*(1.0/ratio-1.0))*envRect.height/rangeDB);
716 
717  // Yellow line for threshold
718 /* dc.SetPen(wxPen(wxColour(220, 220, 0), 1, wxSOLID));
719  AColor::Line(dc,
720  envRect.x,
721  envRect.y + envRect.height - kneeY,
722  envRect.x + envRect.width - 1,
723  envRect.y + envRect.height - kneeY);*/
724 
725  // Was: Nice dark red line for the compression diagram
726 // dc.SetPen(wxPen(wxColour(180, 40, 40), 3, wxSOLID));
727 
728  // Nice blue line for compressor, same color as used in the waveform envelope.
729  dc.SetPen( AColor::WideEnvelopePen) ;
730 
731  AColor::Line(dc,
732  envRect.x,
733  envRect.y + envRect.height - startY,
734  envRect.x + kneeX - 1,
735  envRect.y + envRect.height - kneeY);
736 
737  AColor::Line(dc,
738  envRect.x + kneeX,
739  envRect.y + envRect.height - kneeY,
740  envRect.x + envRect.width - 1,
741  envRect.y + envRect.height - finalY);
742 
743  // Paint border again
744  dc.SetBrush(*wxTRANSPARENT_BRUSH);
745  dc.SetPen(*wxBLACK_PEN);
746  dc.DrawRectangle(border);
747 
748  vRuler.Draw(dc);
749  hRuler.Draw(dc);
750 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1307
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:215
void SetBounds(int left, int top, int right, int bottom)
Definition: Ruler.cpp:356
void GetMaxSize(wxCoord *width, wxCoord *height)
Definition: Ruler.cpp:1533
void SetOrientation(int orient)
Definition: Ruler.cpp:220
#define lrint(dbl)
Definition: float_cast.h:136
void SetFlip(bool flip)
Definition: Ruler.cpp:285
void SetUnits(const wxString &units)
Definition: Ruler.cpp:208
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:122
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
void SetFormat(RulerFormat format)
Definition: Ruler.cpp:186
void SetRange(double min, double max)
Definition: Ruler.cpp:234
Used to display a Ruler.
Definition: Ruler.h:32
void SetTickColour(const wxColour &colour)
Definition: Ruler.h:150
static wxPen WideEnvelopePen
Definition: AColor.h:123
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1214
void EffectCompressorPanel::OnSize ( wxSizeEvent &  evt)
private

Definition at line 752 of file Compressor.cpp.

753 {
754  Refresh(false);
755 }

Member Data Documentation

double& EffectCompressorPanel::noiseFloor
private

Definition at line 152 of file Compressor.h.

double& EffectCompressorPanel::ratio
private

Definition at line 153 of file Compressor.h.

Referenced by OnPaint().

double& EffectCompressorPanel::threshold
private

Definition at line 151 of file Compressor.h.

Referenced by OnPaint().


The documentation for this class was generated from the following files: