soxr重采样实现变速

soxr重采样的使用,使用自带example里的例子soxoneshot,一维处理,实现变速。input是解码后得到的数组,output输出给解码器,使用时注意数据类型。以下是重采样的部分

float*in = malloc(totalSampleCount * sizeof(double));
for (size_t i = 0; i < totalSampleCount; i++)
{
in[i] = input[i];

}


double irate = 1;      /* Default to interpolation */
double orate = 1.1;       /* by a factor of 2. */

size_t olen = (size_t)(totalSampleCount * orate / irate + .5);   /* Assay output len. */
float* out = (float*)malloc(sizeof(float) * olen);       /* Allocate output buffer. */
size_t odone;

soxr_error_t error = soxr_oneshot(irate, orate, channels, /* Rates and # of chans. */
	in, totalSampleCount/channels, NULL,    //注意是每个通道的点数                          /* Input. */
	out, olen, &odone,                             /* Output. */
	NULL, NULL, NULL);                             /* Default configuration.*/

										/* Tidy up. */
drwav_int32*output = (drwav_int32*)malloc(odone * sizeof(drwav_int32));
for (size_t i = 0; i < odone; i++)
{
	output[i] = out[i];
	//printf("%d\n", output[i]);
}

猜你喜欢

转载自blog.csdn.net/weixin_42707943/article/details/85040414