annotate win64-msvc/include/samplerate.h @ 74:2f2b27544483

Rebuild win32 Opus using mingw 5 rather than 7 to avoid runtime incompatibility
author Chris Cannam
date Wed, 30 Jan 2019 10:30:56 +0000
parents d530e058a1c1
children
rev   line source
Chris@45 1 /*
Chris@45 2 ** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
Chris@45 3 ** All rights reserved.
Chris@45 4 **
Chris@45 5 ** This code is released under 2-clause BSD license. Please see the
Chris@45 6 ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
Chris@45 7 */
Chris@45 8
Chris@45 9 /*
Chris@45 10 ** API documentation is available here:
Chris@45 11 ** http://www.mega-nerd.com/SRC/api.html
Chris@45 12 */
Chris@45 13
Chris@45 14 #ifndef SAMPLERATE_H
Chris@45 15 #define SAMPLERATE_H
Chris@45 16
Chris@45 17 #ifdef __cplusplus
Chris@45 18 extern "C" {
Chris@45 19 #endif /* __cplusplus */
Chris@45 20
Chris@45 21
Chris@45 22 /* Opaque data type SRC_STATE. */
Chris@45 23 typedef struct SRC_STATE_tag SRC_STATE ;
Chris@45 24
Chris@45 25 /* SRC_DATA is used to pass data to src_simple() and src_process(). */
Chris@45 26 typedef struct
Chris@45 27 { const float *data_in ;
Chris@45 28 float *data_out ;
Chris@45 29
Chris@45 30 long input_frames, output_frames ;
Chris@45 31 long input_frames_used, output_frames_gen ;
Chris@45 32
Chris@45 33 int end_of_input ;
Chris@45 34
Chris@45 35 double src_ratio ;
Chris@45 36 } SRC_DATA ;
Chris@45 37
Chris@45 38 /*
Chris@45 39 ** User supplied callback function type for use with src_callback_new()
Chris@45 40 ** and src_callback_read(). First parameter is the same pointer that was
Chris@45 41 ** passed into src_callback_new(). Second parameter is pointer to a
Chris@45 42 ** pointer. The user supplied callback function must modify *data to
Chris@45 43 ** point to the start of the user supplied float array. The user supplied
Chris@45 44 ** function must return the number of frames that **data points to.
Chris@45 45 */
Chris@45 46
Chris@45 47 typedef long (*src_callback_t) (void *cb_data, float **data) ;
Chris@45 48
Chris@45 49 /*
Chris@45 50 ** Standard initialisation function : return an anonymous pointer to the
Chris@45 51 ** internal state of the converter. Choose a converter from the enums below.
Chris@45 52 ** Error returned in *error.
Chris@45 53 */
Chris@45 54
Chris@45 55 SRC_STATE* src_new (int converter_type, int channels, int *error) ;
Chris@45 56
Chris@45 57 /*
Chris@45 58 ** Initilisation for callback based API : return an anonymous pointer to the
Chris@45 59 ** internal state of the converter. Choose a converter from the enums below.
Chris@45 60 ** The cb_data pointer can point to any data or be set to NULL. Whatever the
Chris@45 61 ** value, when processing, user supplied function "func" gets called with
Chris@45 62 ** cb_data as first parameter.
Chris@45 63 */
Chris@45 64
Chris@45 65 SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
Chris@45 66 int *error, void* cb_data) ;
Chris@45 67
Chris@45 68 /*
Chris@45 69 ** Cleanup all internal allocations.
Chris@45 70 ** Always returns NULL.
Chris@45 71 */
Chris@45 72
Chris@45 73 SRC_STATE* src_delete (SRC_STATE *state) ;
Chris@45 74
Chris@45 75 /*
Chris@45 76 ** Standard processing function.
Chris@45 77 ** Returns non zero on error.
Chris@45 78 */
Chris@45 79
Chris@45 80 int src_process (SRC_STATE *state, SRC_DATA *data) ;
Chris@45 81
Chris@45 82 /*
Chris@45 83 ** Callback based processing function. Read up to frames worth of data from
Chris@45 84 ** the converter int *data and return frames read or -1 on error.
Chris@45 85 */
Chris@45 86 long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
Chris@45 87
Chris@45 88 /*
Chris@45 89 ** Simple interface for performing a single conversion from input buffer to
Chris@45 90 ** output buffer at a fixed conversion ratio.
Chris@45 91 ** Simple interface does not require initialisation as it can only operate on
Chris@45 92 ** a single buffer worth of audio.
Chris@45 93 */
Chris@45 94
Chris@45 95 int src_simple (SRC_DATA *data, int converter_type, int channels) ;
Chris@45 96
Chris@45 97 /*
Chris@45 98 ** This library contains a number of different sample rate converters,
Chris@45 99 ** numbered 0 through N.
Chris@45 100 **
Chris@45 101 ** Return a string giving either a name or a more full description of each
Chris@45 102 ** sample rate converter or NULL if no sample rate converter exists for
Chris@45 103 ** the given value. The converters are sequentially numbered from 0 to N.
Chris@45 104 */
Chris@45 105
Chris@45 106 const char *src_get_name (int converter_type) ;
Chris@45 107 const char *src_get_description (int converter_type) ;
Chris@45 108 const char *src_get_version (void) ;
Chris@45 109
Chris@45 110 /*
Chris@45 111 ** Set a new SRC ratio. This allows step responses
Chris@45 112 ** in the conversion ratio.
Chris@45 113 ** Returns non zero on error.
Chris@45 114 */
Chris@45 115
Chris@45 116 int src_set_ratio (SRC_STATE *state, double new_ratio) ;
Chris@45 117
Chris@45 118 /*
Chris@45 119 ** Get the current channel count.
Chris@45 120 ** Returns negative on error, positive channel count otherwise
Chris@45 121 */
Chris@45 122
Chris@45 123 int src_get_channels (SRC_STATE *state) ;
Chris@45 124
Chris@45 125 /*
Chris@45 126 ** Reset the internal SRC state.
Chris@45 127 ** Does not modify the quality settings.
Chris@45 128 ** Does not free any memory allocations.
Chris@45 129 ** Returns non zero on error.
Chris@45 130 */
Chris@45 131
Chris@45 132 int src_reset (SRC_STATE *state) ;
Chris@45 133
Chris@45 134 /*
Chris@45 135 ** Return TRUE if ratio is a valid conversion ratio, FALSE
Chris@45 136 ** otherwise.
Chris@45 137 */
Chris@45 138
Chris@45 139 int src_is_valid_ratio (double ratio) ;
Chris@45 140
Chris@45 141 /*
Chris@45 142 ** Return an error number.
Chris@45 143 */
Chris@45 144
Chris@45 145 int src_error (SRC_STATE *state) ;
Chris@45 146
Chris@45 147 /*
Chris@45 148 ** Convert the error number into a string.
Chris@45 149 */
Chris@45 150 const char* src_strerror (int error) ;
Chris@45 151
Chris@45 152 /*
Chris@45 153 ** The following enums can be used to set the interpolator type
Chris@45 154 ** using the function src_set_converter().
Chris@45 155 */
Chris@45 156
Chris@45 157 enum
Chris@45 158 {
Chris@45 159 SRC_SINC_BEST_QUALITY = 0,
Chris@45 160 SRC_SINC_MEDIUM_QUALITY = 1,
Chris@45 161 SRC_SINC_FASTEST = 2,
Chris@45 162 SRC_ZERO_ORDER_HOLD = 3,
Chris@45 163 SRC_LINEAR = 4,
Chris@45 164 } ;
Chris@45 165
Chris@45 166 /*
Chris@45 167 ** Extra helper functions for converting from short to float and
Chris@45 168 ** back again.
Chris@45 169 */
Chris@45 170
Chris@45 171 void src_short_to_float_array (const short *in, float *out, int len) ;
Chris@45 172 void src_float_to_short_array (const float *in, short *out, int len) ;
Chris@45 173
Chris@45 174 void src_int_to_float_array (const int *in, float *out, int len) ;
Chris@45 175 void src_float_to_int_array (const float *in, int *out, int len) ;
Chris@45 176
Chris@45 177
Chris@45 178 #ifdef __cplusplus
Chris@45 179 } /* extern "C" */
Chris@45 180 #endif /* __cplusplus */
Chris@45 181
Chris@45 182 #endif /* SAMPLERATE_H */
Chris@45 183