Audacity 3.2.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static 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 void GetRangeChoices (TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
 
- 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
 

Static Public Attributes

static const wxString waveformScaleKey
 
static const wxString dbLogValueString = wxT("dB")
 
static const wxString dbLinValueString = wxT("dBLin")
 
static EnumSetting< ScaleTypeValueswaveformScaleSetting
 

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 78 of file WaveformSettings.h.

Member Enumeration Documentation

◆ ScaleTypeValues

Enumerator
stLinearAmp 
stLogarithmicDb 
stLinearDb 
stNumScaleTypes 

Definition at line 79 of file WaveformSettings.h.

Constructor & Destructor Documentation

◆ WaveformSettings() [1/2]

WaveformSettings::WaveformSettings ( )

Definition at line 89 of file WaveformSettings.cpp.

90{
91 LoadPrefs();
92}

References LoadPrefs().

Here is the call graph for this function:

◆ WaveformSettings() [2/2]

WaveformSettings::WaveformSettings ( const WaveformSettings other)

Definition at line 94 of file WaveformSettings.cpp.

95 : scaleType(other.scaleType)
96 , dBRange(other.dBRange)
97{
98}

◆ ~WaveformSettings()

WaveformSettings::~WaveformSettings ( )
override

Definition at line 242 of file WaveformSettings.cpp.

243{
244}

Member Function Documentation

◆ Clone()

auto WaveformSettings::Clone ( ) const
overridevirtual

Implements ClientData::Cloneable< Covariant, Owner >.

Definition at line 246 of file WaveformSettings.cpp.

247{
248 return std::make_unique<WaveformSettings>(*this);
249}

◆ ConvertToActualDBRange()

void WaveformSettings::ConvertToActualDBRange ( )

Definition at line 177 of file WaveformSettings.cpp.

178{
179 wxArrayStringEx codes;
180 WaveformSettings::GetRangeChoices(nullptr, &codes);
181 long value = 0;
182 codes[std::max(0, std::min((int)(codes.size()) - 1, dBRange))]
183 .ToLong(&value);
184 dBRange = (int)(value);
185}
int min(int a, int b)
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.

References dBRange, 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 162 of file WaveformSettings.cpp.

163{
164 // Assumes the codes are in ascending sequence.
165 wxArrayStringEx codes;
166 WaveformSettings::GetRangeChoices(nullptr, &codes);
167 int ii = 0;
168 for (int nn = codes.size(); ii < nn; ++ii) {
169 long value = 0;
170 codes[ii].ToLong(&value);
171 if (dBRange < value)
172 break;
173 }
174 dBRange = std::max(0, ii - 1);
175}

References dBRange, and 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 109 of file WaveformSettings.cpp.

110{
111 static WaveformSettings instance;
112 return instance;
113}
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 78 of file WaveformSettings.cpp.

79{
80 return Get(channel.GetTrack());
81}
WaveTrack & GetTrack()
Definition: WaveTrack.h:841
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 72 of file WaveformSettings.cpp.

73{
74 auto &mutTrack = const_cast<WaveTrack&>(track);
75 return mutTrack.Attachments::Get<WaveformSettings>(key1);
76}
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:

◆ GetRangeChoices()

void WaveformSettings::GetRangeChoices ( TranslatableStrings pChoices,
wxArrayStringEx pCodes,
int *  pDefaultRangeIndex = nullptr 
)
static

Definition at line 213 of file WaveformSettings.cpp.

216{
217 static const wxArrayStringEx sCodes = {
218 wxT("36"), wxT("48"), wxT("60"), wxT("72"),
219 wxT("84"), wxT("96"), wxT("120"), wxT("145"),
220 };
221 if (pCodes)
222 *pCodes = sCodes;
223
224 static const std::initializer_list<TranslatableString> sChoices = {
225 XO("-36 dB (shallow range for high-amplitude editing)"),
226 XO("-48 dB (PCM range of 8 bit samples)"),
227 XO("-60 dB (PCM range of 10 bit samples)"),
228 XO("-72 dB (PCM range of 12 bit samples)"),
229 XO("-84 dB (PCM range of 14 bit samples)"),
230 XO("-96 dB (PCM range of 16 bit samples)"),
231 XO("-120 dB (approximate limit of human hearing)"),
232 XO("-145 dB (PCM range of 24 bit samples)"),
233 };
234
235 if (pChoices)
236 *pChoices = sChoices;
237
238 if (pDefaultRangeIndex)
239 *pDefaultRangeIndex = 2; // 60 == ENV_DB_RANGE
240}
wxT("CloseDown"))
XO("Cut/Copy/Paste")

