Audacity  3.0.3
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QualityPrefs Class Referencefinal

A PrefsPanel used for setting audio quality. More...

#include <QualityPrefs.h>

Inheritance diagram for QualityPrefs:
[legend]
Collaboration diagram for QualityPrefs:
[legend]

Public Member Functions

 QualityPrefs (wxWindow *parent, wxWindowID winid)
 
virtual ~QualityPrefs ()
 
ComponentInterfaceSymbol GetSymbol () override
 
TranslatableString GetDescription () override
 
bool Commit () override
 
ManualPageID HelpPageName () override
 If not empty string, the Help button is added below the panel. More...
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const TranslatableString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
virtual PluginPath GetPath ()
 
virtual VendorSymbol GetVendor ()
 
virtual wxString GetVersion ()
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual void Cancel ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Private Member Functions

void Populate ()
 
void GetNamesAndLabels ()
 
void OnSampleRateChoice (wxCommandEvent &e)
 

Private Attributes

TranslatableStrings mSampleRateNames
 
std::vector< int > mSampleRateLabels
 
wxChoice * mSampleRates
 
wxTextCtrl * mOtherSampleRate
 
int mOtherSampleRateValue
 

Additional Inherited Members

- Public Types inherited from PrefsPanel
using Factories = std::vector< PrefsPanel::PrefsNode >
 
using Factory = std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) >
 
- Static Public Member Functions inherited from PrefsPanel
static FactoriesDefaultFactories ()
 

Detailed Description

A PrefsPanel used for setting audio quality.

Definition at line 28 of file QualityPrefs.h.

Constructor & Destructor Documentation

◆ QualityPrefs()

QualityPrefs::QualityPrefs ( wxWindow *  parent,
wxWindowID  winid 
)

Definition at line 39 of file QualityPrefs.cpp.

41 : PrefsPanel(parent, winid, XO("Quality"))
42 {
43  Populate();
44 }

◆ ~QualityPrefs()

QualityPrefs::~QualityPrefs ( )
virtual

Definition at line 46 of file QualityPrefs.cpp.

47 {
48 }

Member Function Documentation

◆ Commit()

bool QualityPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 198 of file QualityPrefs.cpp.

199 {
200  ShuttleGui S(this, eIsSavingToPrefs);
202 
203  // The complex compound control may have value 'other' in which case the
204  // value in prefs comes from the second field.
205  if (mOtherSampleRate->IsEnabled()) {
207  gPrefs->Flush();
208  }
209 
210  // Tell CopySamples() to use these ditherers now
211  InitDitherers();
212 
213  return true;
214 }

References QualitySettings::DefaultSampleRate, eIsSavingToPrefs, FileConfig::Flush(), gPrefs, InitDitherers(), mOtherSampleRate, mOtherSampleRateValue, PopulateOrExchange(), and Setting< T >::Write().

Here is the call graph for this function:

◆ GetDescription()

TranslatableString QualityPrefs::GetDescription ( )
overridevirtual

Implements ComponentInterface.

Definition at line 55 of file QualityPrefs.cpp.

56 {
57  return XO("Preferences for Quality");
58 }

References XO.

◆ GetNamesAndLabels()

void QualityPrefs::GetNamesAndLabels ( )
private

Gets the lists of names and lists of labels which are used in the choice controls. The names are what the user sees in the wxChoice. The corresponding labels are what gets stored.

Definition at line 87 of file QualityPrefs.cpp.

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 }

References mSampleRateLabels, mSampleRateNames, AudioIOBase::NumStandardRates, AudioIOBase::StandardRates, and XO.

Referenced by Populate().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol QualityPrefs::GetSymbol ( )
overridevirtual

Implements ComponentInterface.

Definition at line 50 of file QualityPrefs.cpp.

51 {
53 }

References QUALITY_PREFS_PLUGIN_SYMBOL.

◆ HelpPageName()

ManualPageID QualityPrefs::HelpPageName ( )
overridevirtual

If not empty string, the Help button is added below the panel.

Default returns empty string.

Reimplemented from PrefsPanel.

Definition at line 60 of file QualityPrefs.cpp.

61 {
62  return "Quality_Preferences";
63 }

◆ OnSampleRateChoice()

void QualityPrefs::OnSampleRateChoice ( wxCommandEvent &  e)
private

Enables or disables the Edit box depending on whether we selected 'Other...' or not.

Definition at line 192 of file QualityPrefs.cpp.

193 {
194  int sel = mSampleRates->GetSelection();
195  mOtherSampleRate->Enable(sel == (int)mSampleRates->GetCount() - 1);
196 }

References mOtherSampleRate, and mSampleRates.

Referenced by Populate().

Here is the caller graph for this function:

◆ Populate()

void QualityPrefs::Populate ( )
private

Definition at line 65 of file QualityPrefs.cpp.

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 }

References QualitySettings::DefaultSampleRate, eIsCreatingFromPrefs, GetNamesAndLabels(), mOtherSampleRateValue, OnSampleRateChoice(), PopulateOrExchange(), and Setting< T >::Read().

Here is the call graph for this function:

◆ PopulateOrExchange()

void QualityPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 115 of file QualityPrefs.cpp.

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.
131  mSampleRates =
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...
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 }

