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< Covariant, Owner >
using Base = std::conditional_t< std::is_void_v< Covariant >, Cloneable, Covariant >
 
using PointerType = Owner< 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< Covariant, Owner >
 Cloneable ()=default
 
 Cloneable (const Cloneable &)=default
 
Cloneableoperator= (const Cloneable &)=default
 
virtual ~Cloneable ()=default
 
virtual PointerType Clone () const =0
 

Static Public Member Functions

static WaveformSettingsGet (const WaveTrack &track)
 
static WaveformSettingsGet (const WaveChannel &channel)
 
static void Set (WaveChannel &channel, 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 23 of file WaveformSettings.h.

Member Typedef Documentation

◆ ScaleType

Definition at line 80 of file WaveformSettings.h.

Member Enumeration Documentation

◆ ScaleTypeValues

Enumerator
stLinearAmp 
stLogarithmicDb 
stLinearDb 
stNumScaleTypes 

Definition at line 81 of file WaveformSettings.h.

Constructor & Destructor Documentation

◆ WaveformSettings() [1/2]

WaveformSettings::WaveformSettings ( )

Definition at line 70 of file WaveformSettings.cpp.

71{
72 LoadPrefs();
73}

References LoadPrefs().

Here is the call graph for this function:

◆ WaveformSettings() [2/2]

WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 75 of file WaveformSettings.cpp.

76 : scaleType(other.scaleType)
77 , dBRange(other.dBRange)
78{
79}

◆ ~WaveformSettings()

WaveformSettings::~WaveformSettings ( )
override

Definition at line 194 of file WaveformSettings.cpp.

195{
196}

Member Function Documentation

◆ Clone()

auto WaveformSettings::Clone ( ) const
overridevirtual

Implements ClientData::Cloneable< Covariant, Owner >.

Definition at line 198 of file WaveformSettings.cpp.

199{
200 return std::make_unique<WaveformSettings>(*this);
201}

◆ ConvertToActualDBRange()

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 158 of file WaveformSettings.cpp.

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

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

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

91{
92 static WaveformSettings instance;
93 return instance;
94}
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() [1/2]

WaveformSettings & WaveformSettings::Get ( const WaveChannel channel)
static

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

Definition at line 59 of file WaveformSettings.cpp.

60{
61 return Get(channel.GetTrack());
62}
WaveTrack & GetTrack()
Definition: WaveTrack.h:840
static WaveformSettings & Get(const WaveTrack &track)

References Get(), and WaveChannel::GetTrack().

Here is the call graph for this function:

◆ Get() [2/2]

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.Attachments::Get<WaveformSettings>(key1);
57}
static const ChannelGroup::Attachments::RegisteredFactory key1
A Track that contains audio waveform data.
Definition: WaveTrack.h:203

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(), Get(), SampleHandle::HitTest(), WaveformVRulerMenuTable::OnWaveformScaleType(), anonymous_namespace{WaveformVRulerControls.cpp}::SetLastdBRange(), anonymous_namespace{WaveformVRulerControls.cpp}::SetLastScaleType(), EnvelopeHandle::WaveChannelHitTest(), and WaveformPrefs::WaveformPrefs().

Here is the caller graph for this function:

◆ GetScaleNames()

const EnumValueSymbols & WaveformSettings::GetScaleNames ( )
static

Definition at line 183 of file WaveformSettings.cpp.

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

References wxT(), and XO().

Referenced by 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 63 of file WaveformSettings.h.

64 {
65 return this == &defaults();
66 }
static WaveformSettings & defaults()

◆ isLinear()

bool WaveformSettings::isLinear ( ) const
inline

Definition at line 95 of file WaveformSettings.h.

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

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

Here is the caller graph for this function:

◆ LoadPrefs()

void WaveformSettings::LoadPrefs ( )

Definition at line 108 of file WaveformSettings.cpp.

109{
111
113
114 // Enforce legal values
115 Validate(true);
116
117 Update();
118}
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:207
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 175 of file WaveformSettings.cpp.

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

Here is the call graph for this function:

◆ NextLowerDBRange()

void WaveformSettings::NextLowerDBRange ( )

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

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

References dBRange, and scaleType.

◆ SavePrefs()

void WaveformSettings::SavePrefs ( )

Definition at line 120 of file WaveformSettings.cpp.

121{
122}

Referenced by WaveformPrefs::Commit().

Here is the caller graph for this function:

◆ Set()

void WaveformSettings::Set ( WaveChannel channel,
std::unique_ptr< WaveformSettings pSettings 
)
static

Guarantee independence of settings, then assign.

Definition at line 64 of file WaveformSettings.cpp.

66{
67 channel.GetTrack().Attachments::Assign(key1, move(pSettings));
68}

References WaveChannel::GetTrack(), 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 124 of file WaveformSettings.cpp.

125{
126}

Referenced by LoadPrefs().

Here is the caller graph for this function:

◆ UpdatePrefs()

void WaveformSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 129 of file WaveformSettings.cpp.

130{
131 if (scaleType == defaults().scaleType) {
133 }
134
135 if (dBRange == defaults().dBRange){
137 }
138
139 // Enforce legal values
140 Validate(true);
141}

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

97{
99 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
100 );
101
104
105 return true;
106}

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: