Chris@41: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> Chris@41: <HTML> Chris@41: Chris@41: <HEAD> Chris@41: <TITLE> Chris@41: Secret Rabbit Code (aka libsamplerate) Chris@41: </TITLE> Chris@41: <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)"> Chris@41: <META NAME="Version" CONTENT="libsamplerate-0.1.8"> Chris@41: <META NAME="Description" CONTENT="The Secret Rabbit Code Home Page"> Chris@41: <META NAME="Keywords" CONTENT="libsamplerate sound resample audio dsp Linux"> Chris@41: <LINK REL=StyleSheet HREF="SRC.css" TYPE="text/css" MEDIA="all"> Chris@41: </HEAD> Chris@41: Chris@41: <BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#FB1465" VLINK="#FB1465" ALINK="#FB1465"> Chris@41: <!-- pepper --> Chris@41: <CENTER> Chris@41: <IMG SRC="SRC.png" HEIGHT=100 WIDTH=760 ALT="SRC.png"> Chris@41: </CENTER> Chris@41: <!-- pepper --> Chris@41: <BR> Chris@41: <!-- pepper --> Chris@41: <TABLE ALIGN="center" WIDTH="98%"> Chris@41: <TR> Chris@41: <TD VALIGN="top"> Chris@41: <BR> Chris@41: <DIV CLASS="nav"> Chris@41: <BR> Chris@41: <A HREF="index.html">Home</A><BR> Chris@41: <BR> Chris@41: <A HREF="api_simple.html">Simple API</A><BR> Chris@41: <A HREF="api_full.html">Full API</A><BR> Chris@41: <A HREF="api_callback.html">Callback API</A><BR> Chris@41: <A HREF="api_misc.html">Miscellaneous</A><BR> Chris@41: <A HREF="api_misc.html#ErrorReporting">Error Handling</A><BR> Chris@41: <BR> Chris@41: <DIV CLASS="block"> Chris@41: Author :<BR>Erik de Castro Lopo Chris@41: <!-- pepper --> Chris@41: <BR><BR> Chris@41: <!-- pepper --> Chris@41: Chris@41: </DIV> Chris@41: <IMG SRC= Chris@41: "/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|md=6|dd=B|st=1|sh=1|df=src_api.dat" Chris@41: HEIGHT=30 WIDTH=100 ALT="counter.gif"> Chris@41: </DIV> Chris@41: Chris@41: </TD> Chris@41: <!-- pepper --> Chris@41: <!-- ######################################################################## --> Chris@41: <!-- pepper --> Chris@41: <TD VALIGN="top"> Chris@41: <DIV CLASS="block"> Chris@41: Chris@41: <H1><B>Simple API</B></H1> Chris@41: Chris@41: <P> Chris@41: <B>Important Note:</B> Chris@41: The simple API is not designed to work on small chunks of a larger piece of Chris@41: audio. Chris@41: If you attempt to use it this way you are doing it wrong and will not get the Chris@41: results you want. Chris@41: For processing audio data in chunks you <b>must</b> use the Chris@41: <a href="api_full.html">full api</a> Chris@41: or the Chris@41: <a href="api_callback.html">callback based api</a>. Chris@41: </P> Chris@41: Chris@41: <br/><br/> Chris@41: Chris@41: <P> Chris@41: The simple API consists of a single function : Chris@41: </P> Chris@41: <PRE> Chris@41: int src_simple (SRC_DATA *data, int converter_type, int channels) ; Chris@41: </PRE> Chris@41: <P> Chris@41: The use of this function rather than the more fully featured API requires the caller Chris@41: to know the total length of the input data before hand and that all input and output Chris@41: data can be held in the system's memory at once. Chris@41: It also assumes that there is a single constant ratio between input and output sample Chris@41: rates. Chris@41: <!-- Chris@41: If these conditions cannot be met, the full featured API should be used instead. Chris@41: In addition, this documentation is complemented by this Chris@41: <A HREF="ex_simple.html">example code</A>. --> Chris@41: </P> Chris@41: Chris@41: <P> Chris@41: Dealing with the easy stuff first, the <B>converter_type</B> parameter should be Chris@41: one of the values defined in <B>samplerate.h</B> and documented Chris@41: <A HREF="api_misc.html#Converters">here</A> while the <b>channels</b> parameter Chris@41: specifies the number of interleaved channels that the sample rate converter Chris@41: is being asked to process (number of input channels and output channels is always Chris@41: equal). Chris@41: There is no hard upper limit on the number of channels; it is limited purely Chris@41: by the amount of memory available. Chris@41: </P> Chris@41: Chris@41: Chris@41: <P> Chris@41: The first parameter to <B>src_simple</B> is a pointer to an <B>SRC_DATA</B> struct Chris@41: (more info <A HREF="api_misc.html#SRC_DATA">here</A>) defined as follows: Chris@41: </P> Chris@41: <PRE> Chris@41: typedef struct Chris@41: { float *data_in, *data_out ; Chris@41: Chris@41: long input_frames, output_frames ; Chris@41: long input_frames_used, output_frames_gen ; Chris@41: Chris@41: int end_of_input ; Chris@41: Chris@41: double src_ratio ; Chris@41: } SRC_DATA ; Chris@41: </PRE> Chris@41: <P> Chris@41: The fields of this struct which must be filled in by the caller are: Chris@41: </P> Chris@41: <PRE> Chris@41: data_in : A pointer to the input data samples. Chris@41: input_frames : The number of frames of data pointed to by data_in. Chris@41: data_out : A pointer to the output data samples. Chris@41: output_frames : Maximum number of frames pointer to by data_out. Chris@41: src_ratio : Equal to output_sample_rate / input_sample_rate. Chris@41: </PRE> Chris@41: <P> Chris@41: When the <B>src_simple</B> function returns <B>output_frames_gen</B> will be Chris@41: set to the number of output frames generated and <B>input_frames_used</B> will Chris@41: be set to the number of input frames used to generate the provided number of Chris@41: output frames. Chris@41: </P> Chris@41: <P> Chris@41: The <B>src_simple</B> function returns a non-zero value when an error occurs. Chris@41: See <A HREF="api_misc.html#ErrorReporting">here</A> for how to convert the error value into Chris@41: a text string. Chris@41: </P> Chris@41: Chris@41: </DIV> Chris@41: </TD></TR> Chris@41: </TABLE> Chris@41: Chris@41: </BODY> Chris@41: </HTML> Chris@41: