13 #ifndef _MpResamplerBase_h_ 14 #define _MpResamplerBase_h_ 19 #include <os/OsStatus.h> 47 int32_t quality = -1);
76 virtual OsStatus
resample(uint32_t channelIndex,
79 uint32_t& inSamplesProcessed,
81 uint32_t outBufLength,
82 uint32_t& outSamplesWritten);
91 uint32_t& inSamplesProcessed,
93 uint32_t outBufLength,
94 uint32_t& outSamplesWritten);
111 uint32_t inRate, uint32_t outRate,
112 UtlString optionalIdStr =
"");
129 virtual OsStatus
setInputRate(
const uint32_t inputRate);
141 virtual OsStatus
setQuality(
const int32_t quality);
165 int numInputSamples,
int &remainingSamplesNum);
169 int numOutputSamples,
int &remainingSamplesNum);
196 int numInputSamples,
int &remainingSamplesNum)
198 int numOutputSamples = outputRate*numInputSamples/inputRate;
199 remainingSamplesNum = numInputSamples - inputRate*numOutputSamples/outputRate;
200 return numOutputSamples;
204 int numOutputSamples,
int &remainingSamplesNum)
206 int numInputSamples = inputRate*numOutputSamples/outputRate;
207 remainingSamplesNum = numOutputSamples - outputRate*numInputSamples/inputRate;
208 return numInputSamples;
211 #endif // _MpResamplerBase_h_ uint32_t getInputRate() const
Return input sampling rate.
Definition: MpResampler.cpp:242
Generic audio resampler.
Definition: MpResampler.h:34
virtual OsStatus resampleInterleavedStereo(const MpAudioSample *pInBuf, uint32_t inBufLength, uint32_t &inSamplesProcessed, MpAudioSample *pOutBuf, uint32_t outBufLength, uint32_t &outSamplesWritten)
Resample interleaved stereo audio data.
Definition: MpResampler.cpp:129
static int getNumSamplesConverted(uint32_t inputRate, uint32_t outputRate, int numInputSamples, int &remainingSamplesNum)
Definition: MpResampler.h:195
virtual OsStatus resample(uint32_t channelIndex, const MpAudioSample *pInBuf, uint32_t inBufLength, uint32_t &inSamplesProcessed, MpAudioSample *pOutBuf, uint32_t outBufLength, uint32_t &outSamplesWritten)
Resample audio data coming from the specified channel.
Definition: MpResampler.cpp:72
uint32_t mOutputRate
Definition: MpResampler.h:184
virtual OsStatus setOutputRate(const uint32_t outputRate)
Set the output sample rate, in Hz.
Definition: MpResampler.cpp:228
static MpResamplerBase * createResampler(uint32_t numChannels, uint32_t inputRate, uint32_t outputRate, int32_t quality=-1)
Definition: MpResampler.cpp:33
int32_t getQuality() const
Return quality of resampling conversion.
Definition: MpResampler.cpp:253
virtual OsStatus resetStream()
Reset resampler state to prepare for processing new (unrelated) stream.
Definition: MpResampler.cpp:65
MpResamplerBase(uint32_t numChannels, uint32_t inputRate, uint32_t outputRate, int32_t quality)
Constructor.
Definition: MpResampler.cpp:47
int16_t MpAudioSample
Definition: MpTypes.h:44
Smart pointer to MpAudioBuf.
Definition: MpAudioBuf.h:168
uint32_t getOutputRate() const
Return output sampling rate.
Definition: MpResampler.cpp:247
OsStatus resampleBufPtr(const MpAudioBufPtr &inBuf, MpAudioBufPtr &outBuf, uint32_t inRate, uint32_t outRate, UtlString optionalIdStr="")
resample the buffer given, and return a new resampled one.
Definition: MpResampler.cpp:140
uint32_t mInputRate
Definition: MpResampler.h:183
virtual OsStatus setInputRate(const uint32_t inputRate)
Set the input sample rate, in Hz.
Definition: MpResampler.cpp:222
virtual ~MpResamplerBase()
Destructor.
Definition: MpResampler.cpp:58
virtual OsStatus setQuality(const int32_t quality)
Set the quality of resampling conversion.
Definition: MpResampler.cpp:234
int32_t mQuality
Definition: MpResampler.h:185
uint32_t mNumChannels
Definition: MpResampler.h:182
static int getNumSamplesOriginal(uint32_t inputRate, uint32_t outputRate, int numOutputSamples, int &remainingSamplesNum)
Definition: MpResampler.h:203