Audacity 3.2.0
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
DownwardMeterValueProvider Class Reference

#include <DownwardMeterValueProvider.h>

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

Public Member Functions

 DownwardMeterValueProvider (float upperValue=0.f)
 
 ~DownwardMeterValueProvider ()=default
 
void Update (float value, bool alsoFiveSecondMax) override
 
float GetGlobalMax () const override
 
float GetFiveSecMax () const override
 
float GetCurrentMax () const override
 
Direction GetDirection () const override
 
bool IsInvisible () const override
 
- Public Member Functions inherited from MeterValueProvider
virtual ~MeterValueProvider ()=default
 
virtual void Update (float value, bool alsoFiveSecondMax)=0
 
virtual float GetGlobalMax () const =0
 
virtual float GetFiveSecMax () const =0
 
virtual float GetCurrentMax () const =0
 
virtual Direction GetDirection () const =0
 
virtual bool IsInvisible () const =0
 

Private Attributes

const float mUpperValue
 
float mGlobalMin
 
float mCurrentMin
 
float mFiveSecMinState
 
std::vector< std::pair< int, float > > mLastFiveSeconds
 
std::array< float, ringBufferLengthmRingBuffer
 
size_t mRingBufferIndex = 0
 
int mTimerCount = 0
 

Static Private Attributes

static constexpr auto displayDelayMs = 100
 
static constexpr auto ringBufferLength
 

Additional Inherited Members

- Public Types inherited from MeterValueProvider
enum class  Direction { Upwards , Downwards }
 
- Static Public Member Functions inherited from MeterValueProvider
static std::unique_ptr< MeterValueProviderCreate (Direction direction)
 

Detailed Description


Audacity: A Digital Audio Editor

DownwardMeterValueProvider.h

Matthieu Hodgkinson

Definition at line 19 of file DownwardMeterValueProvider.h.

Constructor & Destructor Documentation

◆ DownwardMeterValueProvider()

DownwardMeterValueProvider::DownwardMeterValueProvider ( float  upperValue = 0.f)

Definition at line 24 of file DownwardMeterValueProvider.cpp.

25 : mUpperValue { upperValue }
26 , mGlobalMin { upperValue }
27 , mCurrentMin { upperValue }
28 , mFiveSecMinState { upperValue }
29{
30 mRingBuffer.fill(upperValue);
31}
std::array< float, ringBufferLength > mRingBuffer

References mRingBuffer.

◆ ~DownwardMeterValueProvider()

DownwardMeterValueProvider::~DownwardMeterValueProvider ( )
default

Member Function Documentation

◆ GetCurrentMax()

float DownwardMeterValueProvider::GetCurrentMax ( ) const
overridevirtual

Implements MeterValueProvider.

Definition at line 79 of file DownwardMeterValueProvider.cpp.

80{
81 return mCurrentMin;
82}

References mCurrentMin.

Referenced by UpwardMeterValueProvider::GetCurrentMax().

Here is the caller graph for this function:

◆ GetDirection()

DownwardMeterValueProvider::Direction DownwardMeterValueProvider::GetDirection ( ) const
overridevirtual

◆ GetFiveSecMax()

float DownwardMeterValueProvider::GetFiveSecMax ( ) const
overridevirtual

Implements MeterValueProvider.

Definition at line 74 of file DownwardMeterValueProvider.cpp.

75{
76 return mFiveSecMinState;
77}

References mFiveSecMinState.

Referenced by UpwardMeterValueProvider::GetFiveSecMax().

Here is the caller graph for this function:

◆ GetGlobalMax()

float DownwardMeterValueProvider::GetGlobalMax ( ) const
overridevirtual

Implements MeterValueProvider.

Definition at line 69 of file DownwardMeterValueProvider.cpp.

70{
71 return mGlobalMin;
72}

References mGlobalMin.

Referenced by UpwardMeterValueProvider::GetGlobalMax().

Here is the caller graph for this function:

◆ IsInvisible()

bool DownwardMeterValueProvider::IsInvisible ( ) const
overridevirtual

Implements MeterValueProvider.

Definition at line 90 of file DownwardMeterValueProvider.cpp.

