ref: 2c7f81258fca15c2d4ac1f6700ffff7f34427cc4
dir: /doc/api_full.html/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Secret Rabbit Code (aka libsamplerate) </TITLE> <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)"> <META NAME="Version" CONTENT="libsamplerate-0.1.2"> <META NAME="Description" CONTENT="The Secret Rabbit Code Home Page"> <META NAME="Keywords" CONTENT="libsamplerate sound resample audio dsp Linux"> <LINK REL=StyleSheet HREF="SRC.css" TYPE="text/css" MEDIA="all"> </HEAD> <BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#FB1465" VLINK="#FB1465" ALINK="#FB1465"> <!-- pepper --> <CENTER> <IMG SRC="SRC.png" HEIGHT=100 WIDTH=760 ALT="SRC.png"> </CENTER> <!-- pepper --> <BR> <!-- pepper --> <TABLE ALIGN="center" WIDTH="98%"> <TR> <TD VALIGN="top"> <BR> <DIV CLASS="nav"> <BR> <A HREF="index.html">Home</A><BR> <BR> <A HREF="api_simple.html">Simple API</A><BR> <A HREF="api_full.html">Full API</A><BR> <A HREF="api_callback.html">Callback API</A><BR> <A HREF="api_misc.html">Miscellaneous</A><BR> <A HREF="api_misc.html#ErrorReporting">Error Handling</A><BR> <BR> <DIV CLASS="block"> Author :<BR>Erik de Castro Lopo <!-- pepper --> <BR><BR> <!-- pepper --> </DIV> <IMG SRC= "/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|md=6|dd=B|st=1|sh=1|df=src_api.dat" HEIGHT=30 WIDTH=100 ALT="counter.gif"> </DIV> </TD> <!-- pepper --> <!-- ######################################################################## --> <!-- pepper --> <TD VALIGN="top"> <DIV CLASS="block"> <H1><B>Full API</B></H1> <P> The full API consists of the following functions : </P> <PRE> SRC_STATE* <A HREF="#Init">src_new</A> (int converter_type, int channels, int *error) ; SRC_STATE* <A HREF="#CleanUp">src_delete</A> (SRC_STATE *state) ; int <A HREF="#Process">src_process</A> (SRC_STATE *state, SRC_DATA *data) ; int <A HREF="#Reset">src_reset</A> (SRC_STATE *state) ; int <A HREF="#SetRatio">src_set_ratio</A> (SRC_STATE *state, double new_ratio) ; </PRE> <A NAME="Init"></A> <H3><BR>Initialisation</H3> <PRE> SRC_STATE* src_new (int converter_type, int channels, int *error) ; </PRE> <P> The <B>src_new</B> function returns an anonymous pointer to a sample rate converter object, src_state. If an error occurs the function returns a NULL pointer and fills in the error value pointed to by the <B>error</B> pointer supplied by the caller. The converter must be one of the supplied converter types documented <A HREF="api_misc.html#Converters">here</A>. </P> <A NAME="CleanUp"></A> <H3><BR>Cleanup</H3> <PRE> SRC_STATE* src_delete (SRC_STATE *state) ; </PRE> <P> The <B>src_delete</B> function frees up all memory allocated for the given sample rate converter object and returns a NULL pointer. The caller is responsible for freeing any memory passed to the sample rate converter via the pointer to the <B>SRC_DATA</B> struct. </P> <A NAME="Process"></A> <H3><BR>Process</H3> <PRE> int src_process (SRC_STATE *state, SRC_DATA *data) ; </PRE> <P> The <B>src_process</B> function processes the data provided by the caller in an <B>SRC_DATA</B> struct using the sample rate converter object specified by the <B>SRC_STATE</B> pointer. When operating on streaming data, this function can be called over and over again, with each new call providing new input data and returning new output data. </P> <P> The <B>SRC_DATA</B> struct passed as the second parameter to the <B>src_process</B> function has the following fields: </P> <PRE> typedef struct { float *data_in, *data_out ; long input_frames, output_frames ; long input_frames_used, output_frames_gen ; int end_of_input ; double src_ratio ; } SRC_DATA ; </PRE> <P> The fields of this struct which must be filled in by the caller are: </P> <PRE> data_in : A pointer to the input data samples. input_frames : The number of frames of data pointed to by data_in. data_out : A pointer to the output data samples. output_frames : Maximum number of frames pointer to by data_out. src_ratio : Equal to output_sample_rate / input_sample_rate. end_of_input : Equal to 0 if more input data is available and 1 otherwise. </PRE> <P> Note that the data_in and data_out arrays may not overlap. If they do, the library will return an error code. </P> <P> When the <B>src_process</B> function returns <B>output_frames_gen</B> will be set to the number of output frames generated and <B>input_frames_used</B> will be set to the number of input frames consumed to generate the provided number of output frames. </P> <P> The <B>src_process</B> function returns non-zero if an error occurs. The non-zero error return value can be decoded into a text string using the function documented <A HREF="api_misc.html#ErrorReporting">here</A>. </P> <A NAME="Reset"></A> <H3><BR>Reset</H3> <PRE> int src_reset (SRC_STATE *state) ; </PRE> <P> The <B>src_reset</B> function resets the internal state of the sample rate converter object to the same state it had immediately after its creation using <B>src_new</B>. This should be called whenever a sample rate converter is to be used on two separate, unrelated pieces of audio. </P> <A NAME="SetRatio"></A> <H3><BR>Set Ratio</H3> <PRE> int src_set_ratio (SRC_STATE *state, double new_ratio) ; </PRE> <P> The <B>src_set_ratio</B> function allows the modification of the conversion ratio between calls to <B>src_process</B>. This allows a step response in the conversion ratio. It returns non-zero on error and the error return value can be decoded into a text string using the function documented <A HREF="api_misc.html#ErrorReporting">here</A>.</P> <!-- <A HREF="mailto:aldel@mega-nerd.com">For the spam bots</A> --> </DIV> </TD></TR> </TABLE> </BODY> </HTML> <!-- Do not edit or modify anything in this comment block. The arch-tag line is a file identity tag for the GNU Arch revision control system. arch-tag: 5474caa2-e4a4-4a6c-83c4-05a78a844ba9 -->