annotate src/libsamplerate-0.1.9/doc/api_simple.html @ 126:4a7071416412

Current libsamplerate source
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 18 Oct 2016 13:24:45 +0100
parents
children
rev   line source
cannam@126 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
cannam@126 2 <HTML>
cannam@126 3
cannam@126 4 <HEAD>
cannam@126 5 <TITLE>
cannam@126 6 Secret Rabbit Code (aka libsamplerate)
cannam@126 7 </TITLE>
cannam@126 8 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
cannam@126 9 <META NAME="Version" CONTENT="libsamplerate-0.1.8">
cannam@126 10 <META NAME="Description" CONTENT="The Secret Rabbit Code Home Page">
cannam@126 11 <META NAME="Keywords" CONTENT="libsamplerate sound resample audio dsp Linux">
cannam@126 12 <LINK REL=StyleSheet HREF="SRC.css" TYPE="text/css" MEDIA="all">
cannam@126 13 </HEAD>
cannam@126 14
cannam@126 15 <BODY TEXT="#FFFFFF" BGCOLOR="#000000" LINK="#FB1465" VLINK="#FB1465" ALINK="#FB1465">
cannam@126 16 <!-- pepper -->
cannam@126 17 <CENTER>
cannam@126 18 <IMG SRC="SRC.png" HEIGHT=100 WIDTH=760 ALT="SRC.png">
cannam@126 19 </CENTER>
cannam@126 20 <!-- pepper -->
cannam@126 21 <BR>
cannam@126 22 <!-- pepper -->
cannam@126 23 <TABLE ALIGN="center" WIDTH="98%">
cannam@126 24 <TR>
cannam@126 25 <TD VALIGN="top">
cannam@126 26 <BR>
cannam@126 27 <DIV CLASS="nav">
cannam@126 28 <BR>
cannam@126 29 <A HREF="index.html">Home</A><BR>
cannam@126 30 <BR>
cannam@126 31 <A HREF="api_simple.html">Simple API</A><BR>
cannam@126 32 <A HREF="api_full.html">Full API</A><BR>
cannam@126 33 <A HREF="api_callback.html">Callback API</A><BR>
cannam@126 34 <A HREF="api_misc.html">Miscellaneous</A><BR>
cannam@126 35 <A HREF="api_misc.html#ErrorReporting">Error Handling</A><BR>
cannam@126 36 <BR>
cannam@126 37 <DIV CLASS="block">
cannam@126 38 Author :<BR>Erik de Castro Lopo
cannam@126 39 <!-- pepper -->
cannam@126 40 <BR><BR>
cannam@126 41 <!-- pepper -->
cannam@126 42
cannam@126 43 </DIV>
cannam@126 44 <IMG SRC=
cannam@126 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@126 46 HEIGHT=30 WIDTH=100 ALT="counter.gif">
cannam@126 47 </DIV>
cannam@126 48
cannam@126 49 </TD>
cannam@126 50 <!-- pepper -->
cannam@126 51 <!-- ######################################################################## -->
cannam@126 52 <!-- pepper -->
cannam@126 53 <TD VALIGN="top">
cannam@126 54 <DIV CLASS="block">
cannam@126 55
cannam@126 56 <H1><B>Simple API</B></H1>
cannam@126 57
cannam@126 58 <P>
cannam@126 59 <B>Important Note:</B>
cannam@126 60 The simple API is not designed to work on small chunks of a larger piece of
cannam@126 61 audio.
cannam@126 62 If you attempt to use it this way you are doing it wrong and will not get the
cannam@126 63 results you want.
cannam@126 64 For processing audio data in chunks you <b>must</b> use the
cannam@126 65 <a href="api_full.html">full api</a>
cannam@126 66 or the
cannam@126 67 <a href="api_callback.html">callback based api</a>.
cannam@126 68 </P>
cannam@126 69
cannam@126 70 <br/><br/>
cannam@126 71
cannam@126 72 <P>
cannam@126 73 The simple API consists of a single function :
cannam@126 74 </P>
cannam@126 75 <PRE>
cannam@126 76 int src_simple (SRC_DATA *data, int converter_type, int channels) ;
cannam@126 77 </PRE>
cannam@126 78 <P>
cannam@126 79 The use of this function rather than the more fully featured API requires the caller
cannam@126 80 to know the total length of the input data before hand and that all input and output
cannam@126 81 data can be held in the system's memory at once.
cannam@126 82 It also assumes that there is a single constant ratio between input and output sample
cannam@126 83 rates.
cannam@126 84 <!--
cannam@126 85 If these conditions cannot be met, the full featured API should be used instead.
cannam@126 86 In addition, this documentation is complemented by this
cannam@126 87 <A HREF="ex_simple.html">example code</A>. -->
cannam@126 88 </P>
cannam@126 89
cannam@126 90 <P>
cannam@126 91 Dealing with the easy stuff first, the <B>converter_type</B> parameter should be
cannam@126 92 one of the values defined in <B>samplerate.h</B> and documented
cannam@126 93 <A HREF="api_misc.html#Converters">here</A> while the <b>channels</b> parameter
cannam@126 94 specifies the number of interleaved channels that the sample rate converter
cannam@126 95 is being asked to process (number of input channels and output channels is always
cannam@126 96 equal).
cannam@126 97 There is no hard upper limit on the number of channels; it is limited purely
cannam@126 98 by the amount of memory available.
cannam@126 99 </P>
cannam@126 100
cannam@126 101
cannam@126 102 <P>
cannam@126 103 The first parameter to <B>src_simple</B> is a pointer to an <B>SRC_DATA</B> struct
cannam@126 104 (more info <A HREF="api_misc.html#SRC_DATA">here</A>) defined as follows:
cannam@126 105 </P>
cannam@126 106 <PRE>
cannam@126 107 typedef struct
cannam@126 108 { float *data_in, *data_out ;
cannam@126 109
cannam@126 110 long input_frames, output_frames ;
cannam@126 111 long input_frames_used, output_frames_gen ;
cannam@126 112
cannam@126 113 int end_of_input ;
cannam@126 114
cannam@126 115 double src_ratio ;
cannam@126 116 } SRC_DATA ;
cannam@126 117 </PRE>
cannam@126 118 <P>
cannam@126 119 The fields of this struct which must be filled in by the caller are:
cannam@126 120 </P>
cannam@126 121 <PRE>
cannam@126 122 data_in : A pointer to the input data samples.
cannam@126 123 input_frames : The number of frames of data pointed to by data_in.
cannam@126 124 data_out : A pointer to the output data samples.
cannam@126 125 output_frames : Maximum number of frames pointer to by data_out.
cannam@126 126 src_ratio : Equal to output_sample_rate / input_sample_rate.
cannam@126 127 </PRE>
cannam@126 128 <P>
cannam@126 129 When the <B>src_simple</B> function returns <B>output_frames_gen</B> will be
cannam@126 130 set to the number of output frames generated and <B>input_frames_used</B> will
cannam@126 131 be set to the number of input frames used to generate the provided number of
cannam@126 132 output frames.
cannam@126 133 </P>
cannam@126 134 <P>
cannam@126 135 The <B>src_simple</B> function returns a non-zero value when an error occurs.
cannam@126 136 See <A HREF="api_misc.html#ErrorReporting">here</A> for how to convert the error value into
cannam@126 137 a text string.
cannam@126 138 </P>
cannam@126 139
cannam@126 140 </DIV>
cannam@126 141 </TD></TR>
cannam@126 142 </TABLE>
cannam@126 143
cannam@126 144 </BODY>
cannam@126 145 </HTML>
cannam@126 146