Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
WaveformSettings Class Reference

Waveform settings, either for one track or as defaults. More...

#include <WaveformSettings.h>

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

Classes

class  Globals
 

Public Types

enum  ScaleTypeValues : int { stLinear , stLogarithmic , stNumScaleTypes }
 
typedef int ScaleType
 

Public Member Functions

 WaveformSettings ()
 
 WaveformSettings (const WaveformSettings &other)
 
WaveformSettingsoperator= (const WaveformSettings &other)
 
 ~WaveformSettings ()
 
bool IsDefault () const
 
bool Validate (bool quiet)
 
void LoadPrefs ()
 
void SavePrefs ()
 
void Update ()
 
void UpdatePrefs () override
 
void ConvertToEnumeratedDBRange ()
 
void ConvertToActualDBRange ()
 
void NextLowerDBRange ()
 
void NextHigherDBRange ()
 
bool isLinear () const
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 

Static Public Member Functions

static WaveformSettingsdefaults ()
 
static const EnumValueSymbolsGetScaleNames ()
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Public Attributes

ScaleType scaleType
 
int dBRange
 

Additional Inherited Members

- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 

Detailed Description

Waveform settings, either for one track or as defaults.

Definition at line 18 of file WaveformSettings.h.

Member Typedef Documentation

◆ ScaleType

Definition at line 57 of file WaveformSettings.h.

Member Enumeration Documentation

◆ ScaleTypeValues

Enumerator
stLinear 
stLogarithmic 
stNumScaleTypes 

Definition at line 58 of file WaveformSettings.h.

Constructor & Destructor Documentation

◆ WaveformSettings() [1/2]

WaveformSettings::WaveformSettings ( )

Definition at line 49 of file WaveformSettings.cpp.

50{
51 LoadPrefs();
52}

References LoadPrefs().

Here is the call graph for this function:

◆ WaveformSettings() [2/2]

WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 54 of file WaveformSettings.cpp.

55 : scaleType(other.scaleType)
56 , dBRange(other.dBRange)
57{
58}

◆ ~WaveformSettings()

WaveformSettings::~WaveformSettings ( )

Definition at line 172 of file WaveformSettings.cpp.

173{
174}

Member Function Documentation

◆ ConvertToActualDBRange()

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 137 of file WaveformSettings.cpp.

138{
139 wxArrayStringEx codes;
140 GUIPrefs::GetRangeChoices(nullptr, &codes);
141 long value = 0;
142 codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
143 .ToLong(&value);
144 dBRange = (int)(value);
145}
int min(int a, int b)
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:63
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References dBRange, GUIPrefs::GetRangeChoices(), and min().

Referenced by WaveformPrefs::Commit(), NextHigherDBRange(), NextLowerDBRange(), WaveformPrefs::Validate(), and Validate().

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

◆ ConvertToEnumeratedDBRange()

void WaveformSettings::ConvertToEnumeratedDBRange ( )

Definition at line 122 of file WaveformSettings.cpp.

123{
124 // Assumes the codes are in ascending sequence.
125 wxArrayStringEx codes;
126 GUIPrefs::GetRangeChoices(nullptr, &codes);
127 int ii = 0;
128 for (int nn = codes.size(); ii < nn; ++ii) {
129 long value = 0;
130 codes[ii].ToLong(&value);
131 if (dBRange < value)
132 break;
133 }
134 dBRange = std::max(0, ii - 1);
135}

References dBRange, and GUIPrefs::GetRangeChoices().

Referenced by WaveformPrefs::Commit(), NextHigherDBRange(), NextLowerDBRange(), WaveformPrefs::OnDefaults(), WaveformPrefs::Validate(), Validate(), and WaveformPrefs::WaveformPrefs().

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

◆ defaults()

WaveformSettings & WaveformSettings::defaults ( )
static

Definition at line 69 of file WaveformSettings.cpp.

70{
71 static WaveformSettings instance;
72 return instance;
73}
Waveform settings, either for one track or as defaults.

Referenced by WaveformPrefs::Commit(), WaveTrack::GetWaveformSettings(), WaveformPrefs::OnDefaults(), UpdatePrefs(), and WaveformPrefs::WaveformPrefs().

