Audacity 3.2.0
MeterPanelBase.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5MeterPanelBase.cpp
6
7Paul Licameli split from MeterPanel.cpp
8
9**********************************************************************/
10
11#include "MeterPanelBase.h"
12#include "Meter.h"
13#include <wx/weakref.h>
14
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
85std::shared_ptr<Meter> MeterPanelBase::GetMeter() const
86{
87 return mForwarder;
88}
AudioIO uses this to send sample buffers for real-time display updates.
Definition: Meter.h:16
Inherits wxPanel and has a Meter; exposes shared_ptr to the Meter.
std::shared_ptr< Meter > GetMeter() const
std::shared_ptr< Forwarder > mForwarder
~MeterPanelBase() override
static bool s_AcceptsFocus
static TempAllowFocus TemporarilyAllowFocus()
std::unique_ptr< bool, Resetter > TempAllowFocus
bool IsClipping() const override
Forwarder(MeterPanelBase *pOwner)
float GetMaxPeak() const override
const wxWeakRef< MeterPanelBase > mOwner
int GetDBRange() const override
void UpdateDisplay(unsigned numChannels, unsigned long numFrames, const float *sampleData) override
bool IsMeterDisabled() const override
void Reset(double sampleRate, bool resetClipping) override