2017-04-10 16:17:10 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "converter.h"
|
|
|
|
|
|
|
|
#include "mixer_defs.h"
|
|
|
|
|
|
|
|
|
|
|
|
SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType dstType, ALsizei numchans, ALsizei srcRate, ALsizei dstRate)
|
|
|
|
{
|
|
|
|
SampleConverter *converter;
|
2017-06-28 17:17:36 +00:00
|
|
|
ALsizei step;
|
2017-04-10 16:17:10 +00:00
|
|
|
|
|
|
|
if(numchans <= 0 || srcRate <= 0 || dstRate <= 0)
|
|
|
|
return NULL;
|
|
|
|
|
2017-04-18 21:11:15 +00:00
|
|
|
converter = al_calloc(16, FAM_SIZE(SampleConverter, Chan, numchans));
|
2017-04-10 16:17:10 +00:00
|
|
|
converter->mSrcType = srcType;
|
|
|
|
converter->mDstType = dstType;
|
|
|
|
converter->mNumChannels = numchans;
|
|
|
|
converter->mSrcTypeSize = BytesFromDevFmt(srcType);
|
|
|
|
converter->mDstTypeSize = BytesFromDevFmt(dstType);
|
|
|
|
|
|
|
|
converter->mSrcPrepCount = 0;
|
|
|
|
converter->mFracOffset = 0;
|
2017-06-24 17:52:26 +00:00
|
|
|
|
|
|
|
/* Have to set the mixer FPU mode since that's what the resampler code expects. */
|
2017-07-14 05:30:39 +00:00
|
|
|
START_MIXER_MODE();
|
2017-06-28 17:17:36 +00:00
|
|
|
step = fastf2i(minf((ALdouble)srcRate / dstRate, MAX_PITCH)*FRACTIONONE + 0.5f);
|
|
|
|
converter->mIncrement = maxi(step, 1);
|
2017-04-10 16:17:10 +00:00
|
|
|
if(converter->mIncrement == FRACTIONONE)
|
2017-08-17 01:09:53 +00:00
|
|
|
converter->mResample = Resample_copy_C;
|
2017-04-10 16:17:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* TODO: Allow other resamplers. */
|
2017-08-27 17:16:36 +00:00
|
|
|
BsincPrepare(converter->mIncrement, &converter->mState.bsinc, &bsinc12);
|
2017-08-25 12:52:19 +00:00
|
|
|
converter->mResample = SelectResampler(BSinc12Resampler);
|
2017-04-10 16:17:10 +00:00
|
|
|
}
|
2017-07-14 05:30:39 +00:00
|
|
|
END_MIXER_MODE();
|
2017-04-10 16:17:10 +00:00
|
|
|
|
|
|
|
return converter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroySampleConverter(SampleConverter **converter)
|
|
|
|
{
|
|
|
|
if(converter)
|
|
|
|
{
|
|
|
|
al_free(*converter);
|
|
|
|
*converter = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline ALfloat Sample_ALbyte(ALbyte val)
|
|
|
|
{ return val * (1.0f/128.0f); }
|
|
|
|
static inline ALfloat Sample_ALubyte(ALubyte val)
|
|
|
|
{ return Sample_ALbyte((ALint)val - 128); }
|
|
|
|
|
|
|
|
static inline ALfloat Sample_ALshort(ALshort val)
|
|
|
|
{ return val * (1.0f/32768.0f); }
|
|
|
|
static inline ALfloat Sample_ALushort(ALushort val)
|
|
|
|
{ return Sample_ALshort((ALint)val - 32768); }
|
|
|
|
|
|
|
|
static inline ALfloat Sample_ALint(ALint val)
|
|
|
|
{ return (val>>7) * (1.0f/16777216.0f); }
|
|
|
|
static inline ALfloat Sample_ALuint(ALuint val)
|
2017-06-23 12:34:43 +00:00
|
|
|
{ return Sample_ALint(val - INT_MAX - 1); }
|
2017-04-10 16:17:10 +00:00
|
|
|
|
|
|
|
static inline ALfloat Sample_ALfloat(ALfloat val)
|
|
|
|
{ return val; }
|
|
|
|
|
|
|
|
#define DECL_TEMPLATE(T) \
|
2017-04-13 18:48:43 +00:00
|
|
|
static inline void Load_##T(ALfloat *restrict dst, const T *restrict src, \
|
|
|
|
ALint srcstep, ALsizei samples) \
|
2017-04-10 16:17:10 +00:00
|
|
|
{ \
|
|
|
|
ALsizei i; \
|
|
|
|
for(i = 0;i < samples;i++) \
|
|
|
|
dst[i] = Sample_##T(src[i*srcstep]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_TEMPLATE(ALbyte)
|
|
|
|
DECL_TEMPLATE(ALubyte)
|
|
|
|
DECL_TEMPLATE(ALshort)
|
|
|
|
DECL_TEMPLATE(ALushort)
|
|
|
|
DECL_TEMPLATE(ALint)
|
|
|
|
DECL_TEMPLATE(ALuint)
|
|
|
|
DECL_TEMPLATE(ALfloat)
|
|
|
|
|
|
|
|
#undef DECL_TEMPLATE
|
|
|
|
|
|
|
|
static void LoadSamples(ALfloat *dst, const ALvoid *src, ALint srcstep, enum DevFmtType srctype, ALsizei samples)
|
|
|
|
{
|
|
|
|
switch(srctype)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
|
|
|
Load_ALbyte(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUByte:
|
|
|
|
Load_ALubyte(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
|
|
|
Load_ALshort(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUShort:
|
|
|
|
Load_ALushort(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
|
|
|
Load_ALint(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUInt:
|
|
|
|
Load_ALuint(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtFloat:
|
|
|
|
Load_ALfloat(dst, src, srcstep, samples);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline ALbyte ALbyte_Sample(ALfloat val)
|
2017-06-24 17:52:26 +00:00
|
|
|
{ return fastf2i(clampf(val*128.0f, -128.0f, 127.0f)); }
|
2017-04-10 16:17:10 +00:00
|
|
|
static inline ALubyte ALubyte_Sample(ALfloat val)
|
|
|
|
{ return ALbyte_Sample(val)+128; }
|
|
|
|
|
|
|
|
static inline ALshort ALshort_Sample(ALfloat val)
|
2017-06-24 17:52:26 +00:00
|
|
|
{ return fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f)); }
|
2017-04-10 16:17:10 +00:00
|
|
|
static inline ALushort ALushort_Sample(ALfloat val)
|
|
|
|
{ return ALshort_Sample(val)+32768; }
|
|
|
|
|
|
|
|
static inline ALint ALint_Sample(ALfloat val)
|
2017-06-24 17:52:26 +00:00
|
|
|
{ return fastf2i(clampf(val*16777216.0f, -16777216.0f, 16777215.0f)) << 7; }
|
2017-04-10 16:17:10 +00:00
|
|
|
static inline ALuint ALuint_Sample(ALfloat val)
|
|
|
|
{ return ALint_Sample(val)+INT_MAX+1; }
|
|
|
|
|
|
|
|
static inline ALfloat ALfloat_Sample(ALfloat val)
|
|
|
|
{ return val; }
|
|
|
|
|
|
|
|
#define DECL_TEMPLATE(T) \
|
2017-04-13 18:48:43 +00:00
|
|
|
static inline void Store_##T(T *restrict dst, const ALfloat *restrict src, \
|
|
|
|
ALint dststep, ALsizei samples) \
|
2017-04-10 16:17:10 +00:00
|
|
|
{ \
|
|
|
|
ALsizei i; \
|
|
|
|
for(i = 0;i < samples;i++) \
|
|
|
|
dst[i*dststep] = T##_Sample(src[i]); \
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_TEMPLATE(ALbyte)
|
|
|
|
DECL_TEMPLATE(ALubyte)
|
|
|
|
DECL_TEMPLATE(ALshort)
|
|
|
|
DECL_TEMPLATE(ALushort)
|
|
|
|
DECL_TEMPLATE(ALint)
|
|
|
|
DECL_TEMPLATE(ALuint)
|
|
|
|
DECL_TEMPLATE(ALfloat)
|
|
|
|
|
|
|
|
#undef DECL_TEMPLATE
|
|
|
|
|
|
|
|
static void StoreSamples(ALvoid *dst, const ALfloat *src, ALint dststep, enum DevFmtType dsttype, ALsizei samples)
|
|
|
|
{
|
|
|
|
switch(dsttype)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
|
|
|
Store_ALbyte(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUByte:
|
|
|
|
Store_ALubyte(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
|
|
|
Store_ALshort(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUShort:
|
|
|
|
Store_ALushort(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
|
|
|
Store_ALint(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtUInt:
|
|
|
|
Store_ALuint(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
case DevFmtFloat:
|
|
|
|
Store_ALfloat(dst, src, dststep, samples);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframes)
|
|
|
|
{
|
|
|
|
ALint prepcount = converter->mSrcPrepCount;
|
|
|
|
ALsizei increment = converter->mIncrement;
|
|
|
|
ALsizei DataPosFrac = converter->mFracOffset;
|
|
|
|
ALuint64 DataSize64;
|
|
|
|
|
|
|
|
if(prepcount < 0)
|
|
|
|
{
|
|
|
|
/* Negative prepcount means we need to skip that many input samples. */
|
|
|
|
if(-prepcount >= srcframes)
|
|
|
|
return 0;
|
|
|
|
srcframes += prepcount;
|
|
|
|
prepcount = 0;
|
|
|
|
}
|
|
|
|
|
2017-06-23 15:13:42 +00:00
|
|
|
if(srcframes < 1)
|
|
|
|
{
|
|
|
|
/* No output samples if there's no input samples. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-10 16:17:10 +00:00
|
|
|
if(prepcount < MAX_POST_SAMPLES+MAX_PRE_SAMPLES &&
|
|
|
|
MAX_POST_SAMPLES+MAX_PRE_SAMPLES-prepcount >= srcframes)
|
|
|
|
{
|
|
|
|
/* Not enough input samples to generate an output sample. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataSize64 = prepcount;
|
|
|
|
DataSize64 += srcframes;
|
|
|
|
DataSize64 -= MAX_POST_SAMPLES+MAX_PRE_SAMPLES;
|
|
|
|
DataSize64 <<= FRACTIONBITS;
|
|
|
|
DataSize64 -= DataPosFrac;
|
|
|
|
|
|
|
|
/* If we have a full prep, we can generate at least one sample. */
|
2017-06-26 15:55:22 +00:00
|
|
|
return (ALsizei)clampu64((DataSize64 + increment-1)/increment, 1, BUFFERSIZE);
|
2017-04-10 16:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-04-10 20:40:45 +00:00
|
|
|
ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid **src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes)
|
2017-04-10 16:17:10 +00:00
|
|
|
{
|
|
|
|
const ALsizei SrcFrameSize = converter->mNumChannels * converter->mSrcTypeSize;
|
|
|
|
const ALsizei DstFrameSize = converter->mNumChannels * converter->mDstTypeSize;
|
|
|
|
const ALsizei increment = converter->mIncrement;
|
|
|
|
ALsizei pos = 0;
|
|
|
|
|
2017-07-14 05:30:39 +00:00
|
|
|
START_MIXER_MODE();
|
2017-06-22 22:07:24 +00:00
|
|
|
while(pos < dstframes && *srcframes > 0)
|
2017-04-10 16:17:10 +00:00
|
|
|
{
|
|
|
|
ALfloat *restrict SrcData = ASSUME_ALIGNED(converter->mSrcSamples, 16);
|
|
|
|
ALfloat *restrict DstData = ASSUME_ALIGNED(converter->mDstSamples, 16);
|
|
|
|
ALint prepcount = converter->mSrcPrepCount;
|
|
|
|
ALsizei DataPosFrac = converter->mFracOffset;
|
|
|
|
ALuint64 DataSize64;
|
|
|
|
ALsizei DstSize;
|
|
|
|
ALint toread;
|
|
|
|
ALsizei chan;
|
|
|
|
|
|
|
|
if(prepcount < 0)
|
|
|
|
{
|
|
|
|
/* Negative prepcount means we need to skip that many input samples. */
|
|
|
|
if(-prepcount >= *srcframes)
|
|
|
|
{
|
|
|
|
converter->mSrcPrepCount = prepcount + *srcframes;
|
|
|
|
*srcframes = 0;
|
|
|
|
break;
|
|
|
|
}
|
2017-04-10 20:40:45 +00:00
|
|
|
*src = (const ALbyte*)*src + SrcFrameSize*-prepcount;
|
2017-04-10 16:17:10 +00:00
|
|
|
*srcframes += prepcount;
|
2017-06-22 22:07:24 +00:00
|
|
|
converter->mSrcPrepCount = 0;
|
|
|
|
continue;
|
2017-04-10 16:17:10 +00:00
|
|
|
}
|
|
|
|
toread = mini(*srcframes, BUFFERSIZE-(MAX_POST_SAMPLES+MAX_PRE_SAMPLES));
|
|
|
|
|
|
|
|
if(prepcount < MAX_POST_SAMPLES+MAX_PRE_SAMPLES &&
|
|
|
|
MAX_POST_SAMPLES+MAX_PRE_SAMPLES-prepcount >= toread)
|
|
|
|
{
|
|
|
|
/* Not enough input samples to generate an output sample. Store
|
|
|
|
* what we're given for later.
|
|
|
|
*/
|
|
|
|
for(chan = 0;chan < converter->mNumChannels;chan++)
|
|
|
|
LoadSamples(&converter->Chan[chan].mPrevSamples[prepcount],
|
2017-06-22 22:07:24 +00:00
|
|
|
(const ALbyte*)*src + converter->mSrcTypeSize*chan,
|
2017-04-10 16:17:10 +00:00
|
|
|
converter->mNumChannels, converter->mSrcType, toread
|
|
|
|
);
|
|
|
|
|
|
|
|
converter->mSrcPrepCount = prepcount + toread;
|
|
|
|
*srcframes = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataSize64 = prepcount;
|
|
|
|
DataSize64 += toread;
|
|
|
|
DataSize64 -= MAX_POST_SAMPLES+MAX_PRE_SAMPLES;
|
|
|
|
DataSize64 <<= FRACTIONBITS;
|
|
|
|
DataSize64 -= DataPosFrac;
|
|
|
|
|
|
|
|
/* If we have a full prep, we can generate at least one sample. */
|
2017-06-26 15:55:22 +00:00
|
|
|
DstSize = (ALsizei)clampu64((DataSize64 + increment-1)/increment, 1, BUFFERSIZE);
|
2017-04-10 16:17:10 +00:00
|
|
|
DstSize = mini(DstSize, dstframes-pos);
|
|
|
|
|
|
|
|
for(chan = 0;chan < converter->mNumChannels;chan++)
|
|
|
|
{
|
2017-04-10 20:40:45 +00:00
|
|
|
const ALbyte *SrcSamples = (const ALbyte*)*src + converter->mSrcTypeSize*chan;
|
2017-06-23 15:25:47 +00:00
|
|
|
ALbyte *DstSamples = (ALbyte*)dst + converter->mDstTypeSize*chan;
|
2017-04-10 16:17:10 +00:00
|
|
|
const ALfloat *ResampledData;
|
|
|
|
ALsizei SrcDataEnd;
|
|
|
|
|
|
|
|
/* Load the previous samples into the source data first, then the
|
|
|
|
* new samples from the input buffer.
|
|
|
|
*/
|
|
|
|
memcpy(SrcData, converter->Chan[chan].mPrevSamples,
|
|
|
|
prepcount*sizeof(ALfloat));
|
|
|
|
LoadSamples(SrcData + prepcount, SrcSamples,
|
|
|
|
converter->mNumChannels, converter->mSrcType, toread
|
|
|
|
);
|
|
|
|
|
|
|
|
/* Store as many prep samples for next time as possible, given the
|
|
|
|
* number of output samples being generated.
|
|
|
|
*/
|
|
|
|
SrcDataEnd = (DataPosFrac + increment*DstSize)>>FRACTIONBITS;
|
|
|
|
if(SrcDataEnd >= prepcount+toread)
|
|
|
|
memset(converter->Chan[chan].mPrevSamples, 0,
|
2017-06-23 15:25:47 +00:00
|
|
|
sizeof(converter->Chan[chan].mPrevSamples));
|
2017-04-10 16:17:10 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
size_t len = mini(MAX_PRE_SAMPLES+MAX_POST_SAMPLES, prepcount+toread-SrcDataEnd);
|
|
|
|
memcpy(converter->Chan[chan].mPrevSamples, &SrcData[SrcDataEnd],
|
|
|
|
len*sizeof(ALfloat));
|
|
|
|
memset(converter->Chan[chan].mPrevSamples+len, 0,
|
|
|
|
sizeof(converter->Chan[chan].mPrevSamples) - len*sizeof(ALfloat));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now resample, and store the result in the output buffer. */
|
2017-06-24 17:52:26 +00:00
|
|
|
ResampledData = converter->mResample(&converter->mState,
|
2017-04-10 16:17:10 +00:00
|
|
|
SrcData+MAX_PRE_SAMPLES, DataPosFrac, increment,
|
|
|
|
DstData, DstSize
|
|
|
|
);
|
|
|
|
|
|
|
|
StoreSamples(DstSamples, ResampledData, converter->mNumChannels,
|
|
|
|
converter->mDstType, DstSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the number of prep samples still available, as well as the
|
|
|
|
* fractional offset.
|
|
|
|
*/
|
|
|
|
DataPosFrac += increment*DstSize;
|
|
|
|
converter->mSrcPrepCount = mini(MAX_PRE_SAMPLES+MAX_POST_SAMPLES,
|
|
|
|
prepcount+toread-(DataPosFrac>>FRACTIONBITS));
|
|
|
|
converter->mFracOffset = DataPosFrac & FRACTIONMASK;
|
|
|
|
|
|
|
|
/* Update the src and dst pointers in case there's still more to do. */
|
2017-04-10 20:40:45 +00:00
|
|
|
*src = (const ALbyte*)*src + SrcFrameSize*(DataPosFrac>>FRACTIONBITS);
|
2017-04-10 16:17:10 +00:00
|
|
|
*srcframes -= mini(*srcframes, (DataPosFrac>>FRACTIONBITS));
|
|
|
|
|
|
|
|
dst = (ALbyte*)dst + DstFrameSize*DstSize;
|
|
|
|
pos += DstSize;
|
|
|
|
}
|
2017-07-14 05:30:39 +00:00
|
|
|
END_MIXER_MODE();
|
2017-04-10 16:17:10 +00:00
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
2017-04-11 14:25:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
ChannelConverter *CreateChannelConverter(enum DevFmtType srcType, enum DevFmtChannels srcChans, enum DevFmtChannels dstChans)
|
|
|
|
{
|
|
|
|
ChannelConverter *converter;
|
|
|
|
|
|
|
|
if(srcChans != dstChans && !((srcChans == DevFmtMono && dstChans == DevFmtStereo) ||
|
|
|
|
(srcChans == DevFmtStereo && dstChans == DevFmtMono)))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
converter = al_calloc(DEF_ALIGN, sizeof(*converter));
|
|
|
|
converter->mSrcType = srcType;
|
|
|
|
converter->mSrcChans = srcChans;
|
|
|
|
converter->mDstChans = dstChans;
|
|
|
|
|
|
|
|
return converter;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DestroyChannelConverter(ChannelConverter **converter)
|
|
|
|
{
|
|
|
|
if(converter)
|
|
|
|
{
|
|
|
|
al_free(*converter);
|
|
|
|
*converter = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define DECL_TEMPLATE(T) \
|
2017-04-11 18:47:23 +00:00
|
|
|
static void Mono2Stereo##T(ALfloat *restrict dst, const T *src, ALsizei frames)\
|
2017-04-11 14:25:55 +00:00
|
|
|
{ \
|
|
|
|
ALsizei i; \
|
|
|
|
for(i = 0;i < frames;i++) \
|
2017-04-11 19:06:57 +00:00
|
|
|
dst[i*2 + 1] = dst[i*2 + 0] = Sample_##T(src[i]) * 0.707106781187f; \
|
2017-04-11 14:25:55 +00:00
|
|
|
} \
|
|
|
|
\
|
2017-04-11 18:47:23 +00:00
|
|
|
static void Stereo2Mono##T(ALfloat *restrict dst, const T *src, ALsizei frames)\
|
2017-04-11 14:25:55 +00:00
|
|
|
{ \
|
|
|
|
ALsizei i; \
|
|
|
|
for(i = 0;i < frames;i++) \
|
2017-04-11 19:06:57 +00:00
|
|
|
dst[i] = (Sample_##T(src[i*2 + 0])+Sample_##T(src[i*2 + 1])) * \
|
2017-04-11 14:25:55 +00:00
|
|
|
0.707106781187f; \
|
|
|
|
}
|
|
|
|
|
|
|
|
DECL_TEMPLATE(ALbyte)
|
|
|
|
DECL_TEMPLATE(ALubyte)
|
|
|
|
DECL_TEMPLATE(ALshort)
|
|
|
|
DECL_TEMPLATE(ALushort)
|
|
|
|
DECL_TEMPLATE(ALint)
|
|
|
|
DECL_TEMPLATE(ALuint)
|
|
|
|
DECL_TEMPLATE(ALfloat)
|
|
|
|
|
|
|
|
#undef DECL_TEMPLATE
|
|
|
|
|
|
|
|
void ChannelConverterInput(ChannelConverter *converter, const ALvoid *src, ALfloat *dst, ALsizei frames)
|
|
|
|
{
|
|
|
|
if(converter->mSrcChans == converter->mDstChans)
|
|
|
|
{
|
|
|
|
LoadSamples(dst, src, 1, converter->mSrcType,
|
2017-04-13 01:26:07 +00:00
|
|
|
frames*ChannelsFromDevFmt(converter->mSrcChans, 0));
|
2017-04-11 14:25:55 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(converter->mSrcChans == DevFmtStereo && converter->mDstChans == DevFmtMono)
|
|
|
|
{
|
|
|
|
switch(converter->mSrcType)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALbyte(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUByte:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALubyte(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALshort(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUShort:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALushort(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALint(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUInt:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALuint(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtFloat:
|
2017-04-11 18:47:23 +00:00
|
|
|
Stereo2MonoALfloat(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /*if(converter->mSrcChans == DevFmtMono && converter->mDstChans == DevFmtStereo)*/
|
|
|
|
{
|
|
|
|
switch(converter->mSrcType)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALbyte(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUByte:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALubyte(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALshort(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUShort:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALushort(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALint(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtUInt:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALuint(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
case DevFmtFloat:
|
2017-04-11 18:47:23 +00:00
|
|
|
Mono2StereoALfloat(dst, src, frames);
|
2017-04-11 14:25:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|