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

View File

@ -55,6 +55,44 @@ static EncodedEnumSetting formatSetting{
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)
EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice)
@ -97,12 +135,6 @@ void QualityPrefs::Populate()
/// The corresponding labels are what gets stored.
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
// JKC: I don't understand the following comment.
// 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 */
S.TieChoice(_("&Dither:"),
wxT("/Quality/DitherAlgorithm"),
(int) DitherType::none,
mDitherNames,
mDitherLabels);
fastDitherSetting);
}
S.EndMultiColumn();
}
@ -196,10 +225,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
/* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
S.TieChoice(_("Dit&her:"),
wxT("/Quality/HQDitherAlgorithm"),
(int) DitherType::shaped,
mDitherNames,
mDitherLabels);
bestDitherSetting);
}
S.EndMultiColumn();
}
@ -250,3 +276,13 @@ sampleFormat QualityPrefs::SampleFormatChoice()
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 DitherType FastDitherChoice();
static DitherType BestDitherChoice();
private:
void Populate();
void GetNamesAndLabels();
void OnSampleRateChoice(wxCommandEvent & e);
wxArrayString mDitherNames;
std::vector<int> mDitherLabels;
wxArrayString mSampleRateNames;
std::vector<int> mSampleRateLabels;