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.

147 lines
4.3KB

  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>Simple API</B></H1>
  52. <P>
  53. <B>Important Note:</B>
  54. The simple API is not designed to work on small chunks of a larger piece of
  55. audio.
  56. If you attempt to use it this way you are doing it wrong and will not get the
  57. results you want.
  58. For processing audio data in chunks you <b>must</b> use the
  59. <a href="api_full.html">full api</a>
  60. or the
  61. <a href="api_callback.html">callback based api</a>.
  62. </P>
  63. <br/><br/>
  64. <P>
  65. The simple API consists of a single function :
  66. </P>
  67. <PRE>
  68. int src_simple (SRC_DATA *data, int converter_type, int channels) ;
  69. </PRE>
  70. <P>
  71. The use of this function rather than the more fully featured API requires the caller
  72. to know the total length of the input data before hand and that all input and output
  73. data can be held in the system's memory at once.
  74. It also assumes that there is a single constant ratio between input and output sample
  75. rates.
  76. <!--
  77. If these conditions cannot be met, the full featured API should be used instead.
  78. In addition, this documentation is complemented by this
  79. <A HREF="ex_simple.html">example code</A>. -->
  80. </P>
  81. <P>
  82. Dealing with the easy stuff first, the <B>converter_type</B> parameter should be
  83. one of the values defined in <B>samplerate.h</B> and documented
  84. <A HREF="api_misc.html#Converters">here</A> while the <b>channels</b> parameter
  85. specifies the number of interleaved channels that the sample rate converter
  86. is being asked to process (number of input channels and output channels is always
  87. equal).
  88. There is no hard upper limit on the number of channels; it is limited purely
  89. by the amount of memory available.
  90. </P>
  91. <P>
  92. The first parameter to <B>src_simple</B> is a pointer to an <B>SRC_DATA</B> struct
  93. (more info <A HREF="api_misc.html#SRC_DATA">here</A>) defined as follows:
  94. </P>
  95. <PRE>
  96. typedef struct
  97. { float *data_in, *data_out ;
  98. long input_frames, output_frames ;
  99. long input_frames_used, output_frames_gen ;
  100. int end_of_input ;
  101. double src_ratio ;
  102. } SRC_DATA ;
  103. </PRE>
  104. <P>
  105. The fields of this struct which must be filled in by the caller are:
  106. </P>
  107. <PRE>
  108. data_in : A pointer to the input data samples.
  109. input_frames : The number of frames of data pointed to by data_in.
  110. data_out : A pointer to the output data samples.
  111. output_frames : Maximum number of frames pointer to by data_out.
  112. src_ratio : Equal to output_sample_rate / input_sample_rate.
  113. </PRE>
  114. <P>
  115. When the <B>src_simple</B> function returns <B>output_frames_gen</B> will be
  116. set to the number of output frames generated and <B>input_frames_used</B> will
  117. be set to the number of input frames used to generate the provided number of
  118. output frames.
  119. </P>
  120. <P>
  121. The <B>src_simple</B> function returns a non-zero value when an error occurs.
  122. See <A HREF="api_misc.html#ErrorReporting">here</A> for how to convert the error value into
  123. a text string.
  124. </P>
  125. </DIV>
  126. </TD></TR>
  127. </TABLE>
  128. </BODY>
  129. </HTML>