You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
6.1KB

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