Audio-LibSampleRate

 view release on metacpan or  search on metacpan

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

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>

<A NAME="SetRatio"></A>
<H3><BR>Set Ratio</H3>
<PRE>
      int src_set_ratio (SRC_STATE *state, double new_ratio) ;
</PRE>

<p>
When using the <B>src_process</B> or <B>src_callback_process</B> APIs and 
updating the <B>src_ratio</B> field of the <B>SRC_STATE</B> struct, the library
will try to smoothly transition between the conversion ratio of the last call
and the conversion ratio of the current call.
<p/>

<P>
If the user want to bypass this smooth transition and achieve a step response in
the conversion ratio, the <B>src_set_ratio</B> function can be used to set the
starting conversion ratio of the next call to <B>src_process</B> or
<B>src_callback_process</B>.
<p/>

<P>
This function returns non-zero on error and the error return value can be
decoded into a text string using the function documented 
<A HREF="api_misc.html#ErrorReporting">here</A>.</P>

<!-- <A HREF="mailto:aldel@mega-nerd.com">For the spam bots</A> -->

</DIV>
</TD></TR>
</TABLE>

</BODY>
</HTML>



( run in 1.542 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )