Audacity 3.2.0
QualityPrefs.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 QualityPrefs.cpp
6
7 Joshua Haberman
8 James Crook
9
10
11*******************************************************************//*******************************************************************/
17
18
19#include "QualityPrefs.h"
20#include "QualitySettings.h"
21
22#include <wx/choice.h>
23#include <wx/defs.h>
24#include <wx/textctrl.h>
25
26#include "AudioIOBase.h"
27#include "Dither.h"
28#include "Prefs.h"
29#include "Resample.h"
30#include "ShuttleGui.h"
31
32#define ID_SAMPLE_RATE_CHOICE 7001
33
35BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel)
38
39QualityPrefs::QualityPrefs(wxWindow * parent, wxWindowID winid)
40/* i18n-hint: meaning accuracy in reproduction of sounds */
41: PrefsPanel(parent, winid, XO("Quality"))
42{
43 Populate();
44}
45
47{
48}
49
51{
53}
54
56{
57 return XO("Preferences for Quality");
58}
59
61{
62 return "Quality_Preferences";
63}
64
66{
67 // First any pre-processing for constructing the GUI.
70
71 //------------------------- Main section --------------------
72 // Now construct the GUI itself.
73 // Use 'eIsCreatingFromPrefs' so that the GUI is
74 // initialised with values from gPrefs.
77 // ----------------------- End of main section --------------
78
79 wxCommandEvent e;
80 OnSampleRateChoice(e); // Enable/disable the control.
81}
82
88{
89 //------------ Sample Rate Names
90 // JKC: I don't understand the following comment.
91 // Can someone please explain or correct it?
92 // XXX: This should use a previously changed, but not yet saved
93 // sound card setting from the "I/O" preferences tab.
94 // LLL: It means that until the user clicks "Ok" in preferences, the
95 // GetSupportedSampleRates() call should use the devices they
96 // may have changed on the Audio I/O page. As coded, the sample
97 // rates it will return could be completely invalid as they will
98 // be what's supported by the devices that were selected BEFORE
99 // coming into preferences.
100 //
101 // GetSupportedSampleRates() allows passing in device names, but
102 // how do you get at them as they are on the Audio I/O page????
103 for (int i = 0; i < AudioIOBase::NumStandardRates; i++) {
104 int iRate = AudioIOBase::StandardRates[i];
105 mSampleRateLabels.push_back(iRate);
106 mSampleRateNames.push_back( XO("%i Hz").Format( iRate ) );
107 }
108
109 mSampleRateNames.push_back(XO("Other..."));
110
111 // The label for the 'Other...' case can be any value at all.
112 mSampleRateLabels.push_back(44100); // If chosen, this value will be overwritten
113}
114
116{
117 S.SetBorder(2);
118 S.StartScroller();
119
120 S.StartStatic(XO("Sampling"));
121 {
122 S.StartMultiColumn(2);
123 {
124 S.AddPrompt(XXO("Default Sample &Rate:"));
125
126 S.StartMultiColumn(2);
127 {
128 // First the choice...
129 // We make sure it uses the ID we want, so that we get changes
130 // We make sure we have a pointer to it, so that we can drive it.
132 S
134 .TieNumberAsChoice( {},
138 // If the value in Prefs isn't in the list, then we want
139 // the last item, 'Other...' to be shown.
140 mSampleRateNames.size() - 1 );
141
142 // Now do the edit box...
143 mOtherSampleRate = S.TieNumericTextBox( {},
145 15);
146 }
147 S.EndHorizontalLay();
148
149 S
150 .TieChoice( XXO("Default Sample &Format:"),
152 }
153 S.EndMultiColumn();
154 }
155 S.EndStatic();
156
157 S.StartStatic(XO("Real-time Conversion"));
158 {
159 S.StartMultiColumn(2, wxEXPAND);
160 {
161 S.TieChoice(XXO("Sample Rate Con&verter:"),
163
164 /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
165 S.TieChoice(XXO("&Dither:"),
167 }
168 S.EndMultiColumn();
169 }
170 S.EndStatic();
171
172 S.StartStatic(XO("High-quality Conversion"));
173 {
174 S.StartMultiColumn(2);
175 {
176 S.TieChoice(XXO("Sample Rate Conver&ter:"),
178
179 /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
180 S.TieChoice(XXO("Dit&her:"),
182 }
183 S.EndMultiColumn();
184 }
185 S.EndStatic();
186 S.EndScroller();
187
188}
189
192void QualityPrefs::OnSampleRateChoice(wxCommandEvent & WXUNUSED(e))
193{
194 int sel = mSampleRates->GetSelection();
195 mOtherSampleRate->Enable(sel == (int)mSampleRates->GetCount() - 1);
196}
197
199{
202
204
205 // The complex compound control may have value 'other' in which case the
206 // value in prefs comes from the second field.
207 if (mOtherSampleRate->IsEnabled()) {
209 gPrefs->Flush();
210 }
211
212 // Tell CopySamples() to use these ditherers now
214
215 return true;
216}
217
218namespace{
220 [](wxWindow *parent, wxWindowID winid, AudacityProject *)
221 {
222 wxASSERT(parent); // to justify safenew
223 return safenew QualityPrefs(parent, winid);
224 }
225};
226}
227
END_EVENT_TABLE()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
#define safenew
Definition: MemoryX.h:10
FileConfig * gPrefs
Definition: Prefs.cpp:70
#define ID_SAMPLE_RATE_CHOICE
#define QUALITY_PREFS_PLUGIN_SYMBOL
Definition: QualityPrefs.h:26
void InitDitherers()
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:46
@ eIsSavingToPrefs
Definition: ShuttleGui.h:47
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static const int StandardRates[]
Array of common audio sample rates.
Definition: AudioIOBase.h:189
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIOBase.h:191
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
static EnumSetting< DitherType > BestSetting
Definition: Dither.h:29
static EnumSetting< DitherType > FastSetting
Definition: Dither.h:28
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
Abstract base class used in importing a file.
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
Definition: PrefsPanel.h:51
A PrefsPanel used for setting audio quality.
Definition: QualityPrefs.h:29
bool Commit() override
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:49
wxChoice * mSampleRates
Definition: QualityPrefs.h:48
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
int mOtherSampleRateValue
Definition: QualityPrefs.h:50
void OnSampleRateChoice(wxCommandEvent &e)
void PopulateOrExchange(ShuttleGui &S) override
ComponentInterfaceSymbol GetSymbol() const override
TranslatableStrings mSampleRateNames
Definition: QualityPrefs.h:45
virtual ~QualityPrefs()
TranslatableString GetDescription() const override
std::vector< int > mSampleRateLabels
Definition: QualityPrefs.h:46
void GetNamesAndLabels()
static EnumSetting< int > FastMethodSetting
Definition: Resample.h:42
static EnumSetting< int > BestMethodSetting
Definition: Resample.h:43
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
void Invalidate() override
Definition: Prefs.h:282
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:625
Holds a msgid for the translation catalog; may also bind format arguments.
PROJECT_RATE_API IntSetting DefaultSampleRate
PROJECT_RATE_API EnumSetting< sampleFormat > SampleFormatSetting
PrefsPanel::Registration sAttachment