InterpolateLinear.cpp   InterpolateLinear.cpp 
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
/// ///
/// Linear interpolation algorithm. /// Linear interpolation algorithm.
/// ///
/// Author : Copyright (c) Olli Parviainen /// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai 'at' iki.fi /// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch /// SoundTouch WWW: http://www.surina.net/soundtouch
/// ///
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// //
// $Id: InterpolateLinear.cpp 180 2014-01-06 19:16:02Z oparviai $ // $Id: InterpolateLinear.cpp 225 2015-07-26 14:45:48Z oparviai $
// //
/////////////////////////////////////////////////////////////////////////// ///// /////////////////////////////////////////////////////////////////////////// /////
// //
// License : // License :
// //
// SoundTouch audio processing library // SoundTouch audio processing library
// Copyright (c) Olli Parviainen // Copyright (c) Olli Parviainen
// //
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public // modify it under the terms of the GNU Lesser General Public
skipping to change at line 167 skipping to change at line 167
srcCount += iWhole; srcCount += iWhole;
src += iWhole * numChannels; src += iWhole * numChannels;
} }
srcSamples = srcCount; srcSamples = srcCount;
return i; return i;
} }
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slow er // Sets new target iRate. Normal iRate = 1.0, smaller values represent slow er
// iRate, larger faster iRates. // 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); TransposerBase::setRate(newRate);
} }
/////////////////////////////////////////////////////////////////////////// /// /////////////////////////////////////////////////////////////////////////// ///
// //
// InterpolateLinearFloat - floating point arithmetic implementation // InterpolateLinearFloat - floating point arithmetic implementation
// //
/////////////////////////////////////////////////////////////////////////// /// /////////////////////////////////////////////////////////////////////////// ///
// Constructor // Constructor
InterpolateLinearFloat::InterpolateLinearFloat() : TransposerBase() InterpolateLinearFloat::InterpolateLinearFloat() : TransposerBase()
{ {
// 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 functio ns. // to indicate the fact that C++ constructor can't call virtual functio ns.
resetRegisters(); resetRegisters();
setRate(1.0f); setRate(1.0);
} }
void InterpolateLinearFloat::resetRegisters() void InterpolateLinearFloat::resetRegisters()
{ {
fract = 0; fract = 0;
} }
// Transposes the sample rate of the given samples using linear interpolati on. // Transposes the sample rate of the given samples using linear interpolati on.
// '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
skipping to change at line 266 skipping to change at line 266
int InterpolateLinearFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETY PE *src, int &srcSamples) int InterpolateLinearFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETY PE *src, int &srcSamples)
{ {
int i; int i;
int srcSampleEnd = srcSamples - 1; int srcSampleEnd = srcSamples - 1;
int srcCount = 0; int srcCount = 0;
i = 0; i = 0;
while (srcCount < srcSampleEnd) 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 ++) for (int c = 0; c < numChannels; c ++)
{ {
temp = vol1 * src[c] + fract * src[c + numChannels]; temp = vol1 * src[c] + fract_float * src[c + numChan nels];
*dest = (SAMPLETYPE)temp; *dest = (SAMPLETYPE)temp;
dest ++; dest ++;
} }
i++; i++;
fract += rate; fract += rate;
int iWhole = (int)fract; int iWhole = (int)fract;
fract -= iWhole; fract -= iWhole;
srcCount += iWhole; srcCount += iWhole;
 End of changes. 7 change blocks. 
7 lines changed or deleted 8 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/