Audacity  2.3.1
Public Member Functions | Static 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:
PrefsPanel wxPanelWrapper wxTabTraversalWrapper< wxPanel >

Public Member Functions

 QualityPrefs (wxWindow *parent, wxWindowID winid)
 
virtual ~QualityPrefs ()
 
bool Commit () override
 
wxString HelpPageName () override
 
void PopulateOrExchange (ShuttleGui &S) override
 
- Public Member Functions inherited from PrefsPanel
 PrefsPanel (wxWindow *parent, wxWindowID winid, const wxString &title)
 
virtual ~PrefsPanel ()
 
virtual void Preview ()
 
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 wxString &name=_("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const wxString &name=_("Panel"))
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&...args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static sampleFormat SampleFormatChoice ()
 
static DitherType FastDitherChoice ()
 
static DitherType BestDitherChoice ()
 

Private Member Functions

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

Private Attributes

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

Detailed Description

A PrefsPanel used for setting audio quality.

Definition at line 28 of file QualityPrefs.h.

Constructor & Destructor Documentation

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

Definition at line 101 of file QualityPrefs.cpp.

103 : PrefsPanel(parent, winid, _("Quality"))
104 {
105  Populate();
106 }
PrefsPanel(wxWindow *parent, wxWindowID winid, const wxString &title)
Definition: PrefsPanel.h:53
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
QualityPrefs::~QualityPrefs ( )
virtual

Definition at line 108 of file QualityPrefs.cpp.

109 {
110 }

Member Function Documentation

DitherType QualityPrefs::BestDitherChoice ( )
static

Definition at line 284 of file QualityPrefs.cpp.

References bestDitherSetting, and EncodedEnumSetting::ReadInt().

Referenced by InitDitherers().

285 {
287 }
virtual int ReadInt() const
Definition: Prefs.cpp:420
static EncodedEnumSetting bestDitherSetting
DitherType
These ditherers are currently available:
Definition: Dither.h:17
bool QualityPrefs::Commit ( )
overridevirtual

Implements PrefsPanel.

Definition at line 245 of file QualityPrefs.cpp.

References eIsSavingToPrefs, gPrefs, InitDitherers(), mOtherSampleRate, mOtherSampleRateValue, and PopulateOrExchange().

246 {
247  ShuttleGui S(this, eIsSavingToPrefs);
249 
250  // The complex compound control may have value 'other' in which case the
251  // value in prefs comes from the second field.
252  if (mOtherSampleRate->IsEnabled()) {
253  gPrefs->Write(wxT("/SamplingRate/DefaultProjectSampleRate"), mOtherSampleRateValue);
254  gPrefs->Flush();
255  }
256 
257  // Tell CopySamples() to use these ditherers now
258  InitDitherers();
259 
260  return true;
261 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void PopulateOrExchange(ShuttleGui &S) override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void InitDitherers()
int mOtherSampleRateValue
Definition: QualityPrefs.h:53
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:52
DitherType QualityPrefs::FastDitherChoice ( )
static

Definition at line 279 of file QualityPrefs.cpp.

References fastDitherSetting, and EncodedEnumSetting::ReadInt().

Referenced by InitDitherers().

280 {
282 }
virtual int ReadInt() const
Definition: Prefs.cpp:420
DitherType
These ditherers are currently available:
Definition: Dither.h:17
static EncodedEnumSetting fastDitherSetting
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 136 of file QualityPrefs.cpp.

References _(), mSampleRateLabels, mSampleRateNames, AudioIO::NumStandardRates, and AudioIO::StandardRates.

Referenced by Populate().

137 {
138  //------------ Sample Rate Names
139  // JKC: I don't understand the following comment.
140  // Can someone please explain or correct it?
141  // XXX: This should use a previously changed, but not yet saved
142  // sound card setting from the "I/O" preferences tab.
143  // LLL: It means that until the user clicks "Ok" in preferences, the
144  // GetSupportedSampleRates() call should use the devices they
145  // may have changed on the Audio I/O page. As coded, the sample
146  // rates it will return could be completely invalid as they will
147  // be what's supported by the devices that were selected BEFORE
148  // coming into preferences.
149  //
150  // GetSupportedSampleRates() allows passing in device names, but
151  // how do you get at them as they are on the Audio I/O page????
152  for (int i = 0; i < AudioIO::NumStandardRates; i++) {
153  int iRate = AudioIO::StandardRates[i];
154  mSampleRateLabels.push_back(iRate);
155  mSampleRateNames.Add(wxString::Format(wxT("%i Hz"), iRate));
156  }
157 
158  mSampleRateNames.Add(_("Other..."));
159 
160  // The label for the 'Other...' case can be any value at all.
161  mSampleRateLabels.push_back(44100); // If chosen, this value will be overwritten
162 }
wxArrayString mSampleRateNames
Definition: QualityPrefs.h:48
std::vector< int > mSampleRateLabels
Definition: QualityPrefs.h:49
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIO.h:1039
static const int StandardRates[]
Array of common audio sample rates.
Definition: AudioIO.h:1037
wxString QualityPrefs::HelpPageName ( )
overridevirtual

Reimplemented from PrefsPanel.

Definition at line 263 of file QualityPrefs.cpp.

264 {
265  return "Quality_Preferences";
266 }
void QualityPrefs::OnSampleRateChoice ( wxCommandEvent &  e)
private

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

Definition at line 239 of file QualityPrefs.cpp.

References mOtherSampleRate, and mSampleRates.

Referenced by Populate().

240 {
241  int sel = mSampleRates->GetSelection();
242  mOtherSampleRate->Enable(sel == (int)mSampleRates->GetCount() - 1);
243 }
wxChoice * mSampleRates
Definition: QualityPrefs.h:51
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:52
void QualityPrefs::Populate ( )
private

Definition at line 112 of file QualityPrefs.cpp.

References eIsCreatingFromPrefs, GetNamesAndLabels(), gPrefs, mOtherSampleRateValue, OnSampleRateChoice(), and PopulateOrExchange().

113 {
114  // First any pre-processing for constructing the GUI.
116  gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
118  44100);
119 
120  //------------------------- Main section --------------------
121  // Now construct the GUI itself.
122  // Use 'eIsCreatingFromPrefs' so that the GUI is
123  // initialised with values from gPrefs.
126  // ----------------------- End of main section --------------
127 
128  wxCommandEvent e;
129  OnSampleRateChoice(e); // Enable/disable the control.
130 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
void PopulateOrExchange(ShuttleGui &S) override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI...
Definition: ShuttleGui.h:409
void GetNamesAndLabels()
int mOtherSampleRateValue
Definition: QualityPrefs.h:53
void OnSampleRateChoice(wxCommandEvent &e)
void QualityPrefs::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 164 of file QualityPrefs.cpp.

References _(), ShuttleGuiBase::AddPrompt(), bestDitherSetting, Resample::BestMethodSetting, ShuttleGuiBase::EndHorizontalLay(), ShuttleGuiBase::EndMultiColumn(), ShuttleGuiBase::EndScroller(), ShuttleGuiBase::EndStatic(), fastDitherSetting, Resample::FastMethodSetting, formatSetting, AudioIO::GetOptimalSupportedSampleRate(), ShuttleGui::Id(), ID_SAMPLE_RATE_CHOICE, mOtherSampleRate, mOtherSampleRateValue, mSampleRateLabels, mSampleRateNames, mSampleRates, ShuttleGuiBase::SetBorder(), ShuttleGuiBase::SetNoMatchSelector(), ShuttleGuiBase::StartMultiColumn(), ShuttleGuiBase::StartScroller(), ShuttleGuiBase::StartStatic(), ShuttleGuiBase::TieChoice(), ShuttleGuiBase::TieNumberAsChoice(), and ShuttleGuiBase::TieNumericTextBox().

Referenced by Commit(), and Populate().

165 {
166  S.SetBorder(2);
167  S.StartScroller();
168 
169  S.StartStatic(_("Sampling"));
170  {
171  S.StartMultiColumn(2);
172  {
173  S.AddPrompt(_("Default Sample &Rate:"));
174 
175  S.StartMultiColumn(2);
176  {
177  // If the value in Prefs isn't in the list, then we want
178  // the last item, 'Other...' to be shown.
179  S.SetNoMatchSelector(mSampleRateNames.GetCount() - 1);
180  // First the choice...
181  // We make sure it uses the ID we want, so that we get changes
183  // We make sure we have a pointer to it, so that we can drive it.
185  wxT("/SamplingRate/DefaultProjectSampleRate"),
189 
190  // Now do the edit box...
193  15);
194  }
195  S.EndHorizontalLay();
196 
197  S.TieChoice(_("Default Sample &Format:"),
198  formatSetting);
199  }
200  S.EndMultiColumn();
201  }
202  S.EndStatic();
203 
204  S.StartStatic(_("Real-time Conversion"));
205  {
206  S.StartMultiColumn(2, wxEXPAND);
207  {
208  S.TieChoice(_("Sample Rate Con&verter:"),
210 
211  /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
212  S.TieChoice(_("&Dither:"),
214  }
215  S.EndMultiColumn();
216  }
217  S.EndStatic();
218 
219  S.StartStatic(_("High-quality Conversion"));
220  {
221  S.StartMultiColumn(2);
222  {
223  S.TieChoice(_("Sample Rate Conver&ter:"),
225 
226  /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
227  S.TieChoice(_("Dit&her:"),
229  }
230  S.EndMultiColumn();
231  }
232  S.EndStatic();
233  S.EndScroller();
234 
235 }
wxChoice * TieChoice(const wxString &Prompt, WrappedType &WrappedRef, const wxArrayString *pChoices)
#define ID_SAMPLE_RATE_CHOICE
wxArrayString mSampleRateNames
Definition: QualityPrefs.h:48
std::vector< int > mSampleRateLabels
Definition: QualityPrefs.h:49
void SetNoMatchSelector(int iSelector)
Definition: ShuttleGui.h:288
void EndMultiColumn()
static EncodedEnumSetting FastMethodSetting
Definition: Resample.h:48
static int GetOptimalSupportedSampleRate()
Get a supported sample rate which can be used a an optimal default.
Definition: AudioIO.cpp:3085
void EndScroller()
Definition: ShuttleGui.cpp:836
static EncodedEnumSetting bestDitherSetting
wxChoice * mSampleRates
Definition: QualityPrefs.h:51
static EncodedEnumSetting BestMethodSetting
Definition: Resample.h:49
void EndHorizontalLay()
void AddPrompt(const wxString &Prompt)
Right aligned text string.
Definition: ShuttleGui.cpp:239
static EncodedEnumSetting formatSetting
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:803
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
ShuttleGui & Id(int id)
int mOtherSampleRateValue
Definition: QualityPrefs.h:53
wxTextCtrl * mOtherSampleRate
Definition: QualityPrefs.h:52
wxTextCtrl * TieNumericTextBox(const wxString &Prompt, WrappedType &WrappedRef, const int nChars)
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
virtual wxChoice * TieNumberAsChoice(const wxString &Prompt, const wxString &SettingName, const int Default, const wxArrayString &Choices, const std::vector< int > &InternalChoices)
wxStaticBox * StartStatic(const wxString &Str, int iProp=0)
Definition: ShuttleGui.cpp:771
void SetBorder(int Border)
Definition: ShuttleGui.h:286
static EncodedEnumSetting fastDitherSetting
sampleFormat QualityPrefs::SampleFormatChoice ( )
static

Member Data Documentation

wxTextCtrl* QualityPrefs::mOtherSampleRate
private

Definition at line 52 of file QualityPrefs.h.

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

int QualityPrefs::mOtherSampleRateValue
private

Definition at line 53 of file QualityPrefs.h.

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

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

Definition at line 49 of file QualityPrefs.h.

Referenced by GetNamesAndLabels(), and PopulateOrExchange().

wxArrayString QualityPrefs::mSampleRateNames
private

Definition at line 48 of file QualityPrefs.h.

Referenced by GetNamesAndLabels(), and PopulateOrExchange().

wxChoice* QualityPrefs::mSampleRates
private

Definition at line 51 of file QualityPrefs.h.

Referenced by OnSampleRateChoice(), and PopulateOrExchange().


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