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

68{
69 LoadPrefs();
70}

References LoadPrefs().

Here is the call graph for this function:

◆ WaveformSettings() [2/2]

WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 72 of file WaveformSettings.cpp.

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

◆ ~WaveformSettings()

WaveformSettings::~WaveformSettings ( )
override

Definition at line 191 of file WaveformSettings.cpp.

192{
193}

Member Function Documentation

◆ Clone()

auto WaveformSettings::Clone ( ) const
overridevirtual

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

Definition at line 195 of file WaveformSettings.cpp.

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

◆ ConvertToActualDBRange()

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 155 of file WaveformSettings.cpp.

156{
157 wxArrayStringEx codes;
158 GUIPrefs::GetRangeChoices(nullptr, &codes);
159 long value = 0;
160 codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
161 .ToLong(&value);
162 dBRange = (int)(value);
163}
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 140 of file WaveformSettings.cpp.

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

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

88{
89 static WaveformSettings instance;
90 return instance;
91}
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 53 of file WaveformSettings.cpp.

54{
55 auto &mutTrack = const_cast<WaveTrack&>(track);
56 return mutTrack.GetGroupData().Attachments
57 ::Get<WaveformSettings>(key1);
58}
static const ChannelGroup::Attachments::RegisteredFactory key1
ChannelGroupData & GetGroupData()
Definition: Track.cpp:166
A Track that contains audio waveform data.
Definition: WaveTrack.h:220

References Track::GetGroupData(), and 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 call graph for this function:
Here is the caller graph for this function:

◆ GetScaleNames()

const EnumValueSymbols & WaveformSettings::GetScaleNames ( )
static

Definition at line 180 of file WaveformSettings.cpp.

181{
182 static const EnumValueSymbols result{
183 // Keep in correspondence with ScaleTypeValues:
184 { wxT("Linear"), XO("Linear (amp)") },
185 { wxT("dB"), XO("Logarithmic (dB)") },
186 { wxT("LinearDB"), XO("Linear (dB)") },
187 };
188 return result;
189}
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 105 of file WaveformSettings.cpp.

106{
108
110
111 // Enforce legal values
112 Validate(true);
113
114 Update();
115}
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:205
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 172 of file WaveformSettings.cpp.

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

Here is the call graph for this function:

◆ NextLowerDBRange()

void WaveformSettings::NextLowerDBRange ( )

Definition at line 165 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 78 of file WaveformSettings.cpp.

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

References dBRange, and scaleType.

◆ SavePrefs()

void WaveformSettings::SavePrefs ( )

Definition at line 117 of file WaveformSettings.cpp.

118{
119}

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

62{
63 track.GetGroupData().Attachments
64 ::Assign(key1, move(pSettings));
65}

References Track::GetGroupData(), and key1.

Referenced by WaveformPrefs::Commit().

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

◆ Update()

void WaveformSettings::Update ( )

Definition at line 121 of file WaveformSettings.cpp.

122{
123}

Referenced by LoadPrefs().

Here is the caller graph for this function:

◆ UpdatePrefs()

void WaveformSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 126 of file WaveformSettings.cpp.

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

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

94{
96 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
97 );
98
101
102 return true;
103}

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: