Skip to content

Commit

Permalink
Merge pull request #3406 from skidau/soundtouch-192
Browse files Browse the repository at this point in the history
Updated SoundTouch library to 1.9.2
  • Loading branch information
skidau committed Dec 28, 2015
2 parents fc86a9e + cfa925f commit fb55544
Show file tree
Hide file tree
Showing 27 changed files with 484 additions and 273 deletions.
2 changes: 1 addition & 1 deletion Externals/soundtouch/AAFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2014-01-06 08:40:22 +1100 (Mon, 06 Jan 2014) $
// Last changed : $Date: 2014-01-05 23:40:22 +0200 (Sun, 05 Jan 2014) $
// File revision : $Revision: 4 $
//
// $Id: AAFilter.cpp 177 2014-01-05 21:40:22Z oparviai $
Expand Down
2 changes: 1 addition & 1 deletion Externals/soundtouch/AAFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2014-01-08 06:41:23 +1100 (Wed, 08 Jan 2014) $
// Last changed : $Date: 2014-01-07 21:41:23 +0200 (Tue, 07 Jan 2014) $
// File revision : $Revision: 4 $
//
// $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $
Expand Down
5 changes: 3 additions & 2 deletions Externals/soundtouch/BPMDetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2012-08-31 05:45:25 +1000 (Fri, 31 Aug 2012) $
// Last changed : $Date: 2015-02-21 23:24:29 +0200 (Sat, 21 Feb 2015) $
// File revision : $Revision: 4 $
//
// $Id: BPMDetect.cpp 149 2012-08-30 19:45:25Z oparviai $
// $Id: BPMDetect.cpp 202 2015-02-21 21:24:29Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -226,6 +226,7 @@ void BPMDetect::updateXCorr(int process_samples)
assert(buffer->numSamples() >= (uint)(process_samples + windowLen));

pBuffer = buffer->ptrBegin();
#pragma omp parallel for
for (offs = windowStart; offs < windowLen; offs ++)
{
LONG_SAMPLETYPE sum;
Expand Down
2 changes: 1 addition & 1 deletion Externals/soundtouch/BPMDetect.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2012-08-30 19:53:44 +0000 (Thu, 30 Aug 2012) $
// Last changed : $Date: 2012-08-30 22:53:44 +0300 (Thu, 30 Aug 2012) $
// File revision : $Revision: 4 $
//
// $Id: BPMDetect.h 150 2012-08-30 19:53:44Z oparviai $
Expand Down
6 changes: 1 addition & 5 deletions Externals/soundtouch/FIFOSampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2012-11-09 05:53:01 +1100 (Fri, 09 Nov 2012) $
// Last changed : $Date: 2012-11-08 20:53:01 +0200 (Thu, 08 Nov 2012) $
// File revision : $Revision: 4 $
//
// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
Expand Down Expand Up @@ -86,10 +86,6 @@ void FIFOSampleBuffer::setChannels(int numChannels)
samplesInBuffer = usedBytes / channels;
}

int FIFOSampleBuffer::getChannels()
{
return channels;
}

// if output location pointer 'bufferPos' isn't zero, 'rewinds' the buffer and
// zeroes this pointer by copying samples from the 'bufferPos' pointer
Expand Down
11 changes: 8 additions & 3 deletions Externals/soundtouch/FIFOSampleBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
// Last changed : $Date: 2014-01-05 23:40:22 +0200 (Sun, 05 Jan 2014) $
// File revision : $Revision: 4 $
//
// $Id: FIFOSampleBuffer.h 143 2012-06-13 19:29:53Z oparviai $
// $Id: FIFOSampleBuffer.h 177 2014-01-05 21:40:22Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -161,7 +161,12 @@ class FIFOSampleBuffer : public FIFOSamplePipe

/// Sets number of channels, 1 = mono, 2 = stereo.
void setChannels(int numChannels);
int getChannels();

/// Get number of channels
int getChannels()
{
return channels;
}

