1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-21 16:37:12 +01:00

upgrade to var-rate resampling for libsoxr

This commit is contained in:
v.audacity
2012-12-17 06:48:11 +00:00
parent 5e4cb4067f
commit 1d7f0e15c5
3 changed files with 44 additions and 9 deletions

View File

@@ -125,7 +125,42 @@
// 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"
@@ -283,7 +318,6 @@
*inBufferUsed = (int)data.input_frames_used;
return (int)data.output_frames_gen;
}
#else // no var-rate resampler
VarRateResample::VarRateResample(const bool useBestMethod, const double dMinFactor, const double dMaxFactor)
: Resample(useBestMethod)