References ShuttleGuiBase::AddPrompt(), Resample::BestMethodSetting, Dither::BestSetting, QualitySettings::DefaultSampleRate, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), Resample::FastMethodSetting, Dither::FastSetting, ShuttleGui::Id(), ID_SAMPLE_RATE_CHOICE, mOtherSampleRate, mOtherSampleRateValue, mSampleRateLabels, mSampleRateNames, mSampleRates, QualitySettings::SampleFormatSetting, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieNumberAsChoice(), ShuttleGuiBase::TieNumericTextBox(), XO, and XXO.

Referenced by Commit(), and Populate().

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

Member Data Documentation

◆ mOtherSampleRate

wxTextCtrl* QualityPrefs::mOtherSampleRate
private

Definition at line 49 of file QualityPrefs.h.

Referenced by Commit(), OnSampleRateChoice(), and PopulateOrExchange().

◆ mOtherSampleRateValue

int QualityPrefs::mOtherSampleRateValue
private

Definition at line 50 of file QualityPrefs.h.

Referenced by Commit(), Populate(), and PopulateOrExchange().

◆ mSampleRateLabels

std::vector<int> QualityPrefs::mSampleRateLabels
private

Definition at line 46 of file QualityPrefs.h.

Referenced by GetNamesAndLabels(), and PopulateOrExchange().

◆ mSampleRateNames

TranslatableStrings QualityPrefs::mSampleRateNames
private

Definition at line 45 of file QualityPrefs.h.

Referenced by GetNamesAndLabels(), and PopulateOrExchange().

◆ mSampleRates

wxChoice* QualityPrefs::mSampleRates
private

Definition at line 48 of file QualityPrefs.h.

Referenced by OnSampleRateChoice(), and PopulateOrExchange().


The documentation for this class was generated from the following files:
QualityPrefs::mSampleRateNames
TranslatableStrings mSampleRateNames
Definition: QualityPrefs.h:45
AudioIOBase::StandardRates
static const int StandardRates[]
Array of common audio sample rates.
Definition: AudioIOBase.h:201
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
Dither::BestSetting
static EnumSetting< DitherType > BestSetting
Definition: Dither.h:29
QualityPrefs::mOtherSampleRate
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:49
Resample::FastMethodSetting
static EnumSetting< int > FastMethodSetting
Definition: Resample.h:42
Setting::Write
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:172
Format
Abstract base class used in importing a file.
QualitySettings::SampleFormatSetting
PROJECT_RATE_API EnumSetting< sampleFormat > SampleFormatSetting
Definition: QualitySettings.cpp:20
XO
#define XO(s)
Definition: Internat.h:31
ShuttleGuiBase::TieNumberAsChoice
virtual wxChoice * TieNumberAsChoice(const TranslatableString &Prompt, const IntSetting &Setting, const TranslatableStrings &Choices, const std::vector< int > *pInternalChoices=nullptr, int iNoMatchSelector=0)
Definition: ShuttleGui.cpp:2011
ID_SAMPLE_RATE_CHOICE
#define ID_SAMPLE_RATE_CHOICE
Definition: QualityPrefs.cpp:32
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
QualityPrefs::mSampleRateLabels
std::vector< int > mSampleRateLabels
Definition: QualityPrefs.h:46
AudioIOBase::NumStandardRates
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIOBase.h:203
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2274
Setting::Read
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:128
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:971
QualityPrefs::mOtherSampleRateValue
int mOtherSampleRateValue
Definition: QualityPrefs.h:50
XXO
#define XXO(s)
Definition: Internat.h:44
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:938
ShuttleGuiBase::EndHorizontalLay
void EndHorizontalLay()
Definition: ShuttleGui.cpp:1177
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
QualityPrefs::mSampleRates
wxChoice * mSampleRates
Definition: QualityPrefs.h:48
QualityPrefs::OnSampleRateChoice
void OnSampleRateChoice(wxCommandEvent &e)
Definition: QualityPrefs.cpp:192
QualitySettings::DefaultSampleRate
PROJECT_RATE_API IntSetting DefaultSampleRate
Definition: QualitySettings.cpp:15
ShuttleGuiBase::TieNumericTextBox
wxTextCtrl * TieNumericTextBox(const TranslatableString &Prompt, int &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1673
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:893
eIsSavingToPrefs
@ eIsSavingToPrefs
Definition: ShuttleGui.h:48
QualityPrefs::Populate
void Populate()
Definition: QualityPrefs.cpp:65
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
InitDitherers
void InitDitherers()
Definition: SampleFormat.cpp:53
QualityPrefs::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: QualityPrefs.cpp:115
QualityPrefs::GetNamesAndLabels
void GetNamesAndLabels()
Definition: QualityPrefs.cpp:87
QUALITY_PREFS_PLUGIN_SYMBOL
#define QUALITY_PREFS_PLUGIN_SYMBOL
Definition: QualityPrefs.h:26
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:238
ShuttleGuiBase::SetBorder
void SetBorder(int Border)
Definition: ShuttleGui.h:489
eIsCreatingFromPrefs
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:47
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:922
Resample::BestMethodSetting
static EnumSetting< int > BestMethodSetting
Definition: Resample.h:43
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
Dither::FastSetting
static EnumSetting< DitherType > FastSetting
Definition: Dither.h:28
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
PrefsPanel::PrefsPanel
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90