|
|
|
/*
|
|
|
|
** Copyright (C) 2002,2003 Erik de Castro Lopo <erikd@mega-nerd.com>
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
** API documentation is available here:
|
|
|
|
** http://www.mega-nerd.com/SRC/api.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SAMPLERATE_H
|
|
|
|
#define SAMPLERATE_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
typedef struct SRC_STATE_tag SRC_STATE ;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ float *data_in, *data_out ;
|
|
|
|
|
|
|
|
long input_frames, output_frames ;
|
|
|
|
long input_frames_used, output_frames_gen ;
|
|
|
|
|
|
|
|
int end_of_input ;
|
|
|
|
|
|
|
|
double src_ratio ;
|
|
|
|
} SRC_DATA ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Simple interface for performing a single conversion from input buffer to
|
|
|
|
** output buffer at a fixed conversion ratio.
|
|
|
|
*/
|
|
|
|
int src_simple (SRC_DATA *data, int converter_type, int channels) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Initialisation function : return an anonymous pointer to the internal state
|
|
|
|
** of the converter. Choose a converter from the enums below.
|
|
|
|
*/
|
|
|
|
|
|
|
|
SRC_STATE* src_new (int converter_type, int channels, int *error) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Cleanup all internal allocations.
|
|
|
|
** Always returns NULL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
SRC_STATE* src_delete (SRC_STATE *state) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** This library contains a number of different sample rate converters,
|
|
|
|
** numbered 0 through N.
|
|
|
|
**
|
|
|
|
** Return a string giving either a name or a more full description of each
|
|
|
|
** sample rate converter or NULL if no sample rate converter exists for
|
|
|
|
** the given value. The converters are sequentially numbered from 0 to N.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const char *src_get_name (int converter_type) ;
|
|
|
|
const char *src_get_description (int converter_type) ;
|
|
|
|
const char *src_get_version (void) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Processing function.
|
|
|
|
** Returns non zero on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int src_process (SRC_STATE *state, SRC_DATA *data) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Set a new SRC ratio. This allows step responses
|
|
|
|
** in the conversion ratio.
|
|
|
|
** Returns non zero on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int src_set_ratio (SRC_STATE *state, double new_ratio) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Reset the internal SRC state.
|
|
|
|
** Does not modify the quality settings.
|
|
|
|
** Does not free any memory allocations.
|
|
|
|
** Returns non zero on error.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int src_reset (SRC_STATE *state) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Return TRUE if ratio is a valid conversion ratio, FALSE
|
|
|
|
** otherwise.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int src_is_valid_ratio (double ratio) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Return an error number.
|
|
|
|
*/
|
|
|
|
|
|
|
|
int src_error (SRC_STATE *state) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Convert the error number into a string.
|
|
|
|
*/
|
|
|
|
const char* src_strerror (int error) ;
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The following enums can be used to set the interpolator type
|
|
|
|
** using the function src_set_converter().
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SRC_SINC_BEST_TQUALITY = 0,
|
|
|
|
SRC_SINC_MEDIUM_TQUALITY = 1,
|
|
|
|
SRC_SINC_FASTEST = 2,
|
|
|
|
SRC_ZERO_ORDER_HOLD = 3,
|
|
|
|
SRC_LINEAR = 4
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* SAMPLERATE_H */
|