diff options
author | Chris Robinson <[email protected]> | 2017-04-10 09:17:10 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-10 09:26:06 -0700 |
commit | 6cc69c8d94744d66e68ffffb9b71f6714d86e710 (patch) | |
tree | 1fd85a1f2eb40e5383065560bb8d1a0de8df06ed /Alc/converter.h | |
parent | 81527cdbddc52338f5fb3c8b79139bf9d9186d3a (diff) |
Add a sample converter
This is intended to do conversions for interleaved samples, and supports
changing from one DevFmtType to another as well as resampling. It does not
handle remixing channels.
The mixer is more optimized to use the resampling functions directly. However,
this should prove useful for recording with certain backends that won't do the
conversion themselves.
Diffstat (limited to 'Alc/converter.h')
-rw-r--r-- | Alc/converter.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Alc/converter.h b/Alc/converter.h new file mode 100644 index 00000000..76b2520f --- /dev/null +++ b/Alc/converter.h @@ -0,0 +1,42 @@ +#ifndef CONVERTER_H +#define CONVERTER_H + +#include "alMain.h" +#include "alu.h" + +#ifdef __cpluspluc +extern "C" { +#endif + +typedef struct SampleConverter { + enum DevFmtType mSrcType; + enum DevFmtType mDstType; + ALsizei mNumChannels; + ALsizei mSrcTypeSize; + ALsizei mDstTypeSize; + + ALint mSrcPrepCount; + + ALsizei mFracOffset; + ALsizei mIncrement; + ResamplerFunc mResample; + + alignas(16) ALfloat mSrcSamples[BUFFERSIZE+MAX_PRE_SAMPLES+MAX_POST_SAMPLES]; + alignas(16) ALfloat mDstSamples[BUFFERSIZE]; + + struct { + alignas(16) ALfloat mPrevSamples[MAX_PRE_SAMPLES+MAX_POST_SAMPLES]; + } Chan[]; +} SampleConverter; + +SampleConverter *CreateSampleConverter(enum DevFmtType srcType, enum DevFmtType dstType, ALsizei numchans, ALsizei srcRate, ALsizei dstRate); +void DestroySampleConverter(SampleConverter **converter); + +ALsizei SampleConverterInput(SampleConverter *converter, const ALvoid *src, ALsizei *srcframes, ALvoid *dst, ALsizei dstframes); +ALsizei SampleConverterAvailableOut(SampleConverter *converter, ALsizei srcframes); + +#ifdef __cpluspluc +} +#endif + +#endif /* CONVERTER_H */ |