mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 22:58:39 +02:00
Redo resampler method choices in Quality preferences
This commit is contained in:
parent
2ea5741e2e
commit
bccf8f92cd
@ -26,6 +26,7 @@
|
|||||||
#include "Prefs.h"
|
#include "Prefs.h"
|
||||||
#include "TranslatableStringArray.h"
|
#include "TranslatableStringArray.h"
|
||||||
#include "Internat.h"
|
#include "Internat.h"
|
||||||
|
#include "../include/audacity/IdentInterface.h"
|
||||||
|
|
||||||
#include <soxr.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[] = {
|
bestMethodKey,
|
||||||
XO("Low Quality (Fastest)"),
|
methodNames, numMethods,
|
||||||
XO("Medium Quality"),
|
bestMethodDefault,
|
||||||
XO("High Quality"),
|
|
||||||
XO("Best Quality (Slowest)")
|
|
||||||
};
|
|
||||||
|
|
||||||
wxASSERT( GetNumMethods() ==
|
intChoicesMethod,
|
||||||
sizeof(soxr_method_names) / sizeof(*soxr_method_names) );
|
oldBestMethodKey
|
||||||
|
};
|
||||||
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;}
|
|
||||||
|
|
||||||
|
//////////
|
||||||
std::pair<size_t, size_t>
|
std::pair<size_t, size_t>
|
||||||
Resample::Process(double factor,
|
Resample::Process(double factor,
|
||||||
float *inBuffer,
|
float *inBuffer,
|
||||||
@ -121,7 +132,7 @@ std::pair<size_t, size_t>
|
|||||||
void Resample::SetMethod(const bool useBestMethod)
|
void Resample::SetMethod(const bool useBestMethod)
|
||||||
{
|
{
|
||||||
if (useBestMethod)
|
if (useBestMethod)
|
||||||
mMethod = gPrefs->Read(GetBestMethodKey(), GetBestMethodDefault());
|
mMethod = BestMethodSetting.ReadInt();
|
||||||
else
|
else
|
||||||
mMethod = gPrefs->Read(GetFastMethodKey(), GetFastMethodDefault());
|
mMethod = FastMethodSetting.ReadInt();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
#include "SampleFormat.h"
|
#include "SampleFormat.h"
|
||||||
|
|
||||||
|
class EncodedEnumSetting;
|
||||||
|
|
||||||
struct soxr;
|
struct soxr;
|
||||||
extern "C" void soxr_delete(soxr*);
|
extern "C" void soxr_delete(soxr*);
|
||||||
struct soxr_deleter {
|
struct soxr_deleter {
|
||||||
@ -43,13 +45,8 @@ class Resample final
|
|||||||
Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
|
Resample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor);
|
||||||
~Resample();
|
~Resample();
|
||||||
|
|
||||||
static int GetNumMethods();
|
static EncodedEnumSetting FastMethodSetting;
|
||||||
static wxString GetMethodName(int index);
|
static EncodedEnumSetting BestMethodSetting;
|
||||||
|
|
||||||
static const wxString GetFastMethodKey();
|
|
||||||
static const wxString GetBestMethodKey();
|
|
||||||
static int GetFastMethodDefault();
|
|
||||||
static int GetBestMethodDefault();
|
|
||||||
|
|
||||||
/** @brief Main processing function. Resamples from the input buffer to the
|
/** @brief Main processing function. Resamples from the input buffer to the
|
||||||
* output buffer.
|
* output buffer.
|
||||||
|
@ -56,7 +56,6 @@ static EncodedEnumSetting formatSetting{
|
|||||||
};
|
};
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
|
||||||
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)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@ -128,13 +127,6 @@ void QualityPrefs::GetNamesAndLabels()
|
|||||||
|
|
||||||
// The label for the 'Other...' case can be any value at all.
|
// The label for the 'Other...' case can be any value at all.
|
||||||
mSampleRateLabels.push_back(44100); // If chosen, this value will be overwritten
|
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)
|
void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
||||||
@ -182,10 +174,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.StartMultiColumn(2, wxEXPAND);
|
S.StartMultiColumn(2, wxEXPAND);
|
||||||
{
|
{
|
||||||
S.TieChoice(_("Sample Rate Con&verter:"),
|
S.TieChoice(_("Sample Rate Con&verter:"),
|
||||||
Resample::GetFastMethodKey(),
|
Resample::FastMethodSetting);
|
||||||
Resample::GetFastMethodDefault(),
|
|
||||||
mConverterNames,
|
|
||||||
mConverterLabels);
|
|
||||||
|
|
||||||
/* 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:"),
|
||||||
@ -203,10 +192,7 @@ void QualityPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.StartMultiColumn(2);
|
S.StartMultiColumn(2);
|
||||||
{
|
{
|
||||||
S.TieChoice(_("Sample Rate Conver&ter:"),
|
S.TieChoice(_("Sample Rate Conver&ter:"),
|
||||||
Resample::GetBestMethodKey(),
|
Resample::BestMethodSetting);
|
||||||
Resample::GetBestMethodDefault(),
|
|
||||||
mConverterNames,
|
|
||||||
mConverterLabels);
|
|
||||||
|
|
||||||
/* 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:"),
|
||||||
|
@ -45,8 +45,6 @@ class QualityPrefs final : public PrefsPanel
|
|||||||
std::vector<int> mDitherLabels;
|
std::vector<int> mDitherLabels;
|
||||||
wxArrayString mSampleRateNames;
|
wxArrayString mSampleRateNames;
|
||||||
std::vector<int> mSampleRateLabels;
|
std::vector<int> mSampleRateLabels;
|
||||||
wxArrayString mConverterNames;
|
|
||||||
std::vector<int> mConverterLabels;
|
|
||||||
|
|
||||||
wxChoice *mSampleRates;
|
wxChoice *mSampleRates;
|
||||||
wxTextCtrl *mOtherSampleRate;
|
wxTextCtrl *mOtherSampleRate;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user