1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-09-18 09:00:52 +02:00

Redo dither method choices in Quality preferences

This commit is contained in:
Paul Licameli 2018-03-24 22:33:53 -04:00
parent a3d12e1658
commit 24e651fe37
3 changed files with 56 additions and 21 deletions

View File

@ -44,6 +44,7 @@
#include "Prefs.h" #include "Prefs.h"
#include "Dither.h" #include "Dither.h"
#include "Internat.h" #include "Internat.h"
#include "prefs/QualityPrefs.h"
static DitherType gLowQualityDither = DitherType::none; static DitherType gLowQualityDither = DitherType::none;
static DitherType gHighQualityDither = DitherType::none; static DitherType gHighQualityDither = DitherType::none;
@ -52,11 +53,8 @@ static Dither gDitherAlgorithm;
void InitDitherers() void InitDitherers()
{ {
// Read dither preferences // Read dither preferences
gLowQualityDither = (DitherType) gLowQualityDither = QualityPrefs::FastDitherChoice();
gPrefs->Read(wxT("/Quality/DitherAlgorithm"), (long)DitherType::none); gHighQualityDither = QualityPrefs::BestDitherChoice();
gHighQualityDither = (DitherType)
gPrefs->Read(wxT("/Quality/HQDitherAlgorithm"), (long)DitherType::shaped);
} }
const wxChar *GetSampleFormatStr(sampleFormat format) const wxChar *GetSampleFormatStr(sampleFormat format)

View File

@ -55,6 +55,44 @@ static EncodedEnumSetting formatSetting{
wxT("/SamplingRate/DefaultProjectSampleFormat"), wxT("/SamplingRate/DefaultProjectSampleFormat"),
}; };
//////////
static const IdentInterfaceSymbol choicesDither[] = {
{ XO("None") },
{ XO("Rectangle") },
{ XO("Triangle") },
{ XO("Shaped") },
};
static const size_t nChoicesDither = WXSIZEOF( choicesDither );
static const int intChoicesDither[] = {
(int) DitherType::none,
(int) DitherType::rectangle,
(int) DitherType::triangle,
(int) DitherType::shaped,
};
static_assert(
nChoicesDither == WXSIZEOF( intChoicesDither ),
"size mismatch"
);
static const int defaultFastDither = 0; // none
static EncodedEnumSetting fastDitherSetting{
wxT("Quality/DitherAlgorithmChoice"),
choicesDither, nChoicesDither, defaultFastDither,
intChoicesDither,
wxT("Quality/DitherAlgorithm")
};
static const int defaultBestDither = 3; // shaped
static EncodedEnumSetting bestDitherSetting{
wxT("Quality/HQDitherAlgorithmChoice"),
choicesDither, nChoicesDither, defaultBestDither,
intChoicesDither,
wxT("Quality/HQDitherAlgorithm")
};
////////// //////////
BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel) BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel)
EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice) EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice)
@ -97,12 +135,6 @@ void QualityPrefs::Populate()
/// The corresponding labels are what gets stored. /// The corresponding labels are what gets stored.
void QualityPrefs::GetNamesAndLabels() void QualityPrefs::GetNamesAndLabels()
{ {
//------------ Dither Names
mDitherNames.Add(_("None")); mDitherLabels.push_back((int) DitherType::none);
mDitherNames.Add(_("Rectangle")); mDitherLabels.push_back((int) DitherType::rectangle);
mDitherNames.Add(_("Triangle")); mDitherLabels.push_back((int) DitherType::triangle);
mDitherNames.Add(_("Shaped")); mDitherLabels.push_back((int) DitherType::shaped);
//------------ Sample Rate Names //------------ Sample Rate Names
// JKC: I don't understand the following comment. // JKC: I don't understand the following comment.
// Can someone please explain or correct it? // Can someone please explain or correct it?
@ -178,10 +210,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
/* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */ /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
S.TieChoice(_("&Dither:"), S.TieChoice(_("&Dither:"),
wxT("/Quality/DitherAlgorithm"), fastDitherSetting);
(int) DitherType::none,
mDitherNames,
mDitherLabels);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -196,10 +225,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
/* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */ /* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
S.TieChoice(_("Dit&her:"), S.TieChoice(_("Dit&her:"),
wxT("/Quality/HQDitherAlgorithm"), bestDitherSetting);
(int) DitherType::shaped,
mDitherNames,
mDitherLabels);
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }
@ -250,3 +276,13 @@ sampleFormat QualityPrefs::SampleFormatChoice()
return (sampleFormat)formatSetting.ReadInt(); return (sampleFormat)formatSetting.ReadInt();
} }
DitherType QualityPrefs::FastDitherChoice()
{
return (DitherType) fastDitherSetting.ReadInt();
}
DitherType QualityPrefs::BestDitherChoice()
{
return (DitherType) bestDitherSetting.ReadInt();
}

View File

@ -37,13 +37,14 @@ class QualityPrefs final : public PrefsPanel
static sampleFormat SampleFormatChoice(); static sampleFormat SampleFormatChoice();
static DitherType FastDitherChoice();
static DitherType BestDitherChoice();
private: private:
void Populate(); void Populate();
void GetNamesAndLabels(); void GetNamesAndLabels();
void OnSampleRateChoice(wxCommandEvent & e); void OnSampleRateChoice(wxCommandEvent & e);
wxArrayString mDitherNames;
std::vector<int> mDitherLabels;
wxArrayString mSampleRateNames; wxArrayString mSampleRateNames;
std::vector<int> mSampleRateLabels; std::vector<int> mSampleRateLabels;