libresample  0.1.3
Functions
libresample.h File Reference

libresample API More...

Go to the source code of this file.

Functions

void * resample_open (int highQuality, double minFactor, double maxFactor)
 Create a resampler. More...
 
void * resample_dup (const void *handle)
 Duplicate a resampler. More...
 
int resample_get_filter_width (const void *handle)
 Get filter width for resampler. More...
 
int resample_process (void *handle, double factor, float *inBuffer, int inBufferLen, int lastFlag, int *inBufferUsed, float *outBuffer, int outBufferLen)
 Resample a chunk of audio. More...
 
void resample_close (void *handle)
 Close a resampler. More...
 

Detailed Description

libresample API

Author
Dominic Mazzoni

Function Documentation

§ resample_close()

void resample_close ( void *  handle)

Close a resampler.

Parameters
handlethe resampler to close

Use this function to release a handle to a resampler that was created using either resample_open() or resample_dup().

Returns
nothing.

§ resample_dup()

void* resample_dup ( const void *  handle)

Duplicate a resampler.

Parameters
handlethe resampler to duplicate
Returns
A new handle to a resampler, initialized with the same parameters used to create the original resampler.

§ resample_get_filter_width()

int resample_get_filter_width ( const void *  handle)

Get filter width for resampler.

Parameters
handlethe resampler
Returns
the filter width.

§ resample_open()

void* resample_open ( int  highQuality,
double  minFactor,
double  maxFactor 
)

Create a resampler.

Parameters
highQualitySet this argument to non-zero to enable higher quality resampling.
minFactorThis is the minimum resampling factor that will be used for this resampler. The resampling factor is calculated in the following way: ( from sample rate / to sample rate ).
maxFactorThis is the maximum resampling factor that will be used for this resampler.

Use this function to create a new resampler that will maintain state information about the stream of audio being resampled.

Returns
A handle to a new resampler

§ resample_process()

int resample_process ( void *  handle,
double  factor,
float *  inBuffer,
int  inBufferLen,
int  lastFlag,
int *  inBufferUsed,
float *  outBuffer,
int  outBufferLen 
)

Resample a chunk of audio.

Parameters
handlethe resampler
factorthe resampling factor. This factor should be calculated as ( from sample rate / to sample rate ). So, for converting from 8 kHz to 16 kHz, this value would be 2.0.
inBufferthe input buffer for audio to resample.
inBufferLenthe number of samples in the input buffer
lastFlagSet this argument to non-zero if the data in the input buffer is known to be the end of a stream. This would be used if you're resampling a file, for example.
inBufferUsedThis is an output parameter that indicates how many samples were consumed from the input buffer. Generally, this function is called in a loop until you know that the entire input buffer has been consumed, as it may take multiple calls to complete.
outBufferThis is the output buffer. This function will write the resampled audio into this buffer.
outBufferLenThis parameter specifies how many samples there is room for in the output buffer.

This is the main function used for resampling audio. It should be called in a loop until all of the data from the input buffer is consumed, or the output buffer has been filled.

Returns
the number of samples written to the output buffer. If the return value is equal to the value provided in the outBufferLen parameter, then the output buffer has been filled.