Chris@0: Chris@0: Chris@0: Chris@0:
Chris@0:
Chris@0: Chris@0: Chris@0: Chris@0: |
Chris@0:
Chris@0:
Chris@0:
Chris@0:
Chris@0:
Chris@0:
Chris@0:
Chris@0: Simple APIChris@0: Chris@0:Chris@0: Important Note: Chris@0: The simple API is not designed to work on small chunks of a larger piece of Chris@0: audio. Chris@0: If you attempt to use it this way you are doing it wrong and will not get the Chris@0: results you want. Chris@0: For processing audio data in chunks you must use the Chris@0: full api Chris@0: or the Chris@0: callback based api. Chris@0: Chris@0: Chris@0:Chris@0: Chris@0: Chris@0: The simple API consists of a single function : Chris@0: Chris@0:Chris@0: int src_simple (SRC_DATA *data, int converter_type, int channels) ; Chris@0:Chris@0: Chris@0: The use of this function rather than the more fully featured API requires the caller Chris@0: to know the total length of the input data before hand and that all input and output Chris@0: data can be held in the system's memory at once. Chris@0: It also assumes that there is a single constant ratio between input and output sample Chris@0: rates. Chris@0: Chris@0: Chris@0: Chris@0:Chris@0: Dealing with the easy stuff first, the converter_type parameter should be Chris@0: one of the values defined in samplerate.h and documented Chris@0: here while the channels parameter Chris@0: specifies the number of interleaved channels that the sample rate converter Chris@0: is being asked to process (number of input channels and output channels is always Chris@0: equal). Chris@0: There is no hard upper limit on the number of channels; it is limited purely Chris@0: by the amount of memory available. Chris@0: Chris@0: Chris@0: Chris@0:Chris@0: The first parameter to src_simple is a pointer to an SRC_DATA struct Chris@0: (more info here) defined as follows: Chris@0: Chris@0:Chris@0: typedef struct Chris@0: { float *data_in, *data_out ; Chris@0: Chris@0: long input_frames, output_frames ; Chris@0: long input_frames_used, output_frames_gen ; Chris@0: Chris@0: int end_of_input ; Chris@0: Chris@0: double src_ratio ; Chris@0: } SRC_DATA ; Chris@0:Chris@0: Chris@0: The fields of this struct which must be filled in by the caller are: Chris@0: Chris@0:Chris@0: data_in : A pointer to the input data samples. Chris@0: input_frames : The number of frames of data pointed to by data_in. Chris@0: data_out : A pointer to the output data samples. Chris@0: output_frames : Maximum number of frames pointer to by data_out. Chris@0: src_ratio : Equal to output_sample_rate / input_sample_rate. Chris@0:Chris@0: Chris@0: When the src_simple function returns output_frames_gen will be Chris@0: set to the number of output frames generated and input_frames_used will Chris@0: be set to the number of input frames used to generate the provided number of Chris@0: output frames. Chris@0: Chris@0:Chris@0: The src_simple function returns a non-zero value when an error occurs. Chris@0: See here for how to convert the error value into Chris@0: a text string. Chris@0: Chris@0: Chris@0: |