Linear Resampling API
#include "src/btstack_resample.h"
Linear resampling for 16-bit audio code samples using 16 bit/16 bit fixed point math.
btstack_resample_init
void btstack_resample_init(btstack_resample_t * context, int num_channels);
Init resample context
Parameters
- num_channels
btstack_resample_set_factor
void btstack_resample_set_factor(btstack_resample_t * context, uint32_t factor);
Set resampling factor
Note: factor is used as step size over input data, smaller values result in more output samples
Parameters
- factor: as fixed point value, identity is 0x10000
btstack_resample_get_min_factor_for_output_capacity
uint32_t btstack_resample_get_min_factor_for_output_capacity(uint16_t input_frames, uint16_t output_capacity_frames);
Get minimum resampling factor to fit resampled output into output buffer
Note: Use this value as lower bound for the resampling factor, e.g. factor = btstack_max(factor, minimum_factor)
Note: This calculation includes the extra frame that can be emitted between two input blocks.
Parameters
- input_frames: number of input frames passed to btstack_resample_block
- output_capacity_frames: number of frames that fit into the output buffer
Returns
- uint32_t: minimum factor as fixed point value
btstack_resample_block
uint16_t btstack_resample_block(btstack_resample_t * context, const int16_t * input_buffer, uint32_t num_frames, int16_t * output_buffer);
Process block of input samples
Note: size of output buffer is not checked
@pre: num_frames > 0
Parameters
- input_buffer
- num_frames: number of input frames, must be greater than zero
- output_buffer
Returns
- uint16_t: number destination frames