ScummVM API documentation
Audio::RateConverter Class Referenceabstract

#include <rate.h>

Public Member Functions

virtual int convert (AudioStream &input, st_sample_t *outBuffer, st_size_t numSamples, st_volume_t vol_l, st_volume_t vol_r)=0
 
virtual void setInputRate (st_rate_t inputRate)=0
 
virtual void setOutputRate (st_rate_t outputRate)=0
 
virtual st_rate_t getInputRate () const =0
 
virtual st_rate_t getOutputRate () const =0
 
virtual bool needsDraining () const =0
 

Detailed Description

Helper class that handles resampling an AudioStream between an input and output sample rate. Its regular use case is upsampling from the native stream rate to the one used by the sound mixer. However, the input/output rates can be manually adjusted to change playback speed and produce sound effects.

Member Function Documentation

◆ convert()

virtual int Audio::RateConverter::convert ( AudioStream input,
st_sample_t *  outBuffer,
st_size_t  numSamples,
st_volume_t  vol_l,
st_volume_t  vol_r 
)
pure virtual

Convert the provided AudioStream to the target sample rate.

Parameters
inputThe AudioStream to read data from.
outBufferThe buffer that the resampled audio will be written to. Must have size of at least numSamples.
numSamplesThe desired number of samples to be written into the buffer.
vol_lVolume for left channel.
vol_rVolume for right channel.
Returns
Number of sample pairs written into the buffer.

◆ needsDraining()

virtual bool Audio::RateConverter::needsDraining ( ) const
pure virtual

Does the internal buffer still have some leftover data?

Returns
True if we need to drain, false otherwise

The documentation for this class was generated from the following file: