annotate src/libsamplerate-0.1.8/doc/api_simple.html @ 85:545efbb81310

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