Audio-LibSampleRate

 view release on metacpan or  search on metacpan

libsamplerate/doc/api_full.html  view on Meta::CPAN

	<IMG SRC=
	"/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|md=6|dd=B|st=1|sh=1|df=src_api.dat" 
	HEIGHT=30 WIDTH=100 ALT="counter.gif">
</DIV>

</TD>
<!-- pepper -->
<!-- ######################################################################## -->
<!-- pepper -->
<TD VALIGN="top">
<DIV CLASS="block">

<H1><B>Full API</B></H1>
<P>
The full API consists of the following functions :
</P>
<PRE>
      SRC_STATE* <A HREF="#Init">src_new</A> (int converter_type, int channels, int *error) ;
      SRC_STATE* <A HREF="#CleanUp">src_delete</A> (SRC_STATE *state) ;

      int <A HREF="#Process">src_process</A> (SRC_STATE *state, SRC_DATA *data) ;
      int <A HREF="#Reset">src_reset</A> (SRC_STATE *state) ;
      int <A HREF="#SetRatio">src_set_ratio</A> (SRC_STATE *state, double new_ratio) ;
</PRE>

<A NAME="Init"></A>
<H3><BR>Initialisation</H3>
<PRE>
      SRC_STATE* src_new (int converter_type, int channels, int *error) ;
</PRE>
<P>
The <B>src_new</B> function returns an anonymous pointer to a sample rate 
converter object, src_state. 
If an error occurs the function returns a NULL pointer and fills in the
error value pointed to by the <B>error</B> pointer supplied by the caller.
The converter must be one of the supplied converter types documented
<A HREF="api_misc.html#Converters">here</A>.
</P>

<A NAME="CleanUp"></A>
<H3><BR>Cleanup</H3>
<PRE>
      SRC_STATE* src_delete (SRC_STATE *state) ;
</PRE>
<P>
The <B>src_delete</B> function frees up all memory allocated for the given sample
rate converter object and returns a NULL pointer.
The caller is responsible for freeing any memory passed to the sample rate converter
via the pointer to the <B>SRC_DATA</B> struct.
</P>

<A NAME="Process"></A>
<H3><BR>Process</H3>
<PRE>
      int src_process (SRC_STATE *state, SRC_DATA *data) ;
</PRE>
<P>
The <B>src_process</B> function processes the data provided by the caller
in an <B>SRC_DATA</B> struct using the sample rate converter object specified
by the <B>SRC_STATE</B> pointer.
When operating on streaming data, this function can be called over and over again,
with each new call providing new input data and returning new output data.
</P>

<P>
The <B>SRC_DATA</B> struct passed as the second parameter to the <B>src_process</B> 
function has the following fields:
</P>
<PRE>
      typedef struct
      {   float  *data_in, *data_out ;

          long   input_frames, output_frames ;
          long   input_frames_used, output_frames_gen ;

          int    end_of_input ;

          double src_ratio ;
      } SRC_DATA ;
</PRE>
<P>
The fields of this struct which must be filled in by the caller are:
</P>
<PRE>
      data_in       : A pointer to the input data samples.
      input_frames  : The number of frames of data pointed to by data_in.
      data_out      : A pointer to the output data samples.
      output_frames : Maximum number of frames pointer to by data_out.
      src_ratio     : Equal to output_sample_rate / input_sample_rate.
      end_of_input  : Equal to 0 if more input data is available and 1 
                      otherwise.
</PRE>
<P>
Note that the data_in and data_out arrays may not overlap. If they do, the 
library will return an error code.
</P>
<P>
When the <B>src_process</B> function returns <B>output_frames_gen</B> will be 
set to the number of output frames generated and <B>input_frames_used</B> will 
be set to the number of input frames consumed to generate the provided number of 
output frames.
</P>

<P>
The <B>src_process</B> function returns non-zero if an error occurs.
The non-zero error return value can be decoded into a text string using the function
documented <A HREF="api_misc.html#ErrorReporting">here</A>.
</P>

<A NAME="Reset"></A>
<H3><BR>Reset</H3>
<PRE>
      int src_reset (SRC_STATE *state) ;
</PRE>
<P>
The <B>src_reset</B> function resets the internal state of the sample rate 
converter object to the same state it had immediately after its creation using
<B>src_new</B>.
This should be called whenever a sample rate converter is to be used on two 
separate, unrelated pieces of audio.
</P>



( run in 0.588 second using v1.01-cache-2.11-cpan-524268b4103 )