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]);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值