update soundtouch to svn revision 173
This commit is contained in:
parent
88d1195f93
commit
d8f5ecf3ce
|
@ -12,7 +12,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2009-01-11 13:34:24 +0200 (Sun, 11 Jan 2009) $
|
// Last changed : $Date: 2009-01-11 11:34:24 +0000 (Sun, 11 Jan 2009) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: AAFilter.cpp 45 2009-01-11 11:34:24Z oparviai $
|
// $Id: AAFilter.cpp 45 2009-01-11 11:34:24Z oparviai $
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $
|
// Last changed : $Date: 2008-02-10 16:26:55 +0000 (Sun, 10 Feb 2008) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: AAFilter.h 11 2008-02-10 16:26:55Z oparviai $
|
// $Id: AAFilter.h 11 2008-02-10 16:26:55Z oparviai $
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-08-30 22:45:25 +0300 (Thu, 30 Aug 2012) $
|
// Last changed : $Date: 2012-08-30 19:45:25 +0000 (Thu, 30 Aug 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: BPMDetect.cpp 149 2012-08-30 19:45:25Z oparviai $
|
// $Id: BPMDetect.cpp 149 2012-08-30 19:45:25Z oparviai $
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-08-30 22:53:44 +0300 (Thu, 30 Aug 2012) $
|
// Last changed : $Date: 2012-08-30 19:53:44 +0000 (Thu, 30 Aug 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: BPMDetect.h 150 2012-08-30 19:53:44Z oparviai $
|
// $Id: BPMDetect.h 150 2012-08-30 19:53:44Z oparviai $
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 20:53:01 +0200 (Thu, 08 Nov 2012) $
|
// Last changed : $Date: 2012-11-08 18:53:01 +0000 (Thu, 08 Nov 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
|
||||||
|
@ -220,7 +220,7 @@ uint FIFOSampleBuffer::receiveSamples(SAMPLETYPE *output, uint maxSamples)
|
||||||
|
|
||||||
num = (maxSamples > samplesInBuffer) ? samplesInBuffer : maxSamples;
|
num = (maxSamples > samplesInBuffer) ? samplesInBuffer : maxSamples;
|
||||||
|
|
||||||
memcpy(output, ptrBegin(), channels * sizeof(SAMPLETYPE) * num);
|
memcpy(output, ptrBegin(), channels * sizeof(SAMPLETYPE) * num);
|
||||||
return receiveSamples(num);
|
return receiveSamples(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 22:29:53 +0300 (Wed, 13 Jun 2012) $
|
// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSampleBuffer.h 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: FIFOSampleBuffer.h 143 2012-06-13 19:29:53Z oparviai $
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 22:29:53 +0300 (Wed, 13 Jun 2012) $
|
// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-09-02 21:56:11 +0300 (Fri, 02 Sep 2011) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIRFilter.cpp 131 2011-09-02 18:56:11Z oparviai $
|
// $Id: FIRFilter.cpp 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -167,6 +167,60 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
||||||
|
{
|
||||||
|
uint i, j, end, c;
|
||||||
|
LONG_SAMPLETYPE *sum=(LONG_SAMPLETYPE*)alloca(numChannels*sizeof(*sum));
|
||||||
|
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
// when using floating point samples, use a scaler instead of a divider
|
||||||
|
// because division is much slower operation than multiplying.
|
||||||
|
double dScaler = 1.0 / (double)resultDivider;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
assert(length != 0);
|
||||||
|
assert(src != NULL);
|
||||||
|
assert(dest != NULL);
|
||||||
|
assert(filterCoeffs != NULL);
|
||||||
|
|
||||||
|
end = numChannels * (numSamples - length);
|
||||||
|
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
sum[c] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < end; j += numChannels)
|
||||||
|
{
|
||||||
|
const SAMPLETYPE *ptr;
|
||||||
|
|
||||||
|
ptr = src + j;
|
||||||
|
|
||||||
|
for (i = 0; i < length; i ++)
|
||||||
|
{
|
||||||
|
SAMPLETYPE coef=filterCoeffs[i];
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
sum[c] += ptr[0] * coef;
|
||||||
|
ptr ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
sum[c] >>= resultDivFactor;
|
||||||
|
#else
|
||||||
|
sum[c] *= dScaler;
|
||||||
|
#endif // SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
|
*dest = (SAMPLETYPE)sum[c];
|
||||||
|
dest++;
|
||||||
|
sum[c] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return numSamples - length;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set filter coeffiecients and length.
|
// Set filter coeffiecients and length.
|
||||||
//
|
//
|
||||||
// Throws an exception if filter length isn't divisible by 8
|
// Throws an exception if filter length isn't divisible by 8
|
||||||
|
@ -201,16 +255,25 @@ uint FIRFilter::getLength() const
|
||||||
// smaller than the amount of input samples.
|
// smaller than the amount of input samples.
|
||||||
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
|
||||||
{
|
{
|
||||||
assert(numChannels == 1 || numChannels == 2);
|
|
||||||
|
|
||||||
assert(length > 0);
|
assert(length > 0);
|
||||||
assert(lengthDiv8 * 8 == length);
|
assert(lengthDiv8 * 8 == length);
|
||||||
|
|
||||||
if (numSamples < length) return 0;
|
if (numSamples < length) return 0;
|
||||||
if (numChannels == 2)
|
|
||||||
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (numChannels == 1)
|
||||||
|
{
|
||||||
|
return evaluateFilterMono(dest, src, numSamples);
|
||||||
|
}
|
||||||
|
else if (numChannels == 2)
|
||||||
{
|
{
|
||||||
return evaluateFilterStereo(dest, src, numSamples);
|
return evaluateFilterStereo(dest, src, numSamples);
|
||||||
} else {
|
}
|
||||||
return evaluateFilterMono(dest, src, numSamples);
|
else
|
||||||
|
#endif // USE_MULTICH_ALWAYS
|
||||||
|
{
|
||||||
|
assert(numChannels > 0);
|
||||||
|
return evaluateFilterMulti(dest, src, numSamples, numChannels);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-02-13 21:13:57 +0200 (Sun, 13 Feb 2011) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: FIRFilter.h 104 2011-02-13 19:13:57Z oparviai $
|
// $Id: FIRFilter.h 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -71,6 +71,7 @@ protected:
|
||||||
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) const;
|
uint numSamples) const;
|
||||||
|
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FIRFilter();
|
FIRFilter();
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 21:52:47 +0200 (Fri, 28 Dec 2012) $
|
// Last changed : $Date: 2012-12-28 19:52:47 +0000 (Fri, 28 Dec 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: PeakFinder.cpp 164 2012-12-28 19:52:47Z oparviai $
|
// $Id: PeakFinder.cpp 164 2012-12-28 19:52:47Z oparviai $
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-12-30 22:33:46 +0200 (Fri, 30 Dec 2011) $
|
// Last changed : $Date: 2011-12-30 20:33:46 +0000 (Fri, 30 Dec 2011) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: PeakFinder.h 132 2011-12-30 20:33:46Z oparviai $
|
// $Id: PeakFinder.h 132 2011-12-30 20:33:46Z oparviai $
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2011-09-02 21:56:11 +0300 (Fri, 02 Sep 2011) $
|
// Last changed : $Date: 2013-06-14 17:34:33 +0000 (Fri, 14 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: RateTransposer.cpp 131 2011-09-02 18:56:11Z oparviai $
|
// $Id: RateTransposer.cpp 172 2013-06-14 17:34:33Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -55,17 +55,17 @@ class RateTransposerInteger : public RateTransposer
|
||||||
protected:
|
protected:
|
||||||
int iSlopeCount;
|
int iSlopeCount;
|
||||||
int iRate;
|
int iRate;
|
||||||
SAMPLETYPE sPrevSampleL, sPrevSampleR;
|
SAMPLETYPE *sPrevSample;
|
||||||
|
|
||||||
virtual void resetRegisters();
|
virtual void resetRegisters();
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples);
|
||||||
public:
|
public:
|
||||||
RateTransposerInteger();
|
RateTransposerInteger();
|
||||||
virtual ~RateTransposerInteger();
|
virtual ~RateTransposerInteger();
|
||||||
|
@ -83,16 +83,17 @@ class RateTransposerFloat : public RateTransposer
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
float fSlopeCount;
|
float fSlopeCount;
|
||||||
SAMPLETYPE sPrevSampleL, sPrevSampleR;
|
SAMPLETYPE *sPrevSample;
|
||||||
|
|
||||||
virtual void resetRegisters();
|
virtual void resetRegisters();
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
|
virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RateTransposerFloat();
|
RateTransposerFloat();
|
||||||
|
@ -260,7 +261,7 @@ void RateTransposer::downsample(const SAMPLETYPE *src, uint nSamples)
|
||||||
count = pAAFilter->evaluate(tempBuffer.ptrEnd(sizeTemp),
|
count = pAAFilter->evaluate(tempBuffer.ptrEnd(sizeTemp),
|
||||||
storeBuffer.ptrBegin(), sizeTemp, (uint)numChannels);
|
storeBuffer.ptrBegin(), sizeTemp, (uint)numChannels);
|
||||||
|
|
||||||
if (count == 0) return;
|
if (count == 0) return;
|
||||||
|
|
||||||
// Remove the filtered samples from 'storeBuffer'
|
// Remove the filtered samples from 'storeBuffer'
|
||||||
storeBuffer.receiveSamples(count);
|
storeBuffer.receiveSamples(count);
|
||||||
|
@ -308,15 +309,22 @@ void RateTransposer::processSamples(const SAMPLETYPE *src, uint nSamples)
|
||||||
|
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
// Returns the number of samples returned in the "dest" buffer
|
// Returns the number of samples returned in the "dest" buffer
|
||||||
inline uint RateTransposer::transpose(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
inline int RateTransposer::transpose(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
{
|
{
|
||||||
if (numChannels == 2)
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (numChannels == 1)
|
||||||
|
{
|
||||||
|
return transposeMono(dest, src, nSamples);
|
||||||
|
}
|
||||||
|
else if (numChannels == 2)
|
||||||
{
|
{
|
||||||
return transposeStereo(dest, src, nSamples);
|
return transposeStereo(dest, src, nSamples);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // USE_MULTICH_ALWAYS
|
||||||
{
|
{
|
||||||
return transposeMono(dest, src, nSamples);
|
assert(numChannels > 0);
|
||||||
|
return transposeMulti(dest, src, nSamples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +335,7 @@ void RateTransposer::setChannels(int nChannels)
|
||||||
assert(nChannels > 0);
|
assert(nChannels > 0);
|
||||||
if (numChannels == nChannels) return;
|
if (numChannels == nChannels) return;
|
||||||
|
|
||||||
assert(nChannels == 1 || nChannels == 2);
|
// assert(nChannels == 1 || nChannels == 2);
|
||||||
numChannels = nChannels;
|
numChannels = nChannels;
|
||||||
|
|
||||||
storeBuffer.setChannels(numChannels);
|
storeBuffer.setChannels(numChannels);
|
||||||
|
@ -371,6 +379,7 @@ RateTransposerInteger::RateTransposerInteger() : RateTransposer()
|
||||||
{
|
{
|
||||||
// Notice: use local function calling syntax for sake of clarity,
|
// Notice: use local function calling syntax for sake of clarity,
|
||||||
// to indicate the fact that C++ constructor can't call virtual functions.
|
// to indicate the fact that C++ constructor can't call virtual functions.
|
||||||
|
sPrevSample=0;
|
||||||
RateTransposerInteger::resetRegisters();
|
RateTransposerInteger::resetRegisters();
|
||||||
RateTransposerInteger::setRate(1.0f);
|
RateTransposerInteger::setRate(1.0f);
|
||||||
}
|
}
|
||||||
|
@ -378,14 +387,16 @@ RateTransposerInteger::RateTransposerInteger() : RateTransposer()
|
||||||
|
|
||||||
RateTransposerInteger::~RateTransposerInteger()
|
RateTransposerInteger::~RateTransposerInteger()
|
||||||
{
|
{
|
||||||
|
if (sPrevSample) delete[] sPrevSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RateTransposerInteger::resetRegisters()
|
void RateTransposerInteger::resetRegisters()
|
||||||
{
|
{
|
||||||
iSlopeCount = 0;
|
iSlopeCount = 0;
|
||||||
sPrevSampleL =
|
delete[] sPrevSample;
|
||||||
sPrevSampleR = 0;
|
sPrevSample = new SAMPLETYPE[numChannels];
|
||||||
|
memset(sPrevSample, 0, numChannels * sizeof(SAMPLETYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -393,21 +404,21 @@ void RateTransposerInteger::resetRegisters()
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
int RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
{
|
{
|
||||||
unsigned int i, used;
|
int i, remain;
|
||||||
LONG_SAMPLETYPE temp, vol1;
|
LONG_SAMPLETYPE temp, vol1;
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
if (nSamples == 0) return 0; // no samples, no work
|
||||||
|
|
||||||
used = 0;
|
remain = nSamples - 1;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Process the last sample saved from the previous call first...
|
// Process the last sample saved from the previous call first...
|
||||||
while (iSlopeCount <= SCALE)
|
while (iSlopeCount <= SCALE)
|
||||||
{
|
{
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
||||||
temp = vol1 * sPrevSampleL + iSlopeCount * src[0];
|
temp = vol1 * sPrevSample[0] + iSlopeCount * src[0];
|
||||||
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
i++;
|
i++;
|
||||||
iSlopeCount += iRate;
|
iSlopeCount += iRate;
|
||||||
|
@ -420,11 +431,12 @@ uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *sr
|
||||||
while (iSlopeCount > SCALE)
|
while (iSlopeCount > SCALE)
|
||||||
{
|
{
|
||||||
iSlopeCount -= SCALE;
|
iSlopeCount -= SCALE;
|
||||||
used ++;
|
src ++;
|
||||||
if (used >= nSamples - 1) goto end;
|
remain --;
|
||||||
|
if (remain == 0) goto end;
|
||||||
}
|
}
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
||||||
temp = src[used] * vol1 + iSlopeCount * src[used + 1];
|
temp = src[0] * vol1 + iSlopeCount * src[1];
|
||||||
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -432,7 +444,7 @@ uint RateTransposerInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *sr
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
// Store the last sample for the next round
|
// Store the last sample for the next round
|
||||||
sPrevSampleL = src[nSamples - 1];
|
sPrevSample[0] = src[0];
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -441,23 +453,23 @@ end:
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
// 'Stereo' version of the routine. Returns the number of samples returned in
|
// 'Stereo' version of the routine. Returns the number of samples returned in
|
||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
int RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
{
|
{
|
||||||
unsigned int srcPos, i, used;
|
int i, remain;
|
||||||
LONG_SAMPLETYPE temp, vol1;
|
LONG_SAMPLETYPE temp, vol1;
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
if (nSamples == 0) return 0; // no samples, no work
|
||||||
|
|
||||||
used = 0;
|
remain = nSamples - 1;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Process the last sample saved from the sPrevSampleLious call first...
|
// Process the last sample saved from the sPrevSampleLious call first...
|
||||||
while (iSlopeCount <= SCALE)
|
while (iSlopeCount <= SCALE)
|
||||||
{
|
{
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
||||||
temp = vol1 * sPrevSampleL + iSlopeCount * src[0];
|
temp = vol1 * sPrevSample[0] + iSlopeCount * src[0];
|
||||||
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
temp = vol1 * sPrevSampleR + iSlopeCount * src[1];
|
temp = vol1 * sPrevSample[1] + iSlopeCount * src[1];
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
||||||
i++;
|
i++;
|
||||||
iSlopeCount += iRate;
|
iSlopeCount += iRate;
|
||||||
|
@ -470,14 +482,14 @@ uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *
|
||||||
while (iSlopeCount > SCALE)
|
while (iSlopeCount > SCALE)
|
||||||
{
|
{
|
||||||
iSlopeCount -= SCALE;
|
iSlopeCount -= SCALE;
|
||||||
used ++;
|
remain --;
|
||||||
if (used >= nSamples - 1) goto end;
|
src += 2;
|
||||||
|
if (remain == 0) goto end;
|
||||||
}
|
}
|
||||||
srcPos = 2 * used;
|
|
||||||
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
vol1 = (LONG_SAMPLETYPE)(SCALE - iSlopeCount);
|
||||||
temp = src[srcPos] * vol1 + iSlopeCount * src[srcPos + 2];
|
temp = src[0] * vol1 + iSlopeCount * src[2];
|
||||||
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
dest[2 * i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
temp = src[srcPos + 1] * vol1 + iSlopeCount * src[srcPos + 3];
|
temp = src[1] * vol1 + iSlopeCount * src[3];
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
dest[2 * i + 1] = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
@ -485,13 +497,68 @@ uint RateTransposerInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
// Store the last sample for the next round
|
// Store the last sample for the next round
|
||||||
sPrevSampleL = src[2 * nSamples - 2];
|
sPrevSample[0] = src[0];
|
||||||
sPrevSampleR = src[2 * nSamples - 1];
|
sPrevSample[1] = src[1];
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int RateTransposerInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
|
{
|
||||||
|
int i, remaining;
|
||||||
|
LONG_SAMPLETYPE temp, vol1;
|
||||||
|
|
||||||
|
if (nSamples == 0) return 0; // no samples, no work
|
||||||
|
|
||||||
|
remaining = nSamples - 1;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
// Process the last sample saved from the sPrevSampleLious call first...
|
||||||
|
while (iSlopeCount <= SCALE)
|
||||||
|
{
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
vol1 = (SCALE - iSlopeCount);
|
||||||
|
temp = vol1 * sPrevSample[c] + iSlopeCount * src[c];
|
||||||
|
*dest = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
dest ++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iSlopeCount += iRate;
|
||||||
|
}
|
||||||
|
// now always (iSlopeCount > SCALE)
|
||||||
|
iSlopeCount -= SCALE;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
while (iSlopeCount > SCALE)
|
||||||
|
{
|
||||||
|
iSlopeCount -= SCALE;
|
||||||
|
src += numChannels;
|
||||||
|
remaining --;
|
||||||
|
if (remaining == 0) goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
vol1 = (SCALE - iSlopeCount);
|
||||||
|
temp = src[c] * vol1 + iSlopeCount * src[c + numChannels];
|
||||||
|
*dest = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
dest++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
iSlopeCount += iRate;
|
||||||
|
}
|
||||||
|
end:
|
||||||
|
// Store the last sample for the next round
|
||||||
|
memcpy(sPrevSample, src, numChannels * sizeof(SAMPLETYPE));
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
|
||||||
// iRate, larger faster iRates.
|
// iRate, larger faster iRates.
|
||||||
void RateTransposerInteger::setRate(float newRate)
|
void RateTransposerInteger::setRate(float newRate)
|
||||||
|
@ -512,6 +579,7 @@ RateTransposerFloat::RateTransposerFloat() : RateTransposer()
|
||||||
{
|
{
|
||||||
// Notice: use local function calling syntax for sake of clarity,
|
// Notice: use local function calling syntax for sake of clarity,
|
||||||
// to indicate the fact that C++ constructor can't call virtual functions.
|
// to indicate the fact that C++ constructor can't call virtual functions.
|
||||||
|
sPrevSample = NULL;
|
||||||
RateTransposerFloat::resetRegisters();
|
RateTransposerFloat::resetRegisters();
|
||||||
RateTransposerFloat::setRate(1.0f);
|
RateTransposerFloat::setRate(1.0f);
|
||||||
}
|
}
|
||||||
|
@ -519,14 +587,16 @@ RateTransposerFloat::RateTransposerFloat() : RateTransposer()
|
||||||
|
|
||||||
RateTransposerFloat::~RateTransposerFloat()
|
RateTransposerFloat::~RateTransposerFloat()
|
||||||
{
|
{
|
||||||
|
delete[] sPrevSample;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RateTransposerFloat::resetRegisters()
|
void RateTransposerFloat::resetRegisters()
|
||||||
{
|
{
|
||||||
fSlopeCount = 0;
|
fSlopeCount = 0;
|
||||||
sPrevSampleL =
|
delete[] sPrevSample;
|
||||||
sPrevSampleR = 0;
|
sPrevSample = new SAMPLETYPE[numChannels];
|
||||||
|
memset(sPrevSample, 0, numChannels * sizeof(SAMPLETYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -534,17 +604,17 @@ void RateTransposerFloat::resetRegisters()
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
uint RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
int RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
{
|
{
|
||||||
unsigned int i, used;
|
int i, remain;
|
||||||
|
|
||||||
used = 0;
|
remain = 0;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Process the last sample saved from the previous call first...
|
// Process the last sample saved from the previous call first...
|
||||||
while (fSlopeCount <= 1.0f)
|
while (fSlopeCount <= 1.0f)
|
||||||
{
|
{
|
||||||
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleL + fSlopeCount * src[0]);
|
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSample[0] + fSlopeCount * src[0]);
|
||||||
i++;
|
i++;
|
||||||
fSlopeCount += fRate;
|
fSlopeCount += fRate;
|
||||||
}
|
}
|
||||||
|
@ -557,17 +627,18 @@ uint RateTransposerFloat::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src,
|
||||||
while (fSlopeCount > 1.0f)
|
while (fSlopeCount > 1.0f)
|
||||||
{
|
{
|
||||||
fSlopeCount -= 1.0f;
|
fSlopeCount -= 1.0f;
|
||||||
used ++;
|
src ++;
|
||||||
if (used >= nSamples - 1) goto end;
|
remain --;
|
||||||
|
if (remain == 0) goto end;
|
||||||
}
|
}
|
||||||
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[used] + fSlopeCount * src[used + 1]);
|
dest[i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[0] + fSlopeCount * src[1]);
|
||||||
i++;
|
i++;
|
||||||
fSlopeCount += fRate;
|
fSlopeCount += fRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
// Store the last sample for the next round
|
// Store the last sample for the next round
|
||||||
sPrevSampleL = src[nSamples - 1];
|
sPrevSample[0] = src[0];
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -576,20 +647,20 @@ end:
|
||||||
// Transposes the sample rate of the given samples using linear interpolation.
|
// Transposes the sample rate of the given samples using linear interpolation.
|
||||||
// 'Mono' version of the routine. Returns the number of samples returned in
|
// 'Mono' version of the routine. Returns the number of samples returned in
|
||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
int RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
{
|
{
|
||||||
unsigned int srcPos, i, used;
|
int i, remain;
|
||||||
|
|
||||||
if (nSamples == 0) return 0; // no samples, no work
|
if (nSamples == 0) return 0; // no samples, no work
|
||||||
|
|
||||||
used = 0;
|
remain = nSamples - 1;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// Process the last sample saved from the sPrevSampleLious call first...
|
// Process the last sample saved from the sPrevSampleLious call first...
|
||||||
while (fSlopeCount <= 1.0f)
|
while (fSlopeCount <= 1.0f)
|
||||||
{
|
{
|
||||||
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleL + fSlopeCount * src[0]);
|
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSample[0] + fSlopeCount * src[0]);
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSampleR + fSlopeCount * src[1]);
|
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSample[1] + fSlopeCount * src[1]);
|
||||||
i++;
|
i++;
|
||||||
fSlopeCount += fRate;
|
fSlopeCount += fRate;
|
||||||
}
|
}
|
||||||
|
@ -603,15 +674,15 @@ uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *sr
|
||||||
while (fSlopeCount > 1.0f)
|
while (fSlopeCount > 1.0f)
|
||||||
{
|
{
|
||||||
fSlopeCount -= 1.0f;
|
fSlopeCount -= 1.0f;
|
||||||
used ++;
|
remain --;
|
||||||
if (used >= nSamples - 1) goto end;
|
src += 2;
|
||||||
|
if (remain == 0) goto end;
|
||||||
}
|
}
|
||||||
srcPos = 2 * used;
|
|
||||||
|
|
||||||
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[srcPos]
|
dest[2 * i] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[0]
|
||||||
+ fSlopeCount * src[srcPos + 2]);
|
+ fSlopeCount * src[2]);
|
||||||
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[srcPos + 1]
|
dest[2 * i + 1] = (SAMPLETYPE)((1.0f - fSlopeCount) * src[1]
|
||||||
+ fSlopeCount * src[srcPos + 3]);
|
+ fSlopeCount * src[3]);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
fSlopeCount += fRate;
|
fSlopeCount += fRate;
|
||||||
|
@ -619,8 +690,59 @@ uint RateTransposerFloat::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *sr
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
// Store the last sample for the next round
|
// Store the last sample for the next round
|
||||||
sPrevSampleL = src[2 * nSamples - 2];
|
sPrevSample[0] = src[0];
|
||||||
sPrevSampleR = src[2 * nSamples - 1];
|
sPrevSample[1] = src[1];
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int RateTransposerFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples)
|
||||||
|
{
|
||||||
|
int i, remaining;
|
||||||
|
|
||||||
|
if (nSamples == 0) return 0; // no samples, no work
|
||||||
|
|
||||||
|
remaining = nSamples - 1;
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
// Process the last sample saved from the sPrevSampleLious call first...
|
||||||
|
while (fSlopeCount <= 1.0f)
|
||||||
|
{
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
*dest = (SAMPLETYPE)((1.0f - fSlopeCount) * sPrevSample[c] + fSlopeCount * src[c]);
|
||||||
|
dest ++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
fSlopeCount += fRate;
|
||||||
|
}
|
||||||
|
// now always (iSlopeCount > 1.0f)
|
||||||
|
fSlopeCount -= 1.0f;
|
||||||
|
|
||||||
|
while (remaining > 0)
|
||||||
|
{
|
||||||
|
while (fSlopeCount > 1.0f)
|
||||||
|
{
|
||||||
|
fSlopeCount -= 1.0f;
|
||||||
|
src += numChannels;
|
||||||
|
remaining --;
|
||||||
|
if (remaining == 0) goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < numChannels; c ++)
|
||||||
|
{
|
||||||
|
*dest = (SAMPLETYPE)((1.0f - fSlopeCount) * src[c]
|
||||||
|
+ fSlopeCount * src[c + numChannels]);
|
||||||
|
dest++;
|
||||||
|
}
|
||||||
|
|
||||||
|
i++;
|
||||||
|
fSlopeCount += fRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
// Store the last sample for the next round
|
||||||
|
memcpy(sPrevSample, src, numChannels * sizeof(SAMPLETYPE));
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2009-02-21 18:00:14 +0200 (Sat, 21 Feb 2009) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: RateTransposer.h 63 2009-02-21 16:00:14Z oparviai $
|
// $Id: RateTransposer.h 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -85,13 +85,14 @@ protected:
|
||||||
|
|
||||||
virtual void resetRegisters() = 0;
|
virtual void resetRegisters() = 0;
|
||||||
|
|
||||||
virtual uint transposeStereo(SAMPLETYPE *dest,
|
virtual int transposeStereo(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) = 0;
|
uint numSamples) = 0;
|
||||||
virtual uint transposeMono(SAMPLETYPE *dest,
|
virtual int transposeMono(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples) = 0;
|
uint numSamples) = 0;
|
||||||
inline uint transpose(SAMPLETYPE *dest,
|
virtual int transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint nSamples) = 0;
|
||||||
|
inline int transpose(SAMPLETYPE *dest,
|
||||||
const SAMPLETYPE *src,
|
const SAMPLETYPE *src,
|
||||||
uint numSamples);
|
uint numSamples);
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 16:53:56 +0200 (Fri, 28 Dec 2012) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 3 $
|
// File revision : $Revision: 3 $
|
||||||
//
|
//
|
||||||
// $Id: STTypes.h 162 2012-12-28 14:53:56Z oparviai $
|
// $Id: STTypes.h 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -57,16 +57,14 @@ typedef unsigned long ulong;
|
||||||
#if (defined(__GNUC__) && !defined(ANDROID))
|
#if (defined(__GNUC__) && !defined(ANDROID))
|
||||||
// In GCC, include soundtouch_config.h made by config scritps.
|
// In GCC, include soundtouch_config.h made by config scritps.
|
||||||
// Skip this in Android compilation that uses GCC but without configure scripts.
|
// Skip this in Android compilation that uses GCC but without configure scripts.
|
||||||
//#include "soundtouch_config.h"
|
#include "soundtouch_config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WINDEF_
|
#ifndef _WINDEF_
|
||||||
// if these aren't defined already by Windows headers, define now
|
// if these aren't defined already by Windows headers, define now
|
||||||
#if defined(__APPLE__)
|
|
||||||
typedef signed char BOOL;
|
|
||||||
#else
|
|
||||||
typedef int BOOL;
|
typedef int BOOL;
|
||||||
#endif
|
|
||||||
#define FALSE 0
|
#define FALSE 0
|
||||||
#define TRUE 1
|
#define TRUE 1
|
||||||
|
|
||||||
|
@ -77,10 +75,17 @@ namespace soundtouch
|
||||||
{
|
{
|
||||||
/// Activate these undef's to overrule the possible sampletype
|
/// Activate these undef's to overrule the possible sampletype
|
||||||
/// setting inherited from some other header file:
|
/// setting inherited from some other header file:
|
||||||
#undef SOUNDTOUCH_INTEGER_SAMPLES
|
//#undef SOUNDTOUCH_INTEGER_SAMPLES
|
||||||
#undef SOUNDTOUCH_FLOAT_SAMPLES
|
//#undef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
|
||||||
#if (defined(ANDROID) && defined(__SOFTFP__))
|
/// If following flag is defined, always uses multichannel processing
|
||||||
|
/// routines also for mono and stero sound. This is for routine testing
|
||||||
|
/// purposes; output should be same with either routines, yet disabling
|
||||||
|
/// the dedicated mono/stereo processing routines will result in slower
|
||||||
|
/// runtime performance so recommendation is to keep this off.
|
||||||
|
// #define USE_MULTICH_ALWAYS
|
||||||
|
|
||||||
|
#if (defined(__SOFTFP__))
|
||||||
// For Android compilation: Force use of Integer samples in case that
|
// For Android compilation: Force use of Integer samples in case that
|
||||||
// compilation uses soft-floating point emulation - soft-fp is way too slow
|
// compilation uses soft-floating point emulation - soft-fp is way too slow
|
||||||
#undef SOUNDTOUCH_FLOAT_SAMPLES
|
#undef SOUNDTOUCH_FLOAT_SAMPLES
|
||||||
|
@ -149,9 +154,7 @@ namespace soundtouch
|
||||||
|
|
||||||
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
|
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
|
||||||
// Allow MMX optimizations
|
// Allow MMX optimizations
|
||||||
#ifndef _M_X64
|
|
||||||
#define SOUNDTOUCH_ALLOW_MMX 1
|
#define SOUNDTOUCH_ALLOW_MMX 1
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
@ -171,7 +174,7 @@ namespace soundtouch
|
||||||
};
|
};
|
||||||
|
|
||||||
// define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
|
// define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
|
||||||
#define ST_NO_EXCEPTION_HANDLING 1
|
// #define ST_NO_EXCEPTION_HANDLING 1
|
||||||
#ifdef ST_NO_EXCEPTION_HANDLING
|
#ifdef ST_NO_EXCEPTION_HANDLING
|
||||||
// Exceptions disabled. Throw asserts instead if enabled.
|
// Exceptions disabled. Throw asserts instead if enabled.
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-06-13 22:29:53 +0300 (Wed, 13 Jun 2012) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: SoundTouch.cpp 143 2012-06-13 19:29:53Z oparviai $
|
// $Id: SoundTouch.cpp 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -143,10 +143,11 @@ uint SoundTouch::getVersionId()
|
||||||
// Sets the number of channels, 1 = mono, 2 = stereo
|
// Sets the number of channels, 1 = mono, 2 = stereo
|
||||||
void SoundTouch::setChannels(uint numChannels)
|
void SoundTouch::setChannels(uint numChannels)
|
||||||
{
|
{
|
||||||
if (numChannels != 1 && numChannels != 2)
|
/*if (numChannels != 1 && numChannels != 2)
|
||||||
{
|
{
|
||||||
ST_THROW_RT_ERROR("Illegal number of channels");
|
//ST_THROW_RT_ERROR("Illegal number of channels");
|
||||||
}
|
return;
|
||||||
|
}*/
|
||||||
channels = numChannels;
|
channels = numChannels;
|
||||||
pRateTransposer->setChannels((int)numChannels);
|
pRateTransposer->setChannels((int)numChannels);
|
||||||
pTDStretch->setChannels((int)numChannels);
|
pTDStretch->setChannels((int)numChannels);
|
||||||
|
@ -347,7 +348,7 @@ void SoundTouch::flush()
|
||||||
int i;
|
int i;
|
||||||
int nUnprocessed;
|
int nUnprocessed;
|
||||||
int nOut;
|
int nOut;
|
||||||
SAMPLETYPE buff[64*2]; // note: allocate 2*64 to cater 64 sample frames of stereo sound
|
SAMPLETYPE *buff=(SAMPLETYPE*)alloca(64*channels*sizeof(SAMPLETYPE));
|
||||||
|
|
||||||
// check how many samples still await processing, and scale
|
// check how many samples still await processing, and scale
|
||||||
// that by tempo & rate to get expected output sample count
|
// that by tempo & rate to get expected output sample count
|
||||||
|
|
|
@ -41,10 +41,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-12-28 21:32:59 +0200 (Fri, 28 Dec 2012) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: SoundTouch.h 163 2012-12-28 19:32:59Z oparviai $
|
// $Id: SoundTouch.h 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -79,10 +79,10 @@ namespace soundtouch
|
||||||
{
|
{
|
||||||
|
|
||||||
/// Soundtouch library version string
|
/// Soundtouch library version string
|
||||||
#define SOUNDTOUCH_VERSION "1.7.1"
|
#define SOUNDTOUCH_VERSION "1.7.2 (dev)"
|
||||||
|
|
||||||
/// SoundTouch library version id
|
/// SoundTouch library version id
|
||||||
#define SOUNDTOUCH_VERSION_ID (10701)
|
#define SOUNDTOUCH_VERSION_ID (10702)
|
||||||
|
|
||||||
//
|
//
|
||||||
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
|
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 20:53:01 +0200 (Thu, 08 Nov 2012) $
|
// Last changed : $Date: 2013-06-14 17:34:33 +0000 (Fri, 14 Jun 2013) $
|
||||||
// File revision : $Revision: 1.12 $
|
// File revision : $Revision: 1.12 $
|
||||||
//
|
//
|
||||||
// $Id: TDStretch.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: TDStretch.cpp 172 2013-06-14 17:34:33Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -51,8 +51,6 @@
|
||||||
#include "cpu_detect.h"
|
#include "cpu_detect.h"
|
||||||
#include "TDStretch.h"
|
#include "TDStretch.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
using namespace soundtouch;
|
using namespace soundtouch;
|
||||||
|
|
||||||
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
#define max(x, y) (((x) > (y)) ? (x) : (y))
|
||||||
|
@ -159,7 +157,6 @@ void TDStretch::setParameters(int aSampleRate, int aSequenceMS,
|
||||||
|
|
||||||
// set tempo to recalculate 'sampleReq'
|
// set tempo to recalculate 'sampleReq'
|
||||||
setTempo(tempo);
|
setTempo(tempo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +209,7 @@ void TDStretch::overlapMono(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput) const
|
||||||
|
|
||||||
void TDStretch::clearMidBuffer()
|
void TDStretch::clearMidBuffer()
|
||||||
{
|
{
|
||||||
memset(pMidBuffer, 0, 2 * sizeof(SAMPLETYPE) * overlapLength);
|
memset(pMidBuffer, 0, channels * sizeof(SAMPLETYPE) * overlapLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -265,13 +262,22 @@ int TDStretch::seekBestOverlapPosition(const SAMPLETYPE *refPos)
|
||||||
// of 'ovlPos'.
|
// of 'ovlPos'.
|
||||||
inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, uint ovlPos) const
|
inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, uint ovlPos) const
|
||||||
{
|
{
|
||||||
if (channels == 2)
|
#ifndef USE_MULTICH_ALWAYS
|
||||||
|
if (channels == 1)
|
||||||
|
{
|
||||||
|
// mono sound.
|
||||||
|
overlapMono(pOutput, pInput + ovlPos);
|
||||||
|
}
|
||||||
|
else if (channels == 2)
|
||||||
{
|
{
|
||||||
// stereo sound
|
// stereo sound
|
||||||
overlapStereo(pOutput, pInput + 2 * ovlPos);
|
overlapStereo(pOutput, pInput + 2 * ovlPos);
|
||||||
} else {
|
}
|
||||||
// mono sound.
|
else
|
||||||
overlapMono(pOutput, pInput + ovlPos);
|
#endif // USE_MULTICH_ALWAYS
|
||||||
|
{
|
||||||
|
assert(channels > 0);
|
||||||
|
overlapMulti(pOutput, pInput + channels * ovlPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -458,11 +464,15 @@ void TDStretch::setChannels(int numChannels)
|
||||||
{
|
{
|
||||||
assert(numChannels > 0);
|
assert(numChannels > 0);
|
||||||
if (channels == numChannels) return;
|
if (channels == numChannels) return;
|
||||||
assert(numChannels == 1 || numChannels == 2);
|
// assert(numChannels == 1 || numChannels == 2);
|
||||||
|
|
||||||
channels = numChannels;
|
channels = numChannels;
|
||||||
inputBuffer.setChannels(channels);
|
inputBuffer.setChannels(channels);
|
||||||
outputBuffer.setChannels(channels);
|
outputBuffer.setChannels(channels);
|
||||||
|
|
||||||
|
// re-init overlap/buffer
|
||||||
|
overlapLength=0;
|
||||||
|
setParameters(sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -498,7 +508,6 @@ void TDStretch::processNominalTempo()
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
// Processes as many processing frames of the samples 'inputBuffer', store
|
// Processes as many processing frames of the samples 'inputBuffer', store
|
||||||
// the result into 'outputBuffer'
|
// the result into 'outputBuffer'
|
||||||
|
@ -588,7 +597,7 @@ void TDStretch::acceptNewOverlapLength(int newOverlapLength)
|
||||||
{
|
{
|
||||||
delete[] pMidBufferUnaligned;
|
delete[] pMidBufferUnaligned;
|
||||||
|
|
||||||
pMidBufferUnaligned = new SAMPLETYPE[overlapLength * 2 + 16 / sizeof(SAMPLETYPE)];
|
pMidBufferUnaligned = new SAMPLETYPE[overlapLength * channels + 16 / sizeof(SAMPLETYPE)];
|
||||||
// ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
|
// ensure that 'pMidBuffer' is aligned to 16 byte boundary for efficiency
|
||||||
pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);
|
pMidBuffer = (SAMPLETYPE *)SOUNDTOUCH_ALIGN_POINTER_16(pMidBufferUnaligned);
|
||||||
|
|
||||||
|
@ -666,6 +675,27 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Overlaps samples in 'midBuffer' with the samples in 'input'. The 'Multi'
|
||||||
|
// version of the routine.
|
||||||
|
void TDStretch::overlapMulti(SAMPLETYPE *poutput, const SAMPLETYPE *input) const
|
||||||
|
{
|
||||||
|
SAMPLETYPE m1=(SAMPLETYPE)0;
|
||||||
|
SAMPLETYPE m2;
|
||||||
|
int i=0;
|
||||||
|
|
||||||
|
for (m2 = (SAMPLETYPE)overlapLength; m2; m2 --)
|
||||||
|
{
|
||||||
|
for (int c = 0; c < channels; c ++)
|
||||||
|
{
|
||||||
|
poutput[i] = (input[i] * m1 + pMidBuffer[i] * m2) / overlapLength;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
m1++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Calculates the x having the closest 2^x value for the given value
|
// Calculates the x having the closest 2^x value for the given value
|
||||||
static int _getClosest2Power(double value)
|
static int _getClosest2Power(double value)
|
||||||
{
|
{
|
||||||
|
@ -760,6 +790,34 @@ void TDStretch::overlapStereo(float *pOutput, const float *pInput) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Overlaps samples in 'midBuffer' with the samples in 'input'.
|
||||||
|
void TDStretch::overlapMulti(float *pOutput, const float *pInput) const
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float fScale;
|
||||||
|
float f1;
|
||||||
|
float f2;
|
||||||
|
|
||||||
|
fScale = 1.0f / (float)overlapLength;
|
||||||
|
|
||||||
|
f1 = 0;
|
||||||
|
f2 = 1.0f;
|
||||||
|
|
||||||
|
i=0;
|
||||||
|
for (int i2 = 0; i2 < overlapLength; i2 ++)
|
||||||
|
{
|
||||||
|
// note: Could optimize this slightly by taking into account that always channels > 2
|
||||||
|
for (int c = 0; c < channels; c ++)
|
||||||
|
{
|
||||||
|
pOutput[i] = pInput[i] * f1 + pMidBuffer[i] * f2;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
f1 += fScale;
|
||||||
|
f2 -= fScale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Calculates overlapInMsec period length in samples.
|
/// Calculates overlapInMsec period length in samples.
|
||||||
void TDStretch::calculateOverlapLength(int overlapInMsec)
|
void TDStretch::calculateOverlapLength(int overlapInMsec)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-04-01 22:49:30 +0300 (Sun, 01 Apr 2012) $
|
// Last changed : $Date: 2013-06-12 15:24:44 +0000 (Wed, 12 Jun 2013) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: TDStretch.h 137 2012-04-01 19:49:30Z oparviai $
|
// $Id: TDStretch.h 171 2013-06-12 15:24:44Z oparviai $
|
||||||
//
|
//
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -147,6 +147,7 @@ protected:
|
||||||
|
|
||||||
virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
|
virtual void overlapMulti(SAMPLETYPE *output, const SAMPLETYPE *input) const;
|
||||||
|
|
||||||
void clearMidBuffer();
|
void clearMidBuffer();
|
||||||
void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
|
void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2008-02-10 18:26:55 +0200 (Sun, 10 Feb 2008) $
|
// Last changed : $Date: 2008-02-10 16:26:55 +0000 (Sun, 10 Feb 2008) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
|
// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 20:44:37 +0200 (Thu, 08 Nov 2012) $
|
// Last changed : $Date: 2012-11-08 18:44:37 +0000 (Thu, 08 Nov 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: cpu_detect_x86.cpp 159 2012-11-08 18:44:37Z oparviai $
|
// $Id: cpu_detect_x86.cpp 159 2012-11-08 18:44:37Z oparviai $
|
||||||
|
@ -50,11 +50,11 @@
|
||||||
#elif defined(_M_IX86)
|
#elif defined(_M_IX86)
|
||||||
// windows non-gcc
|
// windows non-gcc
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
#define bit_MMX (1 << 23)
|
||||||
|
#define bit_SSE (1 << 25)
|
||||||
|
#define bit_SSE2 (1 << 26)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define bit_MMX (1 << 23)
|
|
||||||
#define bit_SSE (1 << 25)
|
|
||||||
#define bit_SSE2 (1 << 26)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 20:53:01 +0200 (Thu, 08 Nov 2012) $
|
// Last changed : $Date: 2012-11-08 18:53:01 +0000 (Thu, 08 Nov 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: mmx_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: mmx_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// Last changed : $Date: 2012-11-08 20:53:01 +0200 (Thu, 08 Nov 2012) $
|
// Last changed : $Date: 2012-11-08 18:53:01 +0000 (Thu, 08 Nov 2012) $
|
||||||
// File revision : $Revision: 4 $
|
// File revision : $Revision: 4 $
|
||||||
//
|
//
|
||||||
// $Id: sse_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
// $Id: sse_optimized.cpp 160 2012-11-08 18:53:01Z oparviai $
|
||||||
|
|
Loading…
Reference in New Issue