/// Returns nonzero if there aren't any samples available for outputting.
virtual int isEmpty() const;
Expand Down
2 changes: 1 addition & 1 deletion Externals/soundtouch/FIFOSamplePipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
// Last changed : $Date: 2012-06-13 22:29:53 +0300 (Wed, 13 Jun 2012) $
// File revision : $Revision: 4 $
//
// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
Expand Down
60 changes: 33 additions & 27 deletions Externals/soundtouch/FIRFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2013-06-13 01:24:44 +1000 (Thu, 13 Jun 2013) $
// Last changed : $Date: 2015-02-21 23:24:29 +0200 (Sat, 21 Feb 2015) $
// File revision : $Revision: 4 $
//
// $Id: FIRFilter.cpp 171 2013-06-12 15:24:44Z oparviai $
// $Id: FIRFilter.cpp 202 2015-02-21 21:24:29Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -72,8 +72,7 @@ FIRFilter::~FIRFilter()
// Usual C-version of the filter routine for stereo sound
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
{
uint i, j, end;
LONG_SAMPLETYPE suml, sumr;
int j, end;
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// when using floating point samples, use a scaler instead of a divider
// because division is much slower operation than multiplying.
Expand All @@ -87,9 +86,12 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui

end = 2 * (numSamples - length);

#pragma omp parallel for
for (j = 0; j < end; j += 2)
{
const SAMPLETYPE *ptr;
LONG_SAMPLETYPE suml, sumr;
uint i;

suml = sumr = 0;
ptr = src + j;
Expand Down Expand Up @@ -130,28 +132,31 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
// Usual C-version of the filter routine for mono sound
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
{
uint i, j, end;
LONG_SAMPLETYPE sum;
int j, end;
#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);

end = numSamples - length;
#pragma omp parallel for
for (j = 0; j < end; j ++)
{
const SAMPLETYPE *pSrc = src + j;
LONG_SAMPLETYPE sum;
uint i;

sum = 0;
for (i = 0; i < length; i += 4)
{
// loop is unrolled by factor of 4 here for efficiency
sum += src[i + 0] * filterCoeffs[i + 0] +
src[i + 1] * filterCoeffs[i + 1] +
src[i + 2] * filterCoeffs[i + 2] +
src[i + 3] * filterCoeffs[i + 3];
sum += pSrc[i + 0] * filterCoeffs[i + 0] +
pSrc[i + 1] * filterCoeffs[i + 1] +
pSrc[i + 2] * filterCoeffs[i + 2] +
pSrc[i + 3] * filterCoeffs[i + 3];
}
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
sum >>= resultDivFactor;
Expand All @@ -161,16 +166,15 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
sum *= dScaler;
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j] = (SAMPLETYPE)sum;
src ++;
}
return end;
}


uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const
uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels)
{
uint i, j, end, c;
LONG_SAMPLETYPE *sum=(LONG_SAMPLETYPE*)malloc(numChannels*sizeof(*sum));
int j, end;

#ifdef SOUNDTOUCH_FLOAT_SAMPLES
// when using floating point samples, use a scaler instead of a divider
// because division is much slower operation than multiplying.
Expand All @@ -181,17 +185,21 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
assert(src != NULL);
assert(dest != NULL);
assert(filterCoeffs != NULL);
assert(numChannels < 16);

end = numChannels * (numSamples - length);

for (c = 0; c < numChannels; c ++)
{
sum[c] = 0;
}

#pragma omp parallel for
for (j = 0; j < end; j += numChannels)
{
const SAMPLETYPE *ptr;
LONG_SAMPLETYPE sums[16];
uint c, i;

for (c = 0; c < numChannels; c ++)
{
sums[c] = 0;
}

ptr = src + j;

Expand All @@ -200,21 +208,19 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
SAMPLETYPE coef=filterCoeffs[i];
for (c = 0; c < numChannels; c ++)
{
sum[c] += ptr[0] * coef;
sums[c] += ptr[0] * coef;
ptr ++;
}
}

for (c = 0; c < numChannels; c ++)
{
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
sum[c] >>= resultDivFactor;
sums[c] >>= resultDivFactor;
#else
sum[c] *= dScaler;
sums[c] *= dScaler;
#endif // SOUNDTOUCH_INTEGER_SAMPLES
*dest = (SAMPLETYPE)sum[c];
dest++;
sum[c] = 0;
dest[j+c] = (SAMPLETYPE)sums[c];
}
}
return numSamples - length;
Expand Down Expand Up @@ -253,7 +259,7 @@ uint FIRFilter::getLength() const
//
// Note : The amount of outputted samples is by value of 'filter_length'
// 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)
{
assert(length > 0);
assert(lengthDiv8 * 8 == length);
Expand Down
8 changes: 4 additions & 4 deletions Externals/soundtouch/FIRFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// Last changed : $Date: 2013-06-13 01:24:44 +1000 (Thu, 13 Jun 2013) $
// Last changed : $Date: 2015-02-21 23:24:29 +0200 (Sat, 21 Feb 2015) $
// File revision : $Revision: 4 $
//
// $Id: FIRFilter.h 171 2013-06-12 15:24:44Z oparviai $
// $Id: FIRFilter.h 202 2015-02-21 21:24:29Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -71,7 +71,7 @@ class FIRFilter
virtual uint evaluateFilterMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples) const;
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels) const;
virtual uint evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples, uint numChannels);

