Make the base class set mMethod, so descendants don't need to duplicate that code.
This commit is contained in:
parent
29768c2489
commit
c889930a0c
|
@ -54,13 +54,8 @@
|
|||
#include <soxr.h>
|
||||
|
||||
ConstRateResample::ConstRateResample(const bool useBestMethod, const double dFactor)
|
||||
: Resample()
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
if (useBestMethod)
|
||||
mMethod = GetBestMethod();
|
||||
else
|
||||
mMethod = GetFastMethod();
|
||||
|
||||
soxr_quality_spec_t q_spec = soxr_quality_spec("\0\1\4\6"[mMethod], 0);
|
||||
mHandle = (void *)soxr_create(1, dFactor, 1, 0, 0, &q_spec, 0);
|
||||
}
|
||||
|
@ -120,7 +115,7 @@
|
|||
|
||||
#else // no const-rate resampler
|
||||
ConstRateResample::ConstRateResample(const bool useBestMethod, const double dFactor)
|
||||
: Resample()
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -136,13 +131,8 @@
|
|||
#include "libresample.h"
|
||||
|
||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||
: Resample()
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
if (useBestMethod)
|
||||
mMethod = GetBestMethod();
|
||||
else
|
||||
mMethod = GetFastMethod();
|
||||
|
||||
mHandle = resample_open(mMethod, dMinFactor, dMaxFactor);
|
||||
}
|
||||
|
||||
|
@ -204,7 +194,7 @@
|
|||
#include <samplerate.h>
|
||||
|
||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||
: Resample()
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
if (!src_is_valid_ratio (dMinFactor) || !src_is_valid_ratio (dMaxFactor)) {
|
||||
fprintf(stderr, "libsamplerate supports only resampling factors between 1/SRC_MAX_RATIO and SRC_MAX_RATIO.\n");
|
||||
|
@ -213,11 +203,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (useBestMethod)
|
||||
mMethod = GetBestMethod();
|
||||
else
|
||||
mMethod = GetFastMethod();
|
||||
|
||||
int err;
|
||||
SRC_STATE *state = src_new(mMethod, 1, &err);
|
||||
mHandle = (void *)state;
|
||||
|
@ -306,7 +291,7 @@
|
|||
|
||||
#else // no var-rate resampler
|
||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||
: Resample()
|
||||
: Resample(useBestMethod)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,13 @@ class Resample
|
|||
/// specify the range of factors that will be used, if you plan
|
||||
/// to vary the factor over time. Otherwise set minFactor and
|
||||
/// maxFactor to the same value for optimized performance.
|
||||
Resample()
|
||||
Resample(const bool useBestMethod)
|
||||
{
|
||||
mMethod = 0;
|
||||
if (useBestMethod)
|
||||
mMethod = GetBestMethod();
|
||||
else
|
||||
mMethod = GetFastMethod();
|
||||
|
||||
mHandle = NULL;
|
||||
mInitial = false;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user