Audacity 3.2.0
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 () const override
 
TranslatableString GetDescription () const 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 bool Commit ()=0
 
virtual PluginPath GetPath () const override
 
virtual VendorSymbol GetVendor () const override
 
virtual wxString GetVersion () const override
 
virtual bool ShowsPreviewButton ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual ManualPageID HelpPageName ()
 If not empty string, the Help button is added below the panel. More...
 
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}
#define XO(s)
Definition: Internat.h:31
PrefsPanel(wxWindow *parent, wxWindowID winid, const TranslatableString &title)
Definition: PrefsPanel.h:90

◆ ~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{
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
212
213 return true;
214}
FileConfig * gPrefs
Definition: Prefs.cpp:71
void InitDitherers()
@ eIsSavingToPrefs
Definition: ShuttleGui.h:49
#define S(N)
Definition: ToChars.cpp:64
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:49
int mOtherSampleRateValue
Definition: QualityPrefs.h:50
void PopulateOrExchange(ShuttleGui &S) override
bool Write(const T &value)
Write value to config and return true if successful.
Definition: Prefs.h:252
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
PROJECT_RATE_API IntSetting DefaultSampleRate

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

Here is the call graph for this function:

◆ GetDescription()

TranslatableString QualityPrefs::GetDescription ( ) const
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}
static const int StandardRates[]
Array of common audio sample rates.
Definition: AudioIOBase.h:190
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIOBase.h:192
Abstract base class used in importing a file.
TranslatableStrings mSampleRateNames
Definition: QualityPrefs.h:45
std::vector< int > mSampleRateLabels
Definition: QualityPrefs.h:46

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

Referenced by Populate().

Here is the caller graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol QualityPrefs::GetSymbol ( ) const
overridevirtual

Implements ComponentInterface.

Definition at line 50 of file QualityPrefs.cpp.

51{
53}
#define QUALITY_PREFS_PLUGIN_SYMBOL
Definition: QualityPrefs.h:26

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}
wxChoice * mSampleRates
Definition: QualityPrefs.h:48

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}
@ eIsCreatingFromPrefs
Definition: ShuttleGui.h:48
void OnSampleRateChoice(wxCommandEvent &e)
void GetNamesAndLabels()
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined *‍/
Definition: Prefs.h:200

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

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.
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}
#define XXO(s)
Definition: Internat.h:44
#define ID_SAMPLE_RATE_CHOICE
static EnumSetting< DitherType > BestSetting
Definition: Dither.h:29
static EnumSetting< DitherType > FastSetting
Definition: Dither.h:28
static EnumSetting< int > FastMethodSetting
Definition: Resample.h:42
static EnumSetting< int > BestMethodSetting
Definition: Resample.h:43
PROJECT_RATE_API EnumSetting< sampleFormat > SampleFormatSetting

References Resample::BestMethodSetting, Dither::BestSetting, QualitySettings::DefaultSampleRate, Resample::FastMethodSetting, Dither::FastSetting, ID_SAMPLE_RATE_CHOICE, mOtherSampleRate, mOtherSampleRateValue, mSampleRateLabels, mSampleRateNames, mSampleRates, S, QualitySettings::SampleFormatSetting, XO, and XXO.

Referenced by Commit(), and Populate().

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: