ResamplerInstance¶
class ResamplerInstance
A Resampler instance.
An object of this class will be created each time a Resampler
is requested.
Functions¶
Name | Description |
---|---|
ResamplerInstance | Constructs a new ResamplerInstance object. |
~ResamplerInstance | Default destructor. |
Initialize | Initializes a new instance of the resampler. |
Process | Processes the audio data. |
SetSampleRate | Changes the input and output sample rate. |
GetSampleRateIn | Gets the current input sample rate. |
GetSampleRateOut | Gets the current output sample rate. |
GetChannelCount | Gets the current channels count. |
GetRequiredInputFrames | Returns the required number of frames to have as input for the given amount of output frames. |
GetExpectedOutputFrames | Returns the expected number of frames to have as output for the given amount of input frames. |
GetInputLatency | Returns the current input latency in frames. |
GetOutputLatency | Returns the current output latency in frames. |
Reset | Resets the internal resampler state. |
Clear | Cleans up the internal resampler state and allocated data. |
Function Details¶
Clear¶
virtual void Clear() = 0
Cleans up the internal resampler state and allocated data.
Note
This method is called when the resampler is about to be destroyed.
GetChannelCount¶
[[nodiscard]] virtual AmUInt16 GetChannelCount() const = 0
Gets the current channels count.
- Return
- The current channels count.
GetExpectedOutputFrames¶
[[nodiscard]] virtual AmUInt64 GetExpectedOutputFrames(AmUInt64 inputFrameCount) const = 0
Returns the expected number of frames to have as output for the given amount of input frames.
- Parameter
inputFrameCount
- The number of input frames.
- Return
- The expected number of output frames for the given input frame count.
GetInputLatency¶
[[nodiscard]] virtual AmUInt64 GetInputLatency() const = 0
Returns the current input latency in frames.
- Return
- The resampler's current input latency in frames.
GetOutputLatency¶
[[nodiscard]] virtual AmUInt64 GetOutputLatency() const = 0
Returns the current output latency in frames.
- Return
- The resampler's current output latency in frames.
GetRequiredInputFrames¶
[[nodiscard]] virtual AmUInt64 GetRequiredInputFrames(AmUInt64 outputFrameCount) const = 0
Returns the required number of frames to have as input for the given amount of output frames.
- Parameter
outputFrameCount
- The number of output frames.
- Return
- The input frame count needed to produce the given output frame count.
GetSampleRateIn¶
[[nodiscard]] virtual AmUInt32 GetSampleRateIn() const = 0
Gets the current input sample rate.
- Return
- The current input sample rate.
GetSampleRateOut¶
[[nodiscard]] virtual AmUInt32 GetSampleRateOut() const = 0
Gets the current output sample rate.
- Return
- The current output sample rate.
Initialize¶
virtual void Initialize(AmUInt16 channelCount, AmUInt32 sampleRateIn, AmUInt32 sampleRateOut) = 0
Initializes a new instance of the resampler.
- Parameter
channelCount
- The number of channels in the audio data.
- Parameter
sampleRateIn
- The input sample rate.
- Parameter
sampleRateOut
- The output sample rate.
Process¶
virtual bool Process(const AudioBuffer& input, AmUInt64& inputFrames, AudioBuffer& output, AmUInt64& outputFrames) = 0
Processes the audio data.
- Parameter
input
- The input audio data.
- Parameter
inputFrames
- The number of frames in the input buffer.
- Parameter
output
- The output audio data.
- Parameter
outputFrames
- The number of frames in the output buffer.
- Return
true
if the resampling was successful,false
otherwise.
ResamplerInstance¶
ResamplerInstance() = default
Constructs a new ResamplerInstance
object.
This will initialize the resampler instance state to default values.
Reset¶
virtual void Reset() = 0
Resets the internal resampler state.
SetSampleRate¶
virtual void SetSampleRate(AmUInt32 sampleRateIn, AmUInt32 sampleRateOut) = 0
Changes the input and output sample rate.
- Parameter
sampleRateIn
- The new input sample rate.
- Parameter
sampleRateOut
- The new output sample rate.
~ResamplerInstance¶
virtual ~ResamplerInstance() = default
Default destructor.