Here is the caller graph for this function:

◆ GetScaleNames()

const EnumValueSymbols & WaveformSettings::GetScaleNames ( )
static

Definition at line 162 of file WaveformSettings.cpp.

163{
164 static const EnumValueSymbols result{
165 // Keep in correspondence with ScaleTypeValues:
166 XO("Linear"),
167 XO("dB"),
168 };
169 return result;
170}
#define XO(s)
Definition: Internat.h:31

References XO.

Referenced by BeginSection(), and WaveformPrefs::PopulateOrExchange().

Here is the caller graph for this function:

◆ IsDefault()

bool WaveformSettings::IsDefault ( ) const
inline

Definition at line 40 of file WaveformSettings.h.

41 {
42 return this == &defaults();
43 }
static WaveformSettings & defaults()

◆ isLinear()

bool WaveformSettings::isLinear ( ) const
inline

Definition at line 71 of file WaveformSettings.h.

71{ return stLinear == scaleType; }

Referenced by EnvelopeHandle::Click(), WaveformView::DoDraw(), and WaveformVZoomHandle::DoZoom().

Here is the caller graph for this function:

◆ LoadPrefs()

void WaveformSettings::LoadPrefs ( )

Definition at line 87 of file WaveformSettings.cpp.

88{
90
92
93 // Enforce legal values
94 Validate(true);
95
96 Update();
97}
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
static WaveformSettings::ScaleTypeValues WaveformScaleChoice()
bool Validate(bool quiet)

References dBRange, DecibelScaleCutoff, Setting< T >::Read(), scaleType, Update(), Validate(), and TracksPrefs::WaveformScaleChoice().

Referenced by WaveformPrefs::Commit(), and WaveformSettings().

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

◆ NextHigherDBRange()

void WaveformSettings::NextHigherDBRange ( )

Definition at line 154 of file WaveformSettings.cpp.

References ConvertToActualDBRange(), ConvertToEnumeratedDBRange(), and dBRange.

Referenced by WaveformVRulerControls::DoHandleWheelRotation().

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

◆ NextLowerDBRange()

void WaveformSettings::NextLowerDBRange ( )

Definition at line 147 of file WaveformSettings.cpp.

References ConvertToActualDBRange(), ConvertToEnumeratedDBRange(), and dBRange.

Referenced by WaveformVRulerControls::DoHandleWheelRotation().

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

◆ operator=()

WaveformSettings & WaveformSettings::operator= ( const WaveformSettings other)

Definition at line 60 of file WaveformSettings.cpp.

61{
62 if (this != &other) {
63 scaleType = other.scaleType;
64 dBRange = other.dBRange;
65 }
66 return *this;
67}

References dBRange, and scaleType.

◆ SavePrefs()

void WaveformSettings::SavePrefs ( )

Definition at line 99 of file WaveformSettings.cpp.

100{
101}

Referenced by WaveformPrefs::Commit().

Here is the caller graph for this function:

◆ Update()

void WaveformSettings::Update ( )

Definition at line 103 of file WaveformSettings.cpp.

104{
105}

Referenced by LoadPrefs().

Here is the caller graph for this function:

◆ UpdatePrefs()

void WaveformSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 108 of file WaveformSettings.cpp.

109{
110 if (scaleType == defaults().scaleType) {
112 }
113
114 if (dBRange == defaults().dBRange){
116 }
117
118 // Enforce legal values
119 Validate(true);
120}

References dBRange, DecibelScaleCutoff, defaults(), Setting< T >::Read(), scaleType, Validate(), and TracksPrefs::WaveformScaleChoice().

Here is the call graph for this function:

◆ Validate()

bool WaveformSettings::Validate ( bool  quiet)

Definition at line 75 of file WaveformSettings.cpp.

76{
78 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
79 );
80
83
84 return true;
85}

References ConvertToActualDBRange(), ConvertToEnumeratedDBRange(), min(), scaleType, and stNumScaleTypes.

Referenced by LoadPrefs(), UpdatePrefs(), and WaveformPrefs::Validate().

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

Member Data Documentation

◆ dBRange

int WaveformSettings::dBRange

◆ scaleType

ScaleType WaveformSettings::scaleType

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