]>
iEval git - audio-libsamplerate.git/blob - libsamplerate/src/samplerate.h
ac0f2b085078bf3ab88a5d43ccc5ccd389d98076
2 ** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
3 ** All rights reserved.
5 ** This code is released under 2-clause BSD license. Please see the
6 ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
10 ** API documentation is available here:
11 ** http://www.mega-nerd.com/SRC/api.html
19 #endif /* __cplusplus */
22 /* Opaque data type SRC_STATE. */
23 typedef struct SRC_STATE_tag SRC_STATE
;
25 /* SRC_DATA is used to pass data to src_simple() and src_process(). */
27 { const float *data_in
;
30 long input_frames
, output_frames
;
31 long input_frames_used
, output_frames_gen
;
39 ** User supplied callback function type for use with src_callback_new()
40 ** and src_callback_read(). First parameter is the same pointer that was
41 ** passed into src_callback_new(). Second parameter is pointer to a
42 ** pointer. The user supplied callback function must modify *data to
43 ** point to the start of the user supplied float array. The user supplied
44 ** function must return the number of frames that **data points to.
47 typedef long (*src_callback_t
) (void *cb_data
, float **data
) ;
50 ** Standard initialisation function : return an anonymous pointer to the
51 ** internal state of the converter. Choose a converter from the enums below.
52 ** Error returned in *error.
55 SRC_STATE
* src_new (int converter_type
, int channels
, int *error
) ;
58 ** Initilisation for callback based API : return an anonymous pointer to the
59 ** internal state of the converter. Choose a converter from the enums below.
60 ** The cb_data pointer can point to any data or be set to NULL. Whatever the
61 ** value, when processing, user supplied function "func" gets called with
62 ** cb_data as first parameter.
65 SRC_STATE
* src_callback_new (src_callback_t func
, int converter_type
, int channels
,
66 int *error
, void* cb_data
) ;
69 ** Cleanup all internal allocations.
70 ** Always returns NULL.
73 SRC_STATE
* src_delete (SRC_STATE
*state
) ;
76 ** Standard processing function.
77 ** Returns non zero on error.
80 int src_process (SRC_STATE
*state
, SRC_DATA
*data
) ;
83 ** Callback based processing function. Read up to frames worth of data from
84 ** the converter int *data and return frames read or -1 on error.
86 long src_callback_read (SRC_STATE
*state
, double src_ratio
, long frames
, float *data
) ;
89 ** Simple interface for performing a single conversion from input buffer to
90 ** output buffer at a fixed conversion ratio.
91 ** Simple interface does not require initialisation as it can only operate on
92 ** a single buffer worth of audio.
95 int src_simple (SRC_DATA
*data
, int converter_type
, int channels
) ;
98 ** This library contains a number of different sample rate converters,
99 ** numbered 0 through N.
101 ** Return a string giving either a name or a more full description of each
102 ** sample rate converter or NULL if no sample rate converter exists for
103 ** the given value. The converters are sequentially numbered from 0 to N.
106 const char *src_get_name (int converter_type
) ;
107 const char *src_get_description (int converter_type
) ;
108 const char *src_get_version (void) ;
111 ** Set a new SRC ratio. This allows step responses
112 ** in the conversion ratio.
113 ** Returns non zero on error.
116 int src_set_ratio (SRC_STATE
*state
, double new_ratio
) ;
119 ** Get the current channel count.
120 ** Returns negative on error, positive channel count otherwise
123 int src_get_channels (SRC_STATE
*state
) ;
126 ** Reset the internal SRC state.
127 ** Does not modify the quality settings.
128 ** Does not free any memory allocations.
129 ** Returns non zero on error.
132 int src_reset (SRC_STATE
*state
) ;
135 ** Return TRUE if ratio is a valid conversion ratio, FALSE
139 int src_is_valid_ratio (double ratio
) ;
142 ** Return an error number.
145 int src_error (SRC_STATE
*state
) ;
148 ** Convert the error number into a string.
150 const char* src_strerror (int error
) ;
153 ** The following enums can be used to set the interpolator type
154 ** using the function src_set_converter().
159 SRC_SINC_BEST_QUALITY
= 0,
160 SRC_SINC_MEDIUM_QUALITY
= 1,
161 SRC_SINC_FASTEST
= 2,
162 SRC_ZERO_ORDER_HOLD
= 3,
167 ** Extra helper functions for converting from short to float and
171 void src_short_to_float_array (const short *in
, float *out
, int len
) ;
172 void src_float_to_short_array (const float *in
, short *out
, int len
) ;
174 void src_int_to_float_array (const int *in
, float *out
, int len
) ;
175 void src_float_to_int_array (const float *in
, int *out
, int len
) ;
180 #endif /* __cplusplus */
182 #endif /* SAMPLERATE_H */
This page took 0.057505 seconds and 5 git commands to generate.