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 { stLinearAmp , stLogarithmicDb , stLinearDb , stNumScaleTypes }
 
typedef int ScaleType
 
- Public Types inherited from ClientData::Cloneable< ClientData::UniquePtr >
using Base = Cloneable
 
using PointerType = ClientData::UniquePtr< Base >
 

Public Member Functions

 WaveformSettings ()
 
 WaveformSettings (const WaveformSettings &other)
 
WaveformSettingsoperator= (const WaveformSettings &other)
 
 ~WaveformSettings () override
 
PointerType Clone () const override
 
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
 
- Public Member Functions inherited from ClientData::Cloneable< ClientData::UniquePtr >
virtual ~Cloneable ()
 
virtual PointerType Clone () const=0
 

Static Public Member Functions

static WaveformSettingsGet (const WaveTrack &track)
 
static void Set (WaveTrack &track, std::unique_ptr< WaveformSettings > pSettings)
 Guarantee independence of settings, then assign. More...
 
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 22 of file WaveformSettings.h.

Member Typedef Documentation

◆ ScaleType

Definition at line 74 of file WaveformSettings.h.

Member Enumeration Documentation

◆ ScaleTypeValues

Enumerator
stLinearAmp 
stLogarithmicDb 
stLinearDb 
stNumScaleTypes 

Definition at line 75 of file WaveformSettings.h.

Constructor & Destructor Documentation

◆ WaveformSettings() [1/2]

WaveformSettings::WaveformSettings ( )

Definition at line 68 of file WaveformSettings.cpp.

69{
70 LoadPrefs();
71}

References LoadPrefs().

Here is the call graph for this function:

◆ WaveformSettings() [2/2]

WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 73 of file WaveformSettings.cpp.

74 : scaleType(other.scaleType)
75 , dBRange(other.dBRange)
76{
77}

◆ ~WaveformSettings()

WaveformSettings::~WaveformSettings ( )
override

Definition at line 192 of file WaveformSettings.cpp.

193{
194}

Member Function Documentation

◆ Clone()

auto WaveformSettings::Clone ( ) const
overridevirtual

Implements ClientData::Cloneable< ClientData::UniquePtr >.

Definition at line 196 of file WaveformSettings.cpp.

197{
198 return std::make_unique<WaveformSettings>(*this);
199}

◆ ConvertToActualDBRange()

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 156 of file WaveformSettings.cpp.

157{
158 wxArrayStringEx codes;
159 GUIPrefs::GetRangeChoices(nullptr, &codes);
160 long value = 0;
161 codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
162 .ToLong(&value);
163 dBRange = (int)(value);
164}
int min(int a, int b)
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:65
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 141 of file WaveformSettings.cpp.

142{
143 // Assumes the codes are in ascending sequence.
144 wxArrayStringEx codes;
145 GUIPrefs::GetRangeChoices(nullptr, &codes);
146 int ii = 0;
147 for (int nn = codes.size(); ii < nn; ++ii) {
148 long value = 0;
149 codes[ii].ToLong(&value);
150 if (dBRange < value)
151 break;
152 }
153 dBRange = std::max(0, ii - 1);
154}

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 88 of file WaveformSettings.cpp.

89{
90 static WaveformSettings instance;
91 return instance;
92}
Waveform settings, either for one track or as defaults.

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

Here is the caller graph for this function:

◆ Get()

WaveformSettings & WaveformSettings::Get ( const WaveTrack track)
static

Create waveform settings for the track on demand Mutative access to attachment even if the track argument is const

Definition at line 55 of file WaveformSettings.cpp.

56{
57 auto &mutTrack = const_cast<WaveTrack&>(track);
58 return static_cast<WaveformSettings&>(
59 mutTrack.WaveTrack::Attachments::Get(key1));
60}
static WaveTrack::Attachments::RegisteredFactory key1
A Track that contains audio waveform data.
Definition: WaveTrack.h:51

References key1.

