ReactOS 0.4.15-dev-7953-g1f49173
samplerate.h
Go to the documentation of this file.
1/*
2** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com>
3** All rights reserved.
4**
5** This code is released under 2-clause BSD license. Please see the
6** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING
7*/
8
9/*
10** API documentation is available here:
11** http://www.mega-nerd.com/SRC/api.html
12*/
13
14#ifndef SAMPLERATE_H
15#define SAMPLERATE_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif /* __cplusplus */
20
21
22/* Opaque data type SRC_STATE. */
23typedef struct SRC_STATE_tag SRC_STATE ;
24
25/* SRC_DATA is used to pass data to src_simple() and src_process(). */
26typedef struct
27{ const float *data_in ;
28 float *data_out ;
29
30 long input_frames, output_frames ;
31 long input_frames_used, output_frames_gen ;
32
34
35 double src_ratio ;
36} SRC_DATA ;
37
38/*
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.
45*/
46
47typedef long (*src_callback_t) (void *cb_data, float **data) ;
48
49/*
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.
53*/
54
55SRC_STATE* src_new (int converter_type, int channels, int *error) ;
56
57/*
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.
63*/
64
65SRC_STATE* src_callback_new (src_callback_t func, int converter_type, int channels,
66 int *error, void* cb_data) ;
67
68/*
69** Cleanup all internal allocations.
70** Always returns NULL.
71*/
72
74
75/*
76** Standard processing function.
77** Returns non zero on error.
78*/
79
81
82/*
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.
85*/
86long src_callback_read (SRC_STATE *state, double src_ratio, long frames, float *data) ;
87
88/*
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.
93*/
94
95int src_simple (SRC_DATA *data, int converter_type, int channels) ;
96
97/*
98** This library contains a number of different sample rate converters,
99** numbered 0 through N.
100**
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.
104*/
105
106const char *src_get_name (int converter_type) ;
107const char *src_get_description (int converter_type) ;
108const char *src_get_version (void) ;
109
110/*
111** Set a new SRC ratio. This allows step responses
112** in the conversion ratio.
113** Returns non zero on error.
114*/
115
116int src_set_ratio (SRC_STATE *state, double new_ratio) ;
117
118/*
119** Get the current channel count.
120** Returns negative on error, positive channel count otherwise
121*/
122
124
125/*
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.
130*/
131
133
134/*
135** Return TRUE if ratio is a valid conversion ratio, FALSE
136** otherwise.
137*/
138
139int src_is_valid_ratio (double ratio) ;
140
141/*
142** Return an error number.
143*/
144
146
147/*
148** Convert the error number into a string.
149*/
150const char* src_strerror (int error) ;
151
152/*
153** The following enums can be used to set the interpolator type
154** using the function src_set_converter().
155*/
156
157enum
158{
164} ;
165
166/*
167** Extra helper functions for converting from short to float and
168** back again.
169*/
170
171void src_short_to_float_array (const short *in, float *out, int len) ;
172void src_float_to_short_array (const float *in, short *out, int len) ;
173
174void src_int_to_float_array (const int *in, float *out, int len) ;
175void src_float_to_int_array (const float *in, int *out, int len) ;
176
177
178#ifdef __cplusplus
179} /* extern "C" */
180#endif /* __cplusplus */
181
182#endif /* SAMPLERATE_H */
183
static int state
Definition: maze.c:121
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum func
Definition: glext.h:6028
GLuint in
Definition: glext.h:9616
GLenum GLsizei len
Definition: glext.h:6722
#define error(str)
Definition: mkdosfs.c:1605
#define long
Definition: qsort.c:33
int This channels
Definition: rdpsnd_libao.c:37
static FILE * out
Definition: regtests2xml.c:44
int src_error(SRC_STATE *state)
Definition: samplerate.c:358
SRC_STATE * src_callback_new(src_callback_t func, int converter_type, int channels, int *error, void *cb_data)
Definition: samplerate.c:49
int src_set_ratio(SRC_STATE *state, double new_ratio)
Definition: samplerate.c:250
int src_simple(SRC_DATA *data, int converter_type, int channels)
Definition: samplerate.c:432
void src_int_to_float_array(const int *in, float *out, int len)
Definition: samplerate.c:482
int src_is_valid_ratio(double ratio)
Definition: samplerate.c:345
struct SRC_STATE_tag SRC_STATE
Definition: samplerate.h:23
const char * src_get_version(void)
Definition: samplerate.c:340
void src_float_to_short_array(const float *in, short *out, int len)
Definition: samplerate.c:460
void src_short_to_float_array(const short *in, float *out, int len)
Definition: samplerate.c:449
int src_reset(SRC_STATE *state)
Definition: samplerate.c:283
@ SRC_LINEAR
Definition: samplerate.h:163
@ SRC_SINC_BEST_QUALITY
Definition: samplerate.h:159
@ SRC_ZERO_ORDER_HOLD
Definition: samplerate.h:162
@ SRC_SINC_FASTEST
Definition: samplerate.h:161
@ SRC_SINC_MEDIUM_QUALITY
Definition: samplerate.h:160
const char * src_get_name(int converter_type)
Definition: samplerate.c:308
long src_callback_read(SRC_STATE *state, double src_ratio, long frames, float *data)
Definition: samplerate.c:153
void src_float_to_int_array(const float *in, int *out, int len)
Definition: samplerate.c:493
int src_process(SRC_STATE *state, SRC_DATA *data)
Definition: samplerate.c:89
SRC_STATE * src_delete(SRC_STATE *state)
Definition: samplerate.c:74
const char * src_strerror(int error)
Definition: samplerate.c:365
SRC_STATE * src_new(int converter_type, int channels, int *error)
Definition: samplerate.c:15
const char * src_get_description(int converter_type)
Definition: samplerate.c:324
int src_get_channels(SRC_STATE *state)
Definition: samplerate.c:269
long(* src_callback_t)(void *cb_data, float **data)
Definition: samplerate.h:47
long input_frames
Definition: samplerate.h:30
float * data_out
Definition: samplerate.h:28
double src_ratio
Definition: samplerate.h:35
long input_frames_used
Definition: samplerate.h:31
const float * data_in
Definition: samplerate.h:27
int end_of_input
Definition: samplerate.h:33