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.

227 lines
7.7KB

  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_misc.html#ErrorReporting">Error Handling</A><BR>
  32. <A HREF="api_misc.html">Miscellaneous</A><BR>
  33. <BR>
  34. <DIV CLASS="block">
  35. Author :<BR>Erik de Castro Lopo
  36. <!-- pepper -->
  37. <BR><BR>
  38. <!-- pepper -->
  39. </DIV>
  40. <IMG SRC=
  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"
  42. HEIGHT=30 WIDTH=100 ALT="counter.gif">
  43. </DIV>
  44. </TD>
  45. <!-- pepper -->
  46. <!-- ######################################################################## -->
  47. <!-- pepper -->
  48. <TD VALIGN="top">
  49. <DIV CLASS="block">
  50. <H1><B>Miscellaneous API Documentation</B></H1>
  51. <A NAME="ErrorReporting"></A>
  52. <H3><BR>Error Reporting</H3>
  53. <P>
  54. Most of the API functions either return an integer error (ie <B>src_simple</B>
  55. and <B>src_process</B>) or return an integer error value via an int pointer
  56. parameter (<B>src_new</B>).
  57. These integer error values can be converted into a human readable text strings by
  58. calling the function:
  59. </P>
  60. <PRE>
  61. const char* src_strerror (int error) ;
  62. </PRE>
  63. <P>
  64. which will return an error string for valid error numbers, the string "No Error"
  65. for an error value of zero or a NULL pointer if no error message has been defined
  66. for that error value.
  67. </P>
  68. <A NAME="Converters"></A>
  69. <H3><BR>Converters</H3>
  70. <P>
  71. Secret Rabbit Code has a number of different converters which can be selected
  72. using the <B>converter_type</B> parameter when calling <B>src_simple</B> or
  73. <b>src_new</B>.
  74. Currently, the five converters available are:
  75. </P>
  76. <PRE>
  77. enum
  78. {
  79. SRC_SINC_BEST_QUALITY = 0,
  80. SRC_SINC_MEDIUM_QUALITY = 1,
  81. SRC_SINC_FASTEST = 2,
  82. SRC_ZERO_ORDER_HOLD = 3,
  83. SRC_LINEAR = 4
  84. } ;
  85. </PRE>
  86. <P>
  87. As new converters are added, they will given a number corresponding to the
  88. next inetger.
  89. </P>
  90. <P>
  91. The details of these converters are as follows:
  92. </P>
  93. <UL>
  94. <LI> <B>SRC_SINC_BEST_QUALITY</B> - This is a bandlimited interpolator derived
  95. from the mathematical <B>sinc</B> function and this is the highest
  96. quality sinc based converter, providing a worst case Signal-to-Noise
  97. Ratio (SNR) of 97 decibels (dB) at a bandwidth of 97&#37;.
  98. All three SRC_SINC_* converters are based on the techniques of
  99. <A HREF="http://ccrma-www.stanford.edu/~jos/resample/">Julius O. Smith</A>
  100. although this code was developed independantly.
  101. <LI> <B>SRC_SINC_MEDIUM_QUALITY</B> - This is another bandlimited interpolator
  102. much like the previous one. It has an SNR of 97dB and a bandwidth of 90&#37;.
  103. The speed of the conversion is much faster than the previous one.
  104. <LI> <B>SRC_SINC_FASTEST</B> - This is the fastest bandlimited interpolator and
  105. has an SNR of 97dB and a bandwidth of 80&#37;.
  106. <LI><B>SRC_ZERO_ORDER_HOLD</B> - A Zero Order Hold converter (interpolated value
  107. is equal to the last value). The quality is poor but the conversion speed is
  108. blindlingly fast.
  109. <li><b>SRC_LINEAR</b> - A linear converter. Again the quality is poor, but the
  110. conversion speed is blindingly fast.
  111. </UL>
  112. <P>
  113. There are two functions that give either a (text string) name or description
  114. for each converter:
  115. </P>
  116. <PRE>
  117. const char *src_get_name (int converter_type) ;
  118. const char *src_get_description (int converter_type) ;
  119. </PRE>
  120. <P>
  121. The name will typically be a short string for use in a dialog box, while the
  122. description string is longer.
  123. </P>
  124. <P>
  125. Both of these functions return a NULL pointer if there is no converter for the
  126. given <B>converter_type</B> value.
  127. Since the converters have consecutive <B>converter_type</B> values, the caller
  128. is easily able to figure out the number of converters at run time.
  129. This enables a binary dynamically linked against an old version of the library
  130. to know about converters from later versions of the library as they become
  131. available.
  132. </P>
  133. <A NAME="SRC_DATA"></A>
  134. <H3><BR>SRC_DATA</H3>
  135. <P>
  136. Both the simple and the full featured versions of the API use the <B>SRC_DATA</B>
  137. struct to pass audio and control data into the sample rate converter.
  138. This struct is defined as:
  139. </P>
  140. <PRE>
  141. typedef struct
  142. { float *data_in, *data_out ;
  143. long input_frames, output_frames ;
  144. long input_frames_used, output_frames_gen ;
  145. int end_of_input ;
  146. double src_ratio ;
  147. } SRC_DATA ;
  148. </PRE>
  149. <P>
  150. The <B>data_in</B> pointer is used to pass audio data into the converter while the
  151. <B>data_out</B> pointer supplies the converter with an array to hold the converter's
  152. output.
  153. For a converter which has been configured for mulitchannel operation, these pointers
  154. need to point to a single array of interleaved data.
  155. </P>
  156. <P>
  157. The <B>input_frames</B> and <B>output_frames</B> fields supply the converter with
  158. the lengths of the arrays (in frames) pointed to by the <B>data_in</B> and
  159. <b>data_out</B> pointers respectively.
  160. For monophinc data, these values would indicate the length of the arrays while
  161. for multi channel data these values would be equal to the the length of the array
  162. divided by the number of channels.
  163. </P>
  164. <P>
  165. The <B>end_of_input</B> field is only used when the sample rate converter is used
  166. by calling the <B>src_process</B> function.
  167. In this case it should be set to zero if more buffers are to be passed to the
  168. converter and 1 if the current buffer is the last.
  169. </P>
  170. <P>
  171. Finally, the <B>src_ratio</B> field specifies the conversion ratio defined as
  172. the input sample rate divided by the output sample rate.
  173. For a connected set of buffers, this value can be varies on each call to
  174. <B>src_process</B> resulting in a time varying sample rate conversion
  175. process.
  176. For time varying sample rate conversions, the ratio will be linearly
  177. interpolated between the <B>src_ratio</B> value of the previous call
  178. to <B>src_process</B> and the value for the current call.
  179. </P>
  180. <P>
  181. The <B>input_frames_used</B> and <B>output_frames_gen</B> fields are set by the
  182. converter to inform the caller of the number of frames consumed from the
  183. <B>data_in</B> array and the number of frames generated in the <B>data_out</B>
  184. array respectively.
  185. These values are for the current call to <B>src_process</B> only.
  186. </P>
  187. <A NAME="Aux"></A>
  188. <H3><BR>Auxillary Functions</H3>
  189. <P>
  190. There are four auxillary functions for converting arrays of float data
  191. to and from short or int data.
  192. These functions are defined as:
  193. </P>
  194. <PRE>
  195. void src_short_to_float_array (const short *in, float *out, int len) ;
  196. void src_float_to_short_array (const float *in, short *out, int len) ;
  197. void src_int_to_float_array (const int *in, float *out, int len) ;
  198. void src_float_to_int_array (const float *in, int *out, int len) ;
  199. </PRE>
  200. <P>
  201. The float data is assumed to be in the range [-1.0, 1.0] and it is
  202. automatically scaled on the conversion to and from float.
  203. On the float to short/int conversion path, any data values which would overflow
  204. the range of short/int data are clipped.
  205. </P>
  206. </DIV>
  207. </TD></TR>
  208. </TABLE>
  209. </BODY>
  210. </HTML>