Referenced by SetTrackVisualsCommand::ApplyInner(), EnvelopeHandle::Click(), WaveformPrefs::Commit(), WaveformView::DoDraw(), WaveformVRulerControls::DoHandleWheelRotation(), WaveformVRulerControls::DoUpdateVRuler(), WaveformVZoomHandle::DoZoom(), anonymous_namespace{WaveformView.cpp}::DrawClipWaveform(), SampleHandle::FindSampleEditingLevel(), for(), SampleHandle::HitTest(), WaveformVRulerMenuTable::OnWaveformScaleType(), anonymous_namespace{WaveformVRulerControls.cpp}::SetLastdBRange(), anonymous_namespace{WaveformVRulerControls.cpp}::SetLastScaleType(), WaveformPrefs::WaveformPrefs(), and EnvelopeHandle::WaveTrackHitTest().

Here is the caller graph for this function:

◆ GetScaleNames()

const EnumValueSymbols & WaveformSettings::GetScaleNames ( )
static

Definition at line 181 of file WaveformSettings.cpp.

182{
183 static const EnumValueSymbols result{
184 // Keep in correspondence with ScaleTypeValues:
185 { wxT("Linear"), XO("Linear (amp)") },
186 { wxT("dB"), XO("Logarithmic (dB)") },
187 { wxT("LinearDB"), XO("Linear (dB)") },
188 };
189 return result;
190}
wxT("CloseDown"))
XO("Cut/Copy/Paste")

References wxT(), and XO().

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

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

◆ IsDefault()

bool WaveformSettings::IsDefault ( ) const
inline

Definition at line 57 of file WaveformSettings.h.

58 {
59 return this == &defaults();
60 }
static WaveformSettings & defaults()

◆ isLinear()

bool WaveformSettings::isLinear ( ) const
inline

Definition at line 89 of file WaveformSettings.h.

89{ return scaleType == stLinearAmp || scaleType == stLinearDb; }

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

Here is the caller graph for this function:

◆ LoadPrefs()

void WaveformSettings::LoadPrefs ( )

Definition at line 106 of file WaveformSettings.cpp.

107{
109
111
112 // Enforce legal values
113 Validate(true);
114
115 Update();
116}
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 173 of file WaveformSettings.cpp.

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

Here is the call graph for this function:

◆ NextLowerDBRange()

void WaveformSettings::NextLowerDBRange ( )

Definition at line 166 of file WaveformSettings.cpp.

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

Here is the call graph for this function:

◆ operator=()

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

Definition at line 79 of file WaveformSettings.cpp.

80{
81 if (this != &other) {
82 scaleType = other.scaleType;
83 dBRange = other.dBRange;
84 }
85 return *this;
86}

References dBRange, and scaleType.

◆ SavePrefs()

void WaveformSettings::SavePrefs ( )

Definition at line 118 of file WaveformSettings.cpp.

119{
120}

Referenced by WaveformPrefs::Commit().

Here is the caller graph for this function:

◆ Set()

void WaveformSettings::Set ( WaveTrack track,
std::unique_ptr< WaveformSettings pSettings 
)
static

Guarantee independence of settings, then assign.

Definition at line 62 of file WaveformSettings.cpp.

64{
65 track.WaveTrack::Attachments::Assign(key1, move(pSettings));
66}

References key1.

Referenced by WaveformPrefs::Commit().

Here is the caller graph for this function:

◆ Update()

void WaveformSettings::Update ( )

Definition at line 122 of file WaveformSettings.cpp.

123{
124}

Referenced by LoadPrefs().

Here is the caller graph for this function:

◆ UpdatePrefs()

void WaveformSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 127 of file WaveformSettings.cpp.

128{
129 if (scaleType == defaults().scaleType) {
131 }
132
133 if (dBRange == defaults().dBRange){
135 }
136
137 // Enforce legal values
138 Validate(true);
139}

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 94 of file WaveformSettings.cpp.

95{
97 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
98 );
99
102
103 return true;
104}

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: