annotate src/libsamplerate-0.1.8/doc/api_full.html @ 85:545efbb81310

Import initial set of sources
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 18 Mar 2013 14:12:14 +0000
parents
children
rev   line source
cannam@85 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
cannam@85 2 <HTML>
cannam@85 3
cannam@85 4 <HEAD>
cannam@85 5 <TITLE>
cannam@85 6 Secret Rabbit Code (aka libsamplerate)
cannam@85 7 </TITLE>
cannam@85 8 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
cannam@85 9 <META NAME="Version" CONTENT="libsamplerate-0.1.8">
cannam@85 10 <META NAME="Description" CONTENT="The Secret Rabbit Code Home Page">
cannam@85 11 <META NAME="Keywords" CONTENT="libsamplerate sound resample audio dsp Linux">
cannam@85 12 <LINK REL=StyleSheet HREF="SRC.css" TYPE="text/css" MEDIA="all">
cannam@85 13 </HEAD>
cannam@85 14
cannam@85 15 <BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#FB1465" VLINK="#FB1465" ALINK="#FB1465">
cannam@85 16 <!-- pepper -->
cannam@85 17 <CENTER>
cannam@85 18 <IMG SRC="SRC.png" HEIGHT=100 WIDTH=760 ALT="SRC.png">
cannam@85 19 </CENTER>
cannam@85 20 <!-- pepper -->
cannam@85 21 <BR>
cannam@85 22 <!-- pepper -->
cannam@85 23 <TABLE ALIGN="center" WIDTH="98%">
cannam@85 24 <TR>
cannam@85 25 <TD VALIGN="top">
cannam@85 26 <BR>
cannam@85 27 <DIV CLASS="nav">
cannam@85 28 <BR>
cannam@85 29 <A HREF="index.html">Home</A><BR>
cannam@85 30 <BR>
cannam@85 31 <A HREF="api_simple.html">Simple API</A><BR>
cannam@85 32 <A HREF="api_full.html">Full API</A><BR>
cannam@85 33 <A HREF="api_callback.html">Callback API</A><BR>
cannam@85 34 <A HREF="api_misc.html">Miscellaneous</A><BR>
cannam@85 35 <A HREF="api_misc.html#ErrorReporting">Error Handling</A><BR>
cannam@85 36 <BR>
cannam@85 37 <DIV CLASS="block">
cannam@85 38 Author :<BR>Erik de Castro Lopo
cannam@85 39 <!-- pepper -->
cannam@85 40 <BR><BR>
cannam@85 41 <!-- pepper -->
cannam@85 42
cannam@85 43 </DIV>
cannam@85 44 <IMG SRC=
cannam@85 45 "/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|md=6|dd=B|st=1|sh=1|df=src_api.dat"
cannam@85 46 HEIGHT=30 WIDTH=100 ALT="counter.gif">
cannam@85 47 </DIV>
cannam@85 48
cannam@85 49 </TD>
cannam@85 50 <!-- pepper -->
cannam@85 51 <!-- ######################################################################## -->
cannam@85 52 <!-- pepper -->
cannam@85 53 <TD VALIGN="top">
cannam@85 54 <DIV CLASS="block">
cannam@85 55
cannam@85 56 <H1><B>Full API</B></H1>
cannam@85 57 <P>
cannam@85 58 The full API consists of the following functions :
cannam@85 59 </P>
cannam@85 60 <PRE>
cannam@85 61 SRC_STATE* <A HREF="#Init">src_new</A> (int converter_type, int channels, int *error) ;
cannam@85 62 SRC_STATE* <A HREF="#CleanUp">src_delete</A> (SRC_STATE *state) ;
cannam@85 63
cannam@85 64 int <A HREF="#Process">src_process</A> (SRC_STATE *state, SRC_DATA *data) ;
cannam@85 65 int <A HREF="#Reset">src_reset</A> (SRC_STATE *state) ;
cannam@85 66 int <A HREF="#SetRatio">src_set_ratio</A> (SRC_STATE *state, double new_ratio) ;
cannam@85 67 </PRE>
cannam@85 68
cannam@85 69 <A NAME="Init"></A>
cannam@85 70 <H3><BR>Initialisation</H3>
cannam@85 71 <PRE>
cannam@85 72 SRC_STATE* src_new (int converter_type, int channels, int *error) ;
cannam@85 73 </PRE>
cannam@85 74 <P>
cannam@85 75 The <B>src_new</B> function returns an anonymous pointer to a sample rate
cannam@85 76 converter object, src_state.
cannam@85 77 If an error occurs the function returns a NULL pointer and fills in the
cannam@85 78 error value pointed to by the <B>error</B> pointer supplied by the caller.
cannam@85 79 The converter must be one of the supplied converter types documented
cannam@85 80 <A HREF="api_misc.html#Converters">here</A>.
cannam@85 81 </P>
cannam@85 82
cannam@85 83 <A NAME="CleanUp"></A>
cannam@85 84 <H3><BR>Cleanup</H3>
cannam@85 85 <PRE>
cannam@85 86 SRC_STATE* src_delete (SRC_STATE *state) ;
cannam@85 87 </PRE>
cannam@85 88 <P>
cannam@85 89 The <B>src_delete</B> function frees up all memory allocated for the given sample
cannam@85 90 rate converter object and returns a NULL pointer.
cannam@85 91 The caller is responsible for freeing any memory passed to the sample rate converter
cannam@85 92 via the pointer to the <B>SRC_DATA</B> struct.
cannam@85 93 </P>
cannam@85 94
cannam@85 95 <A NAME="Process"></A>
cannam@85 96 <H3><BR>Process</H3>
cannam@85 97 <PRE>
cannam@85 98 int src_process (SRC_STATE *state, SRC_DATA *data) ;
cannam@85 99 </PRE>
cannam@85 100 <P>
cannam@85 101 The <B>src_process</B> function processes the data provided by the caller
cannam@85 102 in an <B>SRC_DATA</B> struct using the sample rate converter object specified
cannam@85 103 by the <B>SRC_STATE</B> pointer.
cannam@85 104 When operating on streaming data, this function can be called over and over again,
cannam@85 105 with each new call providing new input data and returning new output data.
cannam@85 106 </P>
cannam@85 107
cannam@85 108 <P>
cannam@85 109 The <B>SRC_DATA</B> struct passed as the second parameter to the <B>src_process</B>
cannam@85 110 function has the following fields:
cannam@85 111 </P>
cannam@85 112 <PRE>
cannam@85 113 typedef struct
cannam@85 114 { float *data_in, *data_out ;
cannam@85 115
cannam@85 116 long input_frames, output_frames ;
cannam@85 117 long input_frames_used, output_frames_gen ;
cannam@85 118
cannam@85 119 int end_of_input ;
cannam@85 120
cannam@85 121 double src_ratio ;
cannam@85 122 } SRC_DATA ;
cannam@85 123 </PRE>
cannam@85 124 <P>
cannam@85 125 The fields of this struct which must be filled in by the caller are:
cannam@85 126 </P>
cannam@85 127 <PRE>
cannam@85 128 data_in : A pointer to the input data samples.
cannam@85 129 input_frames : The number of frames of data pointed to by data_in.
cannam@85 130 data_out : A pointer to the output data samples.
cannam@85 131 output_frames : Maximum number of frames pointer to by data_out.
cannam@85 132 src_ratio : Equal to output_sample_rate / input_sample_rate.
cannam@85 133 end_of_input : Equal to 0 if more input data is available and 1
cannam@85 134 otherwise.
cannam@85 135 </PRE>
cannam@85 136 <P>
cannam@85 137 Note that the data_in and data_out arrays may not overlap. If they do, the
cannam@85 138 library will return an error code.
cannam@85 139 </P>
cannam@85 140 <P>
cannam@85 141 When the <B>src_process</B> function returns <B>output_frames_gen</B> will be
cannam@85 142 set to the number of output frames generated and <B>input_frames_used</B> will
cannam@85 143 be set to the number of input frames consumed to generate the provided number of
cannam@85 144 output frames.
cannam@85 145 </P>
cannam@85 146
cannam@85 147 <P>
cannam@85 148 The <B>src_process</B> function returns non-zero if an error occurs.
cannam@85 149 The non-zero error return value can be decoded into a text string using the function
cannam@85 150 documented <A HREF="api_misc.html#ErrorReporting">here</A>.
cannam@85 151 </P>
cannam@85 152
cannam@85 153 <A NAME="Reset"></A>
cannam@85 154 <H3><BR>Reset</H3>
cannam@85 155 <PRE>
cannam@85 156 int src_reset (SRC_STATE *state) ;
cannam@85 157 </PRE>
cannam@85 158 <P>
cannam@85 159 The <B>src_reset</B> function resets the internal state of the sample rate
cannam@85 160 converter object to the same state it had immediately after its creation using
cannam@85 161 <B>src_new</B>.
cannam@85 162 This should be called whenever a sample rate converter is to be used on two
cannam@85 163 separate, unrelated pieces of audio.
cannam@85 164 </P>
cannam@85 165
cannam@85 166 <A NAME="SetRatio"></A>
cannam@85 167 <H3><BR>Set Ratio</H3>
cannam@85 168 <PRE>
cannam@85 169 int src_set_ratio (SRC_STATE *state, double new_ratio) ;
cannam@85 170 </PRE>
cannam@85 171
cannam@85 172 <p>
cannam@85 173 When using the <B>src_process</B> or <B>src_callback_process</B> APIs and
cannam@85 174 updating the <B>src_ratio</B> field of the <B>SRC_STATE</B> struct, the library
cannam@85 175 will try to smoothly transition between the conversion ratio of the last call
cannam@85 176 and the conversion ratio of the current call.
cannam@85 177 <p/>
cannam@85 178
cannam@85 179 <P>
cannam@85 180 If the user want to bypass this smooth transition and achieve a step response in
cannam@85 181 the conversion ratio, the <B>src_set_ratio</B> function can be used to set the
cannam@85 182 starting conversion ratio of the next call to <B>src_process</B> or
cannam@85 183 <B>src_callback_process</B>.
cannam@85 184 <p/>
cannam@85 185
cannam@85 186 <P>
cannam@85 187 This function returns non-zero on error and the error return value can be
cannam@85 188 decoded into a text string using the function documented
cannam@85 189 <A HREF="api_misc.html#ErrorReporting">here</A>.</P>
cannam@85 190
cannam@85 191 <!-- <A HREF="mailto:aldel@mega-nerd.com">For the spam bots</A> -->
cannam@85 192
cannam@85 193 </DIV>
cannam@85 194 </TD></TR>
cannam@85 195 </TABLE>
cannam@85 196
cannam@85 197 </BODY>
cannam@85 198 </HTML>
cannam@85 199