mirror of
https://github.com/azahar-emu/soundtouch
synced 2025-11-07 07:30:02 +01:00
Implemented integer version of linear interpolator
This commit is contained in:
parent
f16b062219
commit
026ebe3841
@ -69,9 +69,31 @@ void InterpolateLinearInteger::resetRegisters()
|
|||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
int InterpolateLinearInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
int InterpolateLinearInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
{
|
{
|
||||||
// not yet implemented
|
int i;
|
||||||
assert(FALSE);
|
int srcSampleEnd = srcSamples - 1;
|
||||||
return 0;
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
LONG_SAMPLETYPE temp;
|
||||||
|
|
||||||
|
assert(iFract < SCALE);
|
||||||
|
|
||||||
|
temp = (SCALE - iFract) * src[0] + iFract * src[1];
|
||||||
|
dest[i] = (SAMPLETYPE)(temp / SCALE);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iFract += iRate;
|
||||||
|
|
||||||
|
int iWhole = iFract / SCALE;
|
||||||
|
iFract -= iWhole * SCALE;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += iWhole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -80,8 +102,35 @@ int InterpolateLinearInteger::transposeMono(SAMPLETYPE *dest, const SAMPLETYPE *
|
|||||||
// the "dest" buffer
|
// the "dest" buffer
|
||||||
int InterpolateLinearInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
int InterpolateLinearInteger::transposeStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, int &srcSamples)
|
||||||
{
|
{
|
||||||
// not yet implemented
|
int i;
|
||||||
return 0;
|
int srcSampleEnd = srcSamples - 1;
|
||||||
|
int srcCount = 0;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (srcCount < srcSampleEnd)
|
||||||
|
{
|
||||||
|
LONG_SAMPLETYPE temp0;
|
||||||
|
LONG_SAMPLETYPE temp1;
|
||||||
|
|
||||||
|
assert(iFract < SCALE);
|
||||||
|
|
||||||
|
temp0 = (SCALE - iFract) * src[0] + iFract * src[2];
|
||||||
|
temp1 = (SCALE - iFract) * src[1] + iFract * src[3];
|
||||||
|
dest[0] = (SAMPLETYPE)(temp0 / SCALE);
|
||||||
|
dest[1] = (SAMPLETYPE)(temp1 / SCALE);
|
||||||
|
dest += 2;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
iFract += iRate;
|
||||||
|
|
||||||
|
int iWhole = iFract / SCALE;
|
||||||
|
iFract -= iWhole * SCALE;
|
||||||
|
srcCount += iWhole;
|
||||||
|
src += 2*iWhole;
|
||||||
|
}
|
||||||
|
srcSamples = srcCount;
|
||||||
|
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -100,8 +149,8 @@ int InterpolateLinearInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE
|
|||||||
vol1 = (SCALE - iFract);
|
vol1 = (SCALE - iFract);
|
||||||
for (int c = 0; c < numChannels; c ++)
|
for (int c = 0; c < numChannels; c ++)
|
||||||
{
|
{
|
||||||
temp = iFract * src[c] + vol1 * src[c + numChannels];
|
temp = vol1 * src[c] + iFract * src[c + numChannels];
|
||||||
*dest = (SAMPLETYPE)(temp / SCALE);
|
dest[0] = (SAMPLETYPE)(temp / SCALE);
|
||||||
dest ++;
|
dest ++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user