References wxT(), and XO().

Referenced by ConvertToActualDBRange(), ConvertToEnumeratedDBRange(), GUIPrefs::Populate(), and WaveformPrefs::Populate().

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

203{
204 static const EnumValueSymbols result{
205 // Keep in correspondence with ScaleTypeValues:
206 { wxT("Linear"), XO("Linear (amp)") },
207 { wxT("dB"), XO("Logarithmic (dB)") },
208 { wxT("LinearDB"), XO("Linear (dB)") },
209 };
210 return result;
211}

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 61 of file WaveformSettings.h.

62 {
63 return this == &defaults();
64 }
static WaveformSettings & defaults()

◆ isLinear()

bool WaveformSettings::isLinear ( ) const
inline

Definition at line 101 of file WaveformSettings.h.

101{ 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 127 of file WaveformSettings.cpp.

128{
130
132
133 // Enforce legal values
134 Validate(true);
135
136 Update();
137}
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
Enum ReadEnum() const
Definition: Prefs.h:534
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:207
bool Validate(bool quiet)
static EnumSetting< ScaleTypeValues > waveformScaleSetting

References dBRange, DecibelScaleCutoff, Setting< T >::Read(), EnumSetting< Enum >::ReadEnum(), scaleType, Update(), Validate(), and waveformScaleSetting.

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

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

Here is the call graph for this function:

◆ NextLowerDBRange()

void WaveformSettings::NextLowerDBRange ( )

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

101{
102 if (this != &other) {
103 scaleType = other.scaleType;
104 dBRange = other.dBRange;
105 }
106 return *this;
107}

References dBRange, and scaleType.

◆ SavePrefs()

void WaveformSettings::SavePrefs ( )

Definition at line 139 of file WaveformSettings.cpp.

140{
141}

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

85{
86 channel.GetTrack().Attachments::Assign(key1, move(pSettings));
87}

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

144{
145}

Referenced by LoadPrefs().

Here is the caller graph for this function:

◆ UpdatePrefs()

void WaveformSettings::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 148 of file WaveformSettings.cpp.

149{
150 if (scaleType == defaults().scaleType) {
152 }
153
154 if (dBRange == defaults().dBRange){
156 }
157
158 // Enforce legal values
159 Validate(true);
160}

References dBRange, DecibelScaleCutoff, defaults(), Setting< T >::Read(), EnumSetting< Enum >::ReadEnum(), scaleType, Validate(), and waveformScaleSetting.

Here is the call graph for this function:

◆ Validate()

bool WaveformSettings::Validate ( bool  quiet)

Definition at line 115 of file WaveformSettings.cpp.

116{
118 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
119 );
120
123
124 return true;
125}

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

◆ dbLinValueString

const wxString WaveformSettings::dbLinValueString = wxT("dBLin")
static

Definition at line 94 of file WaveformSettings.h.

◆ dbLogValueString

const wxString WaveformSettings::dbLogValueString = wxT("dB")
static

Definition at line 93 of file WaveformSettings.h.

Referenced by TracksViewModeEnumSetting::Migrate().

◆ dBRange

int WaveformSettings::dBRange

◆ scaleType

ScaleType WaveformSettings::scaleType

◆ waveformScaleKey

const wxString WaveformSettings::waveformScaleKey
static
Initial value:
=
wxT("/GUI/DefaultWaveformScaleChoice")

Definition at line 92 of file WaveformSettings.h.

Referenced by TracksViewModeEnumSetting::Migrate().

◆ waveformScaleSetting

EnumSetting< WaveformSettings::ScaleTypeValues > WaveformSettings::waveformScaleSetting
static
Initial value:
{
{
{ wxT("Linear"), XO("Linear (amp)") },
{ dbLogValueString, XO("Logarithmic (dB)") },
{ dbLinValueString, XO("Linear (dB)") },
},
0,
{
}
}
static const wxString dbLogValueString
static const wxString waveformScaleKey
static const wxString dbLinValueString

Definition at line 95 of file WaveformSettings.h.

Referenced by LoadPrefs(), TracksPrefs::PopulateOrExchange(), and UpdatePrefs().


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