ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

samplerate.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 /*
00020 ** This code is part of Secret Rabbit Code aka libsamplerate. A commercial
00021 ** use license for this code is available, please see:
00022 **      http://www.mega-nerd.com/SRC/procedure.html
00023 */
00024 
00025 /*
00026 ** API documentation is available here:
00027 **     http://www.mega-nerd.com/SRC/api.html
00028 */
00029 
00030 #ifndef SAMPLERATE_H
00031 #define SAMPLERATE_H
00032 
00033 #ifdef __cplusplus
00034 extern "C" {
00035 #endif  /* __cplusplus */
00036 
00037 
00038 /* Opaque data type SRC_STATE. */
00039 typedef struct SRC_STATE_tag SRC_STATE ;
00040 
00041 /* SRC_DATA is used to pass data to src_simple() and src_process(). */
00042 typedef struct
00043 {   float   *data_in, *data_out ;
00044 
00045     long    input_frames, output_frames ;
00046     long    input_frames_used, output_frames_gen ;
00047 
00048     int     end_of_input ;
00049 
00050     double  src_ratio ;
00051 } SRC_DATA ;
00052 
00053 /* SRC_CB_DATA is used with callback based API. */
00054 typedef struct
00055 {   long    frames ;
00056     float   *data_in ;
00057 } SRC_CB_DATA ;
00058 
00059 /*
00060 ** User supplied callback function type for use with src_callback_new()
00061 ** and src_callback_read(). First parameter is the same pointer that was
00062 ** passed into src_callback_new(). Second parameter is pointer to a
00063 ** pointer. The user supplied callback function must modify *data to
00064 ** point to the start of the user supplied float array. The user supplied
00065 ** function must return the number of frames that **data points to.
00066 */
00067 
00068 typedef long (*src_callback_t) (void *cb_data, float **data) ;
00069 
00070 /*
00071 **  Standard initialisation function : return an anonymous pointer to the
00072 **  internal state of the converter. Choose a converter from the enums below.
00073 **  Error returned in *error.
00074 */
00075 
00076 SRC_STATE* src_new (int converter_type, int channels, int *error) ;
00077 
00078 /*
00079 **  Initilisation for callback based API : return an anonymous pointer to the
00080 **  internal state of the converter. Choose a converter from the enums below.
00081 **  The cb_data pointer can point to any data or be set to NULL. Whatever the
00082 **  value, when processing, user supplied function "func" gets called with
00083 **  cb_data as first parameter.
00084 */
00085 
00086 SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
00087                 int *error, void* cb_data) ;
00088 
00089 /*
00090 **  Cleanup all internal allocations.
00091 **  Always returns NULL.
00092 */
00093 
00094 SRC_STATE* src_delete (SRC_STATE *state) ;
00095 
00096 /*
00097 **  Standard processing function.
00098 **  Returns non zero on error.
00099 */
00100 
00101 int src_process (SRC_STATE *state, SRC_DATA *data) ;
00102 
00103 /*
00104 **  Callback based processing function. Read up to frames worth of data from
00105 **  the converter int *data and return frames read or -1 on error.
00106 */
00107 long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
00108 
00109 /*
00110 **  Simple interface for performing a single conversion from input buffer to
00111 **  output buffer at a fixed conversion ratio.
00112 **  Simple interface does not require initialisation as it can only operate on
00113 **  a single buffer worth of audio.
00114 */
00115 
00116 int src_simple (SRC_DATA *data, int converter_type, int channels) ;
00117 
00118 /*
00119 ** This library contains a number of different sample rate converters,
00120 ** numbered 0 through N.
00121 **
00122 ** Return a string giving either a name or a more full description of each
00123 ** sample rate converter or NULL if no sample rate converter exists for
00124 ** the given value. The converters are sequentially numbered from 0 to N.
00125 */
00126 
00127 const char *src_get_name (int converter_type) ;
00128 const char *src_get_description (int converter_type) ;
00129 const char *src_get_version (void) ;
00130 
00131 /*
00132 **  Set a new SRC ratio. This allows step responses
00133 **  in the conversion ratio.
00134 **  Returns non zero on error.
00135 */
00136 
00137 int src_set_ratio (SRC_STATE *state, double new_ratio) ;
00138 
00139 /*
00140 **  Reset the internal SRC state.
00141 **  Does not modify the quality settings.
00142 **  Does not free any memory allocations.
00143 **  Returns non zero on error.
00144 */
00145 
00146 int src_reset (SRC_STATE *state) ;
00147 
00148 /*
00149 ** Return TRUE if ratio is a valid conversion ratio, FALSE
00150 ** otherwise.
00151 */
00152 
00153 int src_is_valid_ratio (double ratio) ;
00154 
00155 /*
00156 **  Return an error number.
00157 */
00158 
00159 int src_error (SRC_STATE *state) ;
00160 
00161 /*
00162 **  Convert the error number into a string.
00163 */
00164 const char* src_strerror (int error) ;
00165 
00166 /*
00167 ** The following enums can be used to set the interpolator type
00168 ** using the function src_set_converter().
00169 */
00170 
00171 enum
00172 {
00173     SRC_SINC_BEST_QUALITY       = 0,
00174     SRC_SINC_MEDIUM_QUALITY     = 1,
00175     SRC_SINC_FASTEST            = 2,
00176     SRC_ZERO_ORDER_HOLD         = 3,
00177     SRC_LINEAR                  = 4,
00178 } ;
00179 
00180 /*
00181 ** Extra helper functions for converting from short to float and
00182 ** back again.
00183 */
00184 
00185 void src_short_to_float_array (const short *in, float *out, int len) ;
00186 void src_float_to_short_array (const float *in, short *out, int len) ;
00187 
00188 void src_int_to_float_array (const int *in, float *out, int len) ;
00189 void src_float_to_int_array (const float *in, int *out, int len) ;
00190 
00191 
00192 #ifdef __cplusplus
00193 }       /* extern "C" */
00194 #endif  /* __cplusplus */
00195 
00196 #endif  /* SAMPLERATE_H */
00197 

Generated on Fri May 25 2012 04:32:41 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.