mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-28 14:39:28 +02:00
upgrade to var-rate resampling for libsoxr
This commit is contained in:
parent
5e4cb4067f
commit
1d7f0e15c5
@ -125,7 +125,42 @@
|
|||||||
|
|
||||||
|
|
||||||
// variable-rate resampler(s)
|
// variable-rate resampler(s)
|
||||||
#if USE_LIBRESAMPLE
|
#if USE_LIBSOXR
|
||||||
|
|
||||||
|
#include <soxr.h>
|
||||||
|
|
||||||
|
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||||
|
: Resample(useBestMethod)
|
||||||
|
{
|
||||||
|
soxr_quality_spec_t q_spec = soxr_quality_spec(SOXR_HQ, SOXR_VR);
|
||||||
|
mHandle = (void *)soxr_create(1, dMinFactor, 1, 0, 0, &q_spec, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VarRateResample::~VarRateResample()
|
||||||
|
{
|
||||||
|
soxr_delete((soxr_t)mHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
int VarRateResample::Process(double factor,
|
||||||
|
float *inBuffer,
|
||||||
|
int inBufferLen,
|
||||||
|
bool lastFlag,
|
||||||
|
int *inBufferUsed,
|
||||||
|
float *outBuffer,
|
||||||
|
int outBufferLen)
|
||||||
|
{
|
||||||
|
//vvvvv Not defined: soxr_set_io_ratio((soxr_t)mHandle, 1/factor, 0);
|
||||||
|
|
||||||
|
size_t idone , odone;
|
||||||
|
inBufferLen = lastFlag? ~inBufferLen : inBufferLen;
|
||||||
|
soxr_process((soxr_t)mHandle,
|
||||||
|
inBuffer , (size_t)inBufferLen , &idone,
|
||||||
|
outBuffer, (size_t)outBufferLen, &odone);
|
||||||
|
*inBufferUsed = (int)idone;
|
||||||
|
return (int)odone;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif USE_LIBRESAMPLE
|
||||||
|
|
||||||
#include "libresample.h"
|
#include "libresample.h"
|
||||||
|
|
||||||
@ -283,7 +318,6 @@
|
|||||||
*inBufferUsed = (int)data.input_frames_used;
|
*inBufferUsed = (int)data.input_frames_used;
|
||||||
return (int)data.output_frames_gen;
|
return (int)data.output_frames_gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // no var-rate resampler
|
#else // no var-rate resampler
|
||||||
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
|
||||||
: Resample(useBestMethod)
|
: Resample(useBestMethod)
|
||||||
|
@ -150,7 +150,7 @@ class VarRateResample : public Resample
|
|||||||
virtual ~VarRateResample();
|
virtual ~VarRateResample();
|
||||||
|
|
||||||
// Override base class methods only if we actually have a var-rate library.
|
// Override base class methods only if we actually have a var-rate library.
|
||||||
#if USE_LIBRESAMPLE || USE_LIBSAMPLERATE
|
#if USE_LIBRESAMPLE || USE_LIBSAMPLERATE || USE_LIBSOXR
|
||||||
static int GetNumMethods();
|
static int GetNumMethods();
|
||||||
static wxString GetMethodName(int index);
|
static wxString GetMethodName(int index);
|
||||||
|
|
||||||
|
@ -24,13 +24,14 @@
|
|||||||
|
|
||||||
// Resamplers.
|
// Resamplers.
|
||||||
// Only one of each type of resampler (constant or variable rate) should be defined.
|
// Only one of each type of resampler (constant or variable rate) should be defined.
|
||||||
// libsoxr is used for constant-rate resampling.
|
// libsoxr is used for constant-rate and var-rat resampling.
|
||||||
// It's currently our only const-rate resampler, so should always be #defined.
|
// libsoxr currently our only const-rate resampler, so should always be #defined.
|
||||||
#define USE_LIBSOXR 1
|
#define USE_LIBSOXR 1
|
||||||
// Should build only one of libresample or libsamplerate for variable-rate resampling,
|
// Should build only one of libsoxr, libresample, or libsamplerate for variable-rate resampling,
|
||||||
// but if both are defined, USE_LIBRESAMPLE is used and USE_LIBSAMPLERATE is not.
|
// but if more than one are defined, priority is libsoxr over libresample over libsamplerate.
|
||||||
// Should always have one or the other #defined.
|
// We cannot release builds with libsamplerate, due to licensing.
|
||||||
#define USE_LIBRESAMPLE 1
|
// Standard configuration is to have only USE_LIBSOXR #defined.
|
||||||
|
#undef USE_LIBRESAMPLE
|
||||||
#undef USE_LIBSAMPLERATE
|
#undef USE_LIBSAMPLERATE
|
||||||
|
|
||||||
#define USE_LIBTWOLAME 1
|
#define USE_LIBTWOLAME 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user