annotate win32-mingw/include/samplerate.h @ 33:879bdc878826

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