Redo resampler method choices in Quality preferences
This commit is contained in:
parent
2ea5741e2e
commit
bccf8f92cd
|
@ -26,6 +26,7 @@
|
|||
#include "Prefs.h"
|
||||
#include "TranslatableStringArray.h"
|
||||
#include "Internat.h"
|
||||
#include "../include/audacity/IdentInterface.h"
|
||||
|
||||
#include <soxr.h>
|
||||
|
||||
|
@ -50,47 +51,57 @@ Resample::~Resample()
|
|||
{
|
||||
}
|
||||
|
||||
int Resample::GetNumMethods() { return 4; }
|
||||
//////////
|
||||
static const IdentInterfaceSymbol methodNames[] = {
|
||||
{ wxT("LowQuality"), XO("Low Quality (Fastest)") },
|
||||
{ wxT("MediumQuality"), XO("Medium Quality") },
|
||||
{ wxT("HighQuality"), XO("High Quality") },
|
||||
{ wxT("BestQuality"), XO("Best Quality (Slowest)") }
|
||||
};
|
||||
|
||||
wxString Resample::GetMethodName(int index)
|
||||
static const size_t numMethods = WXSIZEOF(methodNames);
|
||||
|
||||
static const wxString fastMethodKey =
|
||||
wxT("/Quality/LibsoxrSampleRateConverterChoice");
|
||||
|
||||
static const wxString bestMethodKey =
|
||||
wxT("/Quality/LibsoxrHQSampleRateConverterChoice");
|
||||
|
||||
static const wxString oldFastMethodKey =
|
||||
wxT("/Quality/LibsoxrSampleRateConverter");
|
||||
|
||||
static const wxString oldBestMethodKey =
|
||||
wxT("/Quality/LibsoxrHQSampleRateConverter");
|
||||
|
||||
static const size_t fastMethodDefault = 1; // Medium Quality
|
||||
static const size_t bestMethodDefault = 3; // Best Quality
|
||||
|
||||
static const int intChoicesMethod[] = {
|
||||
0, 1, 2, 3
|
||||
};
|
||||
|
||||
static_assert( WXSIZEOF(intChoicesMethod) == numMethods, "size mismatch" );
|
||||
|
||||
EncodedEnumSetting Resample::FastMethodSetting{
|
||||
fastMethodKey,
|
||||
methodNames, numMethods,
|
||||
fastMethodDefault,
|
||||
|
||||
intChoicesMethod,
|
||||
oldFastMethodKey
|
||||
};
|
||||
|
||||
EncodedEnumSetting Resample::BestMethodSetting
|
||||
{
|
||||
static const wxString soxr_method_names[] = {
|
||||
XO("Low Quality (Fastest)"),
|
||||
XO("Medium Quality"),
|
||||
XO("High Quality"),
|
||||
XO("Best Quality (Slowest)")
|
||||
};
|
||||
bestMethodKey,
|
||||
methodNames, numMethods,
|
||||
bestMethodDefault,
|
||||
|
||||
wxASSERT( GetNumMethods() ==
|
||||
sizeof(soxr_method_names) / sizeof(*soxr_method_names) );
|
||||
|
||||
class MethodNamesArray final : public TranslatableStringArray
|
||||
{
|
||||
void Populate() override
|
||||
{
|
||||
for (auto &name : soxr_method_names)
|
||||
mContents.push_back( wxGetTranslation( name ) );
|
||||
}
|
||||
};
|
||||
|
||||
static MethodNamesArray theArray;
|
||||
|
||||
return theArray.Get()[ index ];
|
||||
}
|
||||
|
||||
const wxString Resample::GetFastMethodKey()
|
||||
{
|
||||
return wxT("/Quality/LibsoxrSampleRateConverter");
|
||||
}
|
||||
|
||||
const wxString Resample::GetBestMethodKey()
|
||||
{
|
||||
return wxT("/Quality/LibsoxrHQSampleRateConverter");
|
||||
}
|
||||
|
||||
int Resample::GetFastMethodDefault() {return 1;}
|
||||
int Resample::GetBestMethodDefault() {return 3;}
|
||||
intChoicesMethod,
|
||||
oldBestMethodKey
|
||||
};
|
||||
|
||||
//////////
|
||||
std::pair<size_t, size_t>
|
||||
Resample::Process(double factor,
|
||||
float *inBuffer,
|
||||
|
@ -121,7 +132,7 @@ std::pair<size_t, size_t>
|
|||
void Resample::SetMethod(const bool useBestMethod)
|
||||
{
|
||||
if (useBestMethod)
|
||||
mMethod = gPrefs->Read(GetBestMethodKey(), GetBestMethodDefault());
|
||||
mMethod = BestMethodSetting.ReadInt();
|
||||
else
|
||||
mMethod = gPrefs->Read(GetFastMethodKey(), GetFastMethodDefault());
|
||||
mMethod = FastMethodSetting.ReadInt();
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "SampleFormat.h"
|
||||
|
||||
class EncodedEnumSetting;
|
||||
|
||||
struct soxr;
|
||||
extern "C" void soxr_delete(soxr*);
|
||||
struct soxr_deleter {
|
||||
|
@ -43,13 +45,8 @@ class Resample final
|
|||
Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
|
||||
~Resample();
|
||||
|
||||
static int GetNumMethods();
|
||||
static wxString GetMethodName(int index);
|
||||
|
||||
static const wxString GetFastMethodKey();
|
||||
static const wxString GetBestMethodKey();
|
||||
static int GetFastMethodDefault();
|
||||
static int GetBestMethodDefault();
|
||||
static EncodedEnumSetting FastMethodSetting;
|
||||
static EncodedEnumSetting BestMethodSetting;
|
||||
|
||||
/** @brief Main processing function. Resamples from the input buffer to the
|
||||
* output buffer.
|
||||
|
|
|
@ -56,7 +56,6 @@ static EncodedEnumSetting formatSetting{
|
|||
};
|
||||
|
||||
//////////
|
||||
|
||||
BEGIN_EVENT_TABLE(QualityPrefs, PrefsPanel)
|
||||
EVT_CHOICE(ID_SAMPLE_RATE_CHOICE, QualityPrefs::OnSampleRateChoice)
|
||||
END_EVENT_TABLE()
|
||||
|
@ -128,13 +127,6 @@ void QualityPrefs::GetNamesAndLabels()
|
|||
|
||||
// The label for the 'Other...' case can be any value at all.
|
||||
mSampleRateLabels.push_back(44100); // If chosen, this value will be overwritten
|
||||
|
||||
//------------- Converter Names
|
||||
int numConverters = Resample::GetNumMethods();
|
||||
for (int i = 0; i < numConverters; i++) {
|
||||
mConverterNames.Add(Resample::GetMethodName(i));
|
||||
mConverterLabels.push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||
|
@ -182,10 +174,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
S.StartMultiColumn(2, wxEXPAND);
|
||||
{
|
||||
S.TieChoice(_("Sample Rate Con&verter:"),
|
||||
Resample::GetFastMethodKey(),
|
||||
Resample::GetFastMethodDefault(),
|
||||
mConverterNames,
|
||||
mConverterLabels);
|
||||
Resample::FastMethodSetting);
|
||||
|
||||
/* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
|
||||
S.TieChoice(_("&Dither:"),
|
||||
|
@ -203,10 +192,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||
S.StartMultiColumn(2);
|
||||
{
|
||||
S.TieChoice(_("Sample Rate Conver&ter:"),
|
||||
Resample::GetBestMethodKey(),
|
||||
Resample::GetBestMethodDefault(),
|
||||
mConverterNames,
|
||||
mConverterLabels);
|
||||
Resample::BestMethodSetting);
|
||||
|
||||
/* i18n-hint: technical term for randomization to reduce undesirable resampling artifacts */
|
||||
S.TieChoice(_("Dit&her:"),
|
||||
|
|
|
@ -45,8 +45,6 @@ class QualityPrefs final : public PrefsPanel
|
|||
std::vector<int> mDitherLabels;
|
||||
wxArrayString mSampleRateNames;
|
||||
std::vector<int> mSampleRateLabels;
|
||||
wxArrayString mConverterNames;
|
||||
std::vector<int> mConverterLabels;
|
||||
|
||||
wxChoice *mSampleRates;
|
||||
wxTextCtrl *mOtherSampleRate;
|
||||
|
|
Loading…
Reference in New Issue
Block a user