Generic audio resampler.
More...
#include <MpResampler.h>
|
|
virtual OsStatus | resetStream () |
| Reset resampler state to prepare for processing new (unrelated) stream. More...
|
|
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. More...
|
|
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. More...
|
|
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. More...
|
|
virtual OsStatus | setInputRate (const uint32_t inputRate) |
| Set the input sample rate, in Hz. More...
|
|
virtual OsStatus | setOutputRate (const uint32_t outputRate) |
| Set the output sample rate, in Hz. More...
|
|
virtual OsStatus | setQuality (const int32_t quality) |
| Set the quality of resampling conversion. More...
|
|
MpResamplerBase |
( |
uint32_t |
numChannels, |
|
|
uint32_t |
inputRate, |
|
|
uint32_t |
outputRate, |
|
|
int32_t |
quality |
|
) |
| |
Constructor.
- Parameters
-
[in] | numChannels | - The number of channels that the resampler will process. |
[in] | inputRate | - The sample rate of the input audio. |
[in] | outputRate | - The sample rate of the output audio. |
[in] | quality | - The quality parameter is used by some resamplers to control the tradeoff of quality for latency and complexity. |
MpResamplerBase * createResampler |
( |
uint32_t |
numChannels, |
|
|
uint32_t |
inputRate, |
|
|
uint32_t |
outputRate, |
|
|
int32_t |
quality = -1 |
|
) |
| |
|
static |
Reset resampler state to prepare for processing new (unrelated) stream.
OsStatus resample |
( |
uint32_t |
channelIndex, |
|
|
const MpAudioSample * |
pInBuf, |
|
|
uint32_t |
inBufLength, |
|
|
uint32_t & |
inSamplesProcessed, |
|
|
MpAudioSample * |
pOutBuf, |
|
|
uint32_t |
outBufLength, |
|
|
uint32_t & |
outSamplesWritten |
|
) |
| |
|
virtual |
Resample audio data coming from the specified channel.
- Parameters
-
[in] | channelIndex | - The index of the channel to process - base 0. Resample interleaved stereo audio data. |
[in] | pInBuf | - Pointer to the audio to resample. |
[in] | inBufLength | - The length in samples of the audio to resample. |
[out] | inSamplesProcessed | - The number of samples read from /p pInBuf during resampling. |
[out] | pOutBuf | - A pointer where the resampled audio will be stored. |
[in] | outBufLength | - The length in samples of /p pOutBuf. |
[out] | outSamplesWritten | - The number of resampled samples written to /p pOutBuf. |
- Return values
-
OS_INVALID_ARGUMENT | if the channelIndex is out of bounds. |
OS_SUCCESS | if the audio was resampled successfully. |
OsStatus resampleInterleavedStereo |
( |
const MpAudioSample * |
pInBuf, |
|
|
uint32_t |
inBufLength, |
|
|
uint32_t & |
inSamplesProcessed, |
|
|
MpAudioSample * |
pOutBuf, |
|
|
uint32_t |
outBufLength, |
|
|
uint32_t & |
outSamplesWritten |
|
) |
| |
|
virtual |
Resample interleaved stereo audio data.
- Parameters
-
[in] | pInBuf | - Pointer to the audio to resample. |
[in] | inBufLength | - The length in samples of the audio to resample. |
[out] | inSamplesProcessed | - The number of samples read from /p pInBuf during resampling. |
[out] | pOutBuf | - A pointer where the resampled audio will be stored. |
[in] | outBufLength | - The length in samples of /p pOutBuf. |
[out] | outSamplesWritten | - The number of resampled samples written to /p pOutBuf. |
- Return values
-
OS_INVALID_ARGUMENT | if the channelIndex is out of bounds. |
OS_SUCCESS | if the audio was resampled successfully. |
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.
Resample the buffer given. If errors happen, they are logged, outBuf is left unchanged, and return status is set to a value that is not OS_SUCCESS.
- Parameters
-
[in] | inBuf | - the ptr to buffer to resample. |
[out] | outBuf | - the ptr to the destination that will hold the resampled buffer. |
[in] | inRate | - The sample rate that inBuf samples are recorded in. |
[in] | outRate | - The sample rate that is requested to be converted to. |
[in] | optionalIdStr | - an optional identifier string used when reporting errors. |
- Return values
-
OS_SUCCESS | if the resampling happened without error, outBuf now will point to resampled buffer. |
All | other values - failure. |
OsStatus setInputRate |
( |
const uint32_t |
inputRate | ) |
|
|
virtual |
Set the input sample rate, in Hz.
- Parameters
-
[in] | inputRate | - The sample rate of the input audio. |
OsStatus setOutputRate |
( |
const uint32_t |
outputRate | ) |
|
|
virtual |
Set the output sample rate, in Hz.
- Parameters
-
[in] | outputRate | - The sample rate of the output audio. |
OsStatus setQuality |
( |
const int32_t |
quality | ) |
|
|
virtual |
Set the quality of resampling conversion.
- Parameters
-
[in] | quality | - The quality parameter is used by some resamplers to control the tradeoff of quality for latency and complexity. |
uint32_t getInputRate |
( |
| ) |
const |
Return input sampling rate.
uint32_t getOutputRate |
( |
| ) |
const |
Return output sampling rate.
int32_t getQuality |
( |
| ) |
const |
Return quality of resampling conversion.
int getNumSamplesConverted |
( |
uint32_t |
inputRate, |
|
|
uint32_t |
outputRate, |
|
|
int |
numInputSamples, |
|
|
int & |
remainingSamplesNum |
|
) |
| |
|
inlinestatic |
int getNumSamplesOriginal |
( |
uint32_t |
inputRate, |
|
|
uint32_t |
outputRate, |
|
|
int |
numOutputSamples, |
|
|
int & |
remainingSamplesNum |
|
) |
| |
|
inlinestatic |