annotate osx/include/samplerate.h @ 2:cc5d363db385

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