Audacity 3.2.0
WaveformSettings.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5WaveformSettings.cpp
6
7Paul Licameli
8
9*******************************************************************//*******************************************************************/
15
16
17#include "WaveformSettings.h"
18
19#include "Decibels.h"
20#include "GUIPrefs.h"
21#include "TracksPrefs.h"
22
23#include <algorithm>
24#include <wx/intl.h>
25
26#include "Prefs.h"
27
28
30{
31 LoadPrefs();
32}
33
35{
36}
37
39{
40}
41
44{
45 static Globals instance;
46 return instance;
47}
48
50{
51 LoadPrefs();
52}
53
55 : scaleType(other.scaleType)
56 , dBRange(other.dBRange)
57{
58}
59
61{
62 if (this != &other) {
63 scaleType = other.scaleType;
64 dBRange = other.dBRange;
65 }
66 return *this;
67}
68
70{
71 static WaveformSettings instance;
72 return instance;
73}
74
75bool WaveformSettings::Validate(bool /* quiet */)
76{
78 std::max(0, std::min((int)(stNumScaleTypes) - 1, (int)(scaleType)))
79 );
80
83
84 return true;
85}
86
88{
90
92
93 // Enforce legal values
94 Validate(true);
95
96 Update();
97}
98
100{
101}
102
104{
105}
106
107// This is a temporary hack until WaveformSettings gets fully integrated
109{
110 if (scaleType == defaults().scaleType) {
112 }
113
114 if (dBRange == defaults().dBRange){
116 }
117
118 // Enforce legal values
119 Validate(true);
120}
121
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}
136
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}
146
148{
150 ++dBRange;
152}
153
155{
157 --dBRange;
159}
160
161//static
163{
164 static const EnumValueSymbols result{
165 // Keep in correspondence with ScaleTypeValues:
166 XO("Linear"),
167 XO("dB"),
168 };
169 return result;
170}
171
173{
174}
int min(int a, int b)
IntSetting DecibelScaleCutoff
Negation of this value is the lowest dB level that should be shown in dB scales.
Definition: Decibels.cpp:12
#define XO(s)
Definition: Internat.h:31
static void GetRangeChoices(TranslatableStrings *pChoices, wxArrayStringEx *pCodes, int *pDefaultRangeIndex=nullptr)
Definition: GUIPrefs.cpp:63
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()
Waveform settings, either for one track or as defaults.
static const EnumValueSymbols & GetScaleNames()
bool Validate(bool quiet)
static WaveformSettings & defaults()
void UpdatePrefs() override
WaveformSettings & operator=(const WaveformSettings &other)
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.