annotate win32-mingw/include/samplerate.h @ 91:9fe94270bdf5

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