1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
6 Secret Rabbit Code (aka libsamplerate)
8 <META NAME=
"Author" CONTENT=
"Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
9 <META NAME=
"Version" CONTENT=
"libsamplerate-0.1.8">
10 <META NAME=
"Description" CONTENT=
"The Secret Rabbit Code Home Page">
11 <META NAME=
"Keywords" CONTENT=
"libsamplerate sound resample audio dsp Linux">
12 <LINK REL=StyleSheet
HREF=
"SRC.css" TYPE=
"text/css" MEDIA=
"all">
15 <BODY TEXT=
"#FFFFFF" BGCOLOR=
"#000000" LINK=
"#FB1465" VLINK=
"#FB1465" ALINK=
"#FB1465">
18 <IMG SRC=
"SRC.png" HEIGHT=
100 WIDTH=
760 ALT=
"SRC.png">
23 <TABLE ALIGN=
"center" WIDTH=
"98%">
29 <A HREF=
"index.html">Home
</A><BR>
31 <A HREF=
"api_simple.html">Simple API
</A><BR>
32 <A HREF=
"api_full.html">Full API
</A><BR>
33 <A HREF=
"api_callback.html">Callback API
</A><BR>
34 <A HREF=
"api_misc.html">Miscellaneous
</A><BR>
35 <A HREF=
"api_misc.html#ErrorReporting">Error Handling
</A><BR>
38 Author :
<BR>Erik de Castro Lopo
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"
46 HEIGHT=
30 WIDTH=
100 ALT=
"counter.gif">
51 <!-- ######################################################################## -->
56 <H1><B>Simple API
</B></H1>
59 <B>Important Note:
</B>
60 The simple API is not designed to work on small chunks of a larger piece of
62 If you attempt to use it this way you are doing it wrong and will not get the
64 For processing audio data in chunks you
<b>must
</b> use the
65 <a href=
"api_full.html">full api
</a>
67 <a href=
"api_callback.html">callback based api
</a>.
73 The simple API consists of a single function :
76 int src_simple (SRC_DATA *data, int converter_type, int channels) ;
79 The use of this function rather than the more fully featured API requires the caller
80 to know the total length of the input data before hand and that all input and output
81 data can be held in the system's memory at once.
82 It also assumes that there is a single constant ratio between input and output sample
85 If these conditions cannot be met, the full featured API should be used instead.
86 In addition, this documentation is complemented by this
87 <A HREF="ex_simple.html">example code</A>. -->
91 Dealing with the easy stuff first, the
<B>converter_type
</B> parameter should be
92 one of the values defined in
<B>samplerate.h
</B> and documented
93 <A HREF=
"api_misc.html#Converters">here
</A> while the
<b>channels
</b> parameter
94 specifies the number of interleaved channels that the sample rate converter
95 is being asked to process (number of input channels and output channels is always
97 There is no hard upper limit on the number of channels; it is limited purely
98 by the amount of memory available.
103 The first parameter to
<B>src_simple
</B> is a pointer to an
<B>SRC_DATA
</B> struct
104 (more info
<A HREF=
"api_misc.html#SRC_DATA">here
</A>) defined as follows:
108 { float *data_in, *data_out ;
110 long input_frames, output_frames ;
111 long input_frames_used, output_frames_gen ;
119 The fields of this struct which must be filled in by the caller are:
122 data_in : A pointer to the input data samples.
123 input_frames : The number of frames of data pointed to by data_in.
124 data_out : A pointer to the output data samples.
125 output_frames : Maximum number of frames pointer to by data_out.
126 src_ratio : Equal to output_sample_rate / input_sample_rate.
129 When the
<B>src_simple
</B> function returns
<B>output_frames_gen
</B> will be
130 set to the number of output frames generated and
<B>input_frames_used
</B> will
131 be set to the number of input frames used to generate the provided number of
135 The
<B>src_simple
</B> function returns a non-zero value when an error occurs.
136 See
<A HREF=
"api_misc.html#ErrorReporting">here
</A> for how to convert the error value into