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