91{
92 return mCurrentMin >= mUpperValue;
93}

References mCurrentMin, and mUpperValue.

Referenced by UpwardMeterValueProvider::IsInvisible().

Here is the caller graph for this function:

◆ Update()

void DownwardMeterValueProvider::Update ( float  value,
bool  alsoFiveSecondMax 
)
overridevirtual

Implements MeterValueProvider.

Definition at line 33 of file DownwardMeterValueProvider.cpp.

34{
36
37 const auto value = mRingBuffer[mRingBufferIndex];
38 mRingBuffer[mRingBufferIndex] = newValue;
40
41 if (value < mCurrentMin)
42 {
43 mCurrentMin = value;
45 }
46 else
48
49 mLastFiveSeconds.emplace_back(mTimerCount, value);
50 while (!mLastFiveSeconds.empty() &&
53
54 if (!mLastFiveSeconds.empty() && alsoFiveSecondMax)
55 {
56 const auto rawMin =
57 std::min_element(
59 [](const auto& a, const auto& b) { return a.second < b.second; })
60 ->second;
61 if (rawMin <= mFiveSecMinState)
62 mFiveSecMinState = rawMin;
63 else
66 }
67}
int min(int a, int b)
static constexpr auto ringBufferLength
std::vector< std::pair< int, float > > mLastFiveSeconds

References anonymous_namespace{DownwardMeterValueProvider.cpp}::decayPerTickDb, anonymous_namespace{DownwardMeterValueProvider.cpp}::maxTickCount, mCurrentMin, mFiveSecMinState, mGlobalMin, min(), mLastFiveSeconds, mRingBuffer, mRingBufferIndex, mTimerCount, mUpperValue, and ringBufferLength.

Referenced by UpwardMeterValueProvider::Update().

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

Member Data Documentation

◆ displayDelayMs

constexpr auto DownwardMeterValueProvider::displayDelayMs = 100
staticconstexprprivate

The display tends to be earlier than the audio playback. We delay the former by (approximately) this amount, for a tighter audiovisual experience.

Definition at line 36 of file DownwardMeterValueProvider.h.

◆ mCurrentMin

float DownwardMeterValueProvider::mCurrentMin
private

Definition at line 42 of file DownwardMeterValueProvider.h.

Referenced by GetCurrentMax(), IsInvisible(), and Update().

◆ mFiveSecMinState

float DownwardMeterValueProvider::mFiveSecMinState
private

Definition at line 43 of file DownwardMeterValueProvider.h.

Referenced by GetFiveSecMax(), and Update().

◆ mGlobalMin

float DownwardMeterValueProvider::mGlobalMin
private

Definition at line 41 of file DownwardMeterValueProvider.h.

Referenced by GetGlobalMax(), and Update().

◆ mLastFiveSeconds

std::vector<std::pair<int , float> > DownwardMeterValueProvider::mLastFiveSeconds
private

Definition at line 44 of file DownwardMeterValueProvider.h.

Referenced by Update().

◆ mRingBuffer

std::array<float, ringBufferLength> DownwardMeterValueProvider::mRingBuffer
private

Definition at line 45 of file DownwardMeterValueProvider.h.

Referenced by DownwardMeterValueProvider(), and Update().

◆ mRingBufferIndex

size_t DownwardMeterValueProvider::mRingBufferIndex = 0
private

Definition at line 46 of file DownwardMeterValueProvider.h.

Referenced by Update().

◆ mTimerCount

int DownwardMeterValueProvider::mTimerCount = 0
private

Definition at line 47 of file DownwardMeterValueProvider.h.

Referenced by Update().

◆ mUpperValue

const float DownwardMeterValueProvider::mUpperValue
private

Definition at line 40 of file DownwardMeterValueProvider.h.

Referenced by IsInvisible(), and Update().

◆ ringBufferLength

constexpr auto DownwardMeterValueProvider::ringBufferLength
staticconstexprprivate
Initial value:
=
static constexpr auto compressorMeterUpdatePeriodMs

Definition at line 37 of file DownwardMeterValueProvider.h.

Referenced by Update().


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