public:
FIRFilter();
Expand All @@ -91,7 +91,7 @@ class FIRFilter
uint evaluate(SAMPLETYPE *dest,
const SAMPLETYPE *src,
uint numSamples,
uint numChannels) const;
uint numChannels);

uint getLength() const;

Expand Down
4 changes: 2 additions & 2 deletions Externals/soundtouch/InterpolateCubic.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// $Id: InterpolateCubic.h 179 2014-01-06 18:41:42Z oparviai $
// $Id: InterpolateCubic.h 225 2015-07-26 14:45:48Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -56,7 +56,7 @@ class InterpolateCubic : public TransposerBase
const SAMPLETYPE *src,
int &srcSamples);

float fract;
double fract;

public:
InterpolateCubic();
Expand Down
15 changes: 8 additions & 7 deletions Externals/soundtouch/InterpolateLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// $Id: InterpolateLinear.cpp 180 2014-01-06 19:16:02Z oparviai $
// $Id: InterpolateLinear.cpp 225 2015-07-26 14:45:48Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -170,9 +170,9 @@ int InterpolateLinearInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE

// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
// iRate, larger faster iRates.
void InterpolateLinearInteger::setRate(float newRate)
void InterpolateLinearInteger::setRate(double newRate)
{
iRate = (int)(newRate * SCALE + 0.5f);
iRate = (int)(newRate * SCALE + 0.5);
TransposerBase::setRate(newRate);
}

Expand All @@ -190,7 +190,7 @@ InterpolateLinearFloat::InterpolateLinearFloat() : TransposerBase()
// Notice: use local function calling syntax for sake of clarity,
// to indicate the fact that C++ constructor can't call virtual functions.
resetRegisters();
setRate(1.0f);
setRate(1.0);
}


Expand Down Expand Up @@ -275,12 +275,13 @@ int InterpolateLinearFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *s
i = 0;
while (srcCount < srcSampleEnd)
{
float temp, vol1;
float temp, vol1, fract_float;

vol1 = (1.0f- fract);
vol1 = (float)(1.0 - fract);
fract_float = (float)fract;
for (int c = 0; c < numChannels; c ++)
{
temp = vol1 * src[c] + fract * src[c + numChannels];
temp = vol1 * src[c] + fract_float * src[c + numChannels];
*dest = (SAMPLETYPE)temp;
dest ++;
}
Expand Down
6 changes: 3 additions & 3 deletions Externals/soundtouch/InterpolateLinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
///
////////////////////////////////////////////////////////////////////////////////
//
// $Id: InterpolateLinear.h 179 2014-01-06 18:41:42Z oparviai $
// $Id: InterpolateLinear.h 225 2015-07-26 14:45:48Z oparviai $
//
////////////////////////////////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -63,15 +63,15 @@ class InterpolateLinearInteger : public TransposerBase

/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
/// rate, larger faster rates.
virtual void setRate(float newRate);
virtual void setRate(double newRate);
};


/// Linear transposer class that uses floating point arithmetics
class InterpolateLinearFloat : public TransposerBase
{
protected:
float fract;
double fract;

virtual void resetRegisters();

Expand Down

0 comments on commit fb55544

Please sign in to comment.