Audacity  3.0.3
MeterPanelBase.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 MeterPanelBase.cpp
6 
7 Paul Licameli split from MeterPanel.cpp
8 
9 **********************************************************************/
10 
11 #include "MeterPanelBase.h"
12 #include "Meter.h"
13 #include <wx/weakref.h>
14 
15 bool MeterPanelBase::s_AcceptsFocus{ false };
16 
18  s_AcceptsFocus = true;
19  return TempAllowFocus{ &s_AcceptsFocus };
20 }
21 
23 {
24  explicit Forwarder( MeterPanelBase *pOwner )
25  : mOwner{ pOwner } {}
26  ~Forwarder() override {}
27 
28  void Clear() override
29  {
30  if (mOwner)
31  mOwner->Clear();
32  }
33  void Reset(double sampleRate, bool resetClipping) override
34  {
35  if (mOwner)
36  mOwner->Reset( sampleRate, resetClipping );
37  }
38  void UpdateDisplay(unsigned numChannels,
39  unsigned long numFrames, const float *sampleData) override
40  {
41  if (mOwner)
42  mOwner->UpdateDisplay( numChannels, numFrames, sampleData );
43  }
44  bool IsMeterDisabled() const override
45  {
46  if (mOwner)
47  return mOwner->IsMeterDisabled();
48  else
49  return true;
50  }
51  float GetMaxPeak() const override
52  {
53  if (mOwner)
54  return mOwner->GetMaxPeak();
55  else
56  return 0.0;
57  }
58 
59  bool IsClipping() const override
60  {
61  if (mOwner)
62  return mOwner->IsClipping();
63  else
64  return false;
65  }
66 
67  int GetDBRange() const override
68  {
69  if (mOwner)
70  return mOwner->GetDBRange();
71  else
72  return 0.0;
73  }
74 
75  const wxWeakRef< MeterPanelBase > mOwner;
76 };
77 
79 
81 {
82  mForwarder = std::make_shared< Forwarder >( this );
83 }
84 
85 std::shared_ptr<Meter> MeterPanelBase::GetMeter() const
86 {
87  return mForwarder;
88 }
MeterPanelBase::s_AcceptsFocus
static bool s_AcceptsFocus
Definition: MeterPanelBase.h:49
MeterPanelBase::Forwarder::GetDBRange
int GetDBRange() const override
Definition: MeterPanelBase.cpp:67
Meter
AudioIO uses this to send sample buffers for real-time display updates.
Definition: Meter.h:16
MeterPanelBase
Inherits wxPanel and has a Meter; exposes shared_ptr to the Meter.
Definition: MeterPanelBase.h:27
MeterPanelBase::Init
void Init()
Definition: MeterPanelBase.cpp:80
Meter.h
MeterPanelBase::Forwarder::~Forwarder
~Forwarder() override
Definition: MeterPanelBase.cpp:26
MeterPanelBase::Forwarder::IsMeterDisabled
bool IsMeterDisabled() const override
Definition: MeterPanelBase.cpp:44
MeterPanelBase::Forwarder::Forwarder
Forwarder(MeterPanelBase *pOwner)
Definition: MeterPanelBase.cpp:24
MeterPanelBase::GetMeter
std::shared_ptr< Meter > GetMeter() const
Definition: MeterPanelBase.cpp:85
MeterPanelBase::TemporarilyAllowFocus
static TempAllowFocus TemporarilyAllowFocus()
Definition: MeterPanelBase.cpp:17
MeterPanelBase::Forwarder::Clear
void Clear() override
Definition: MeterPanelBase.cpp:28
MeterPanelBase::TempAllowFocus
std::unique_ptr< bool, Resetter > TempAllowFocus
Definition: MeterPanelBase.h:51
MeterPanelBase::Forwarder::IsClipping
bool IsClipping() const override
Definition: MeterPanelBase.cpp:59
MeterPanelBase::Forwarder::mOwner
const wxWeakRef< MeterPanelBase > mOwner
Definition: MeterPanelBase.cpp:75
MeterPanelBase::Forwarder::UpdateDisplay
void UpdateDisplay(unsigned numChannels, unsigned long numFrames, const float *sampleData) override
Definition: MeterPanelBase.cpp:38
MeterPanelBase.h
MeterPanelBase::Forwarder
Definition: MeterPanelBase.cpp:23
MeterPanelBase::mForwarder
std::shared_ptr< Forwarder > mForwarder
Definition: MeterPanelBase.h:62
MeterPanelBase::~MeterPanelBase
~MeterPanelBase() override
MeterPanelBase::Forwarder::Reset
void Reset(double sampleRate, bool resetClipping) override
Definition: MeterPanelBase.cpp:33
MeterPanelBase::Forwarder::GetMaxPeak
float GetMaxPeak() const override
Definition: MeterPanelBase.cpp:51