annotate libs/aubioFullOSXUni/include/libsamplerate/samplerate.h @ 2:fa2af670b5c5 tip

SoundFileLoader might have moved
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Fri, 06 Jan 2012 00:23:26 +0000
parents bcb0d40158f4
children
rev   line source
andrew@0 1 /*
andrew@0 2 ** Copyright (C) 2002-2008 Erik de Castro Lopo <erikd@mega-nerd.com>
andrew@0 3 **
andrew@0 4 ** This program is free software; you can redistribute it and/or modify
andrew@0 5 ** it under the terms of the GNU General Public License as published by
andrew@0 6 ** the Free Software Foundation; either version 2 of the License, or
andrew@0 7 ** (at your option) any later version.
andrew@0 8 **
andrew@0 9 ** This program is distributed in the hope that it will be useful,
andrew@0 10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
andrew@0 11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
andrew@0 12 ** GNU General Public License for more details.
andrew@0 13 **
andrew@0 14 ** You should have received a copy of the GNU General Public License
andrew@0 15 ** along with this program; if not, write to the Free Software
andrew@0 16 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
andrew@0 17 */
andrew@0 18
andrew@0 19 /*
andrew@0 20 ** This code is part of Secret Rabibt Code aka libsamplerate. A commercial
andrew@0 21 ** use license for this code is available, please see:
andrew@0 22 ** http://www.mega-nerd.com/SRC/procedure.html
andrew@0 23 */
andrew@0 24
andrew@0 25 /*
andrew@0 26 ** API documentation is available here:
andrew@0 27 ** http://www.mega-nerd.com/SRC/api.html
andrew@0 28 */
andrew@0 29
andrew@0 30 #ifndef SAMPLERATE_H
andrew@0 31 #define SAMPLERATE_H
andrew@0 32
andrew@0 33 #ifdef __cplusplus
andrew@0 34 extern "C" {
andrew@0 35 #endif /* __cplusplus */
andrew@0 36
andrew@0 37
andrew@0 38 /* Opaque data type SRC_STATE. */
andrew@0 39 typedef struct SRC_STATE_tag SRC_STATE ;
andrew@0 40
andrew@0 41 /* SRC_DATA is used to pass data to src_simple() and src_process(). */
andrew@0 42 typedef struct
andrew@0 43 { float *data_in, *data_out ;
andrew@0 44
andrew@0 45 long input_frames, output_frames ;
andrew@0 46 long input_frames_used, output_frames_gen ;
andrew@0 47
andrew@0 48 int end_of_input ;
andrew@0 49
andrew@0 50 double src_ratio ;
andrew@0 51 } SRC_DATA ;
andrew@0 52
andrew@0 53 /* SRC_CB_DATA is used with callback based API. */
andrew@0 54 typedef struct
andrew@0 55 { long frames ;
andrew@0 56 float *data_in ;
andrew@0 57 } SRC_CB_DATA ;
andrew@0 58
andrew@0 59 /*
andrew@0 60 ** User supplied callback function type for use with src_callback_new()
andrew@0 61 ** and src_callback_read(). First parameter is the same pointer that was
andrew@0 62 ** passed into src_callback_new(). Second parameter is pointer to a
andrew@0 63 ** pointer. The user supplied callback function must modify *data to
andrew@0 64 ** point to the start of the user supplied float array. The user supplied
andrew@0 65 ** function must return the number of frames that **data points to.
andrew@0 66 */
andrew@0 67
andrew@0 68 typedef long (*src_callback_t) (void *cb_data, float **data) ;
andrew@0 69
andrew@0 70 /*
andrew@0 71 ** Standard initialisation function : return an anonymous pointer to the
andrew@0 72 ** internal state of the converter. Choose a converter from the enums below.
andrew@0 73 ** Error returned in *error.
andrew@0 74 */
andrew@0 75
andrew@0 76 SRC_STATE* src_new (int converter_type, int channels, int *error) ;
andrew@0 77
andrew@0 78 /*
andrew@0 79 ** Initilisation for callback based API : return an anonymous pointer to the
andrew@0 80 ** internal state of the converter. Choose a converter from the enums below.
andrew@0 81 ** The cb_data pointer can point to any data or be set to NULL. Whatever the
andrew@0 82 ** value, when processing, user supplied function "func" gets called with
andrew@0 83 ** cb_data as first parameter.
andrew@0 84 */
andrew@0 85
andrew@0 86 SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
andrew@0 87 int *error, void* cb_data) ;
andrew@0 88
andrew@0 89 /*
andrew@0 90 ** Cleanup all internal allocations.
andrew@0 91 ** Always returns NULL.
andrew@0 92 */
andrew@0 93
andrew@0 94 SRC_STATE* src_delete (SRC_STATE *state) ;
andrew@0 95
andrew@0 96 /*
andrew@0 97 ** Standard processing function.
andrew@0 98 ** Returns non zero on error.
andrew@0 99 */
andrew@0 100
andrew@0 101 int src_process (SRC_STATE *state, SRC_DATA *data) ;
andrew@0 102
andrew@0 103 /*
andrew@0 104 ** Callback based processing function. Read up to frames worth of data from
andrew@0 105 ** the converter int *data and return frames read or -1 on error.
andrew@0 106 */
andrew@0 107 long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
andrew@0 108
andrew@0 109 /*
andrew@0 110 ** Simple interface for performing a single conversion from input buffer to
andrew@0 111 ** output buffer at a fixed conversion ratio.
andrew@0 112 ** Simple interface does not require initialisation as it can only operate on
andrew@0 113 ** a single buffer worth of audio.
andrew@0 114 */
andrew@0 115
andrew@0 116 int src_simple (SRC_DATA *data, int converter_type, int channels) ;
andrew@0 117
andrew@0 118 /*
andrew@0 119 ** This library contains a number of different sample rate converters,
andrew@0 120 ** numbered 0 through N.
andrew@0 121 **
andrew@0 122 ** Return a string giving either a name or a more full description of each
andrew@0 123 ** sample rate converter or NULL if no sample rate converter exists for
andrew@0 124 ** the given value. The converters are sequentially numbered from 0 to N.
andrew@0 125 */
andrew@0 126
andrew@0 127 const char *src_get_name (int converter_type) ;
andrew@0 128 const char *src_get_description (int converter_type) ;
andrew@0 129 const char *src_get_version (void) ;
andrew@0 130
andrew@0 131 /*
andrew@0 132 ** Set a new SRC ratio. This allows step responses
andrew@0 133 ** in the conversion ratio.
andrew@0 134 ** Returns non zero on error.
andrew@0 135 */
andrew@0 136
andrew@0 137 int src_set_ratio (SRC_STATE *state, double new_ratio) ;
andrew@0 138
andrew@0 139 /*
andrew@0 140 ** Reset the internal SRC state.
andrew@0 141 ** Does not modify the quality settings.
andrew@0 142 ** Does not free any memory allocations.
andrew@0 143 ** Returns non zero on error.
andrew@0 144 */
andrew@0 145
andrew@0 146 int src_reset (SRC_STATE *state) ;
andrew@0 147
andrew@0 148 /*
andrew@0 149 ** Return TRUE if ratio is a valid conversion ratio, FALSE
andrew@0 150 ** otherwise.
andrew@0 151 */
andrew@0 152
andrew@0 153 int src_is_valid_ratio (double ratio) ;
andrew@0 154
andrew@0 155 /*
andrew@0 156 ** Return an error number.
andrew@0 157 */
andrew@0 158
andrew@0 159 int src_error (SRC_STATE *state) ;
andrew@0 160
andrew@0 161 /*
andrew@0 162 ** Convert the error number into a string.
andrew@0 163 */
andrew@0 164 const char* src_strerror (int error) ;
andrew@0 165
andrew@0 166 /*
andrew@0 167 ** The following enums can be used to set the interpolator type
andrew@0 168 ** using the function src_set_converter().
andrew@0 169 */
andrew@0 170
andrew@0 171 enum
andrew@0 172 {
andrew@0 173 SRC_SINC_BEST_QUALITY = 0,
andrew@0 174 SRC_SINC_MEDIUM_QUALITY = 1,
andrew@0 175 SRC_SINC_FASTEST = 2,
andrew@0 176 SRC_ZERO_ORDER_HOLD = 3,
andrew@0 177 SRC_LINEAR = 4,
andrew@0 178 } ;
andrew@0 179
andrew@0 180 /*
andrew@0 181 ** Extra helper functions for converting from short to float and
andrew@0 182 ** back again.
andrew@0 183 */
andrew@0 184
andrew@0 185 void src_short_to_float_array (const short *in, float *out, int len) ;
andrew@0 186 void src_float_to_short_array (const float *in, short *out, int len) ;
andrew@0 187
andrew@0 188 void src_int_to_float_array (const int *in, float *out, int len) ;
andrew@0 189 void src_float_to_int_array (const float *in, int *out, int len) ;
andrew@0 190
andrew@0 191
andrew@0 192 #ifdef __cplusplus
andrew@0 193 } /* extern "C" */
andrew@0 194 #endif /* __cplusplus */
andrew@0 195
andrew@0 196 #endif /* SAMPLERATE_H */
andrew@0 197