/********************************************************************** Audacity: A Digital Audio Editor QualityPrefs.cpp Joshua Haberman James Crook *******************************************************************//** \class QualityPrefs \brief A PrefsPanel used for setting audio quality. *//*******************************************************************/ #include "../Audacity.h" #include #include #include #include #include "../AudioIO.h" #include "../Dither.h" #include "../Prefs.h" #include "../Resample.h" #include "../SampleFormat.h" #include "../ShuttleGui.h" #include "QualityPrefs.h" #define ID_SAMPLE_RATE_CHOICE 7001 BEGIN_EVENT_TABLE(QualityPrefs, wxPanel) EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice) END_EVENT_TABLE() QualityPrefs::QualityPrefs(wxWindow * parent): PrefsPanel(parent) { SetLabel(_("Quality")); // Provide visual label SetName(_("Quality")); // Provide audible label mSampleRates = NULL; // Pointers to controls. mOtherSampleRate = NULL; Populate( ); } void QualityPrefs::Populate( ) { // First any pre-processing for constructing the GUI. GetNamesAndLabels(); gPrefs->Read( wxT("/SamplingRate/DefaultProjectSampleRate"), &mOtherSampleRateValue, 44100 ); //------------------------- Main section -------------------- // Now construct the GUI itself. // Use 'eIsCreatingFromPrefs' so that the GUI is // initialised with values from gPrefs. ShuttleGui S(this, eIsCreatingFromPrefs); PopulateOrExchange(S); // ----------------------- End of main section -------------- wxCommandEvent e; OnSampleRateChoice(e); // Enable/disable the control. } /// 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. void QualityPrefs::GetNamesAndLabels() { //------------ Dither Names mmDitherNames.Add( _("None") ); mmDitherLabels.Add( Dither::none ); mmDitherNames.Add( _("Rectangle") ); mmDitherLabels.Add( Dither::rectangle ); mmDitherNames.Add( _("Triangle") ); mmDitherLabels.Add( Dither::triangle ); mmDitherNames.Add( _("Shaped") ); mmDitherLabels.Add( Dither::shaped ); //------------ Sample Rate Names // JKC: I don't understand the following comment. // Can someone please explain or correct it? // XXX: This should use a previously changed, but not yet saved // sound card setting from the "I/O" preferences tab. // LLL: It means that until the user clicks "Ok" in preferences, the // GetSupportedSampleRates() call should use the devices they // may have changed on the Audio I/O page. As coded, the sample // rates it will return could be completely invalid as they will // be what's supported by the devices that were selected BEFORE // coming into preferences. // // GetSupportedSampleRates() allows passing in device names, but // how do you get at them as they are on the Audio I/O page???? for (int i=0; iIsEnabled() ) { gPrefs->Write( wxT("/SamplingRate/DefaultProjectSampleRate"), mOtherSampleRateValue ); } // Tell CopySamples() to use these ditherers now InitDitherers(); return true; } /// Enables or disables the Edit box depending on /// whether we selected 'Other...' or not. void QualityPrefs::OnSampleRateChoice(wxCommandEvent& evt) { int sel = mSampleRates->GetSelection(); mOtherSampleRate->Enable(sel == mSampleRates->GetCount() - 1); } QualityPrefs::~QualityPrefs() { } // Indentation settings for Vim and Emacs and unique identifier for Arch, a // version control system. Please do not modify past this point. // // Local Variables: // c-basic-offset: 3 // indent-tabs-mode: nil // End: // // vim: et sts=3 sw=3 // arch-tag: 135e3a62-5d8a-472d-ab66-462a5157e6b8