上采样算法PCM [英] PCM algorithm for upsampling

查看:277
本文介绍了上采样算法PCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有8k16bit PCM音频,我想上采样它16k16bit。我必须手动完成。

I have 8k16bit pcm audio and I want to upsample it to 16k16bit. I have to do this manually.

有人告诉我,直线插补算法?我应该每两个字节之间插入?

Can someone tell me the algorithm for linear interpolation? Should I interpolate between each two bytes?

此外,当我上采样我必须做出对WAV头的变化 - 我应该怎么改

Also when I upsample i have to make changes for the wav header - what should I change?

推荐答案

正如其他人所说,线性插值不给最好的音质,但它的简单和便宜。

As others have mentioned, linear interpolation doesn't give the best sound quality, but it's simple and cheap.

对于创建的每个新的样本,只是下一个,例如平均吧。

For each new sample you create, just average it with the next one, e.g.

short[] source = ...;
short[] result = new short[source.length * 2];
for(int i = 0; i < source.length; ++i) {
  result[i * 2] = source[i];
  result[i * 2 + 1] = (source[i] + source[i + 1]) / 2;
}

您一定要寻找一个库,可以帮助您与WAV文件的工作。尽管这是一个简单的格式,你不应该这样做,你自己是否有可用code,会做你的需要。顺便说一句,你为什么要摆在首位这样做呢?也许你可以只使用SOX或类似的工具来做到这一点。

You should definitely search for a library that helps you with working with WAV files. Even though it's a simple format, you shouldn't have to do that yourself if there's code available that will do what you need. By the way, why are you doing this in the first place? Perhaps you could just use sox or a similar tool to do this.

这篇关于上采样算法PCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