我正在我的 android 应用程序中从蓝牙耳机中读取音频样本。蓝牙 SCO 以 8KHz 的音频输入采样频率工作。但我需要来自蓝牙耳机的 16KHz 音频样本,所以我需要使用上采样。
我在此处和其他网站上搜索了有关 Android 上采样的信息,但没有用。如果有人知道用于上采样的预定义 Java 库,请回答我的问题。
如果您请求 16 kHz,则上采样应该会自动发生,除非您正在测试的设备对音频 HAL / audioflinger 有一些奇怪的实现。
如果您请求输入设备不支持的采样率,将会(应该)发生什么,音频 HAL 将向 audioflinger 返回错误代码并建议使用采样率。反过来,audioflinger 将尝试以支持的采样率打开输入流并在内部进行重新采样,以便应用程序以它请求的速率获取音频数据。
只要请求的采样率不大于支持的采样率的两倍,这应该可以工作,因此 8 -> 16 kHz 上采样应该可以工作。这种上采样的质量是否足够好是您必须自己判断的事情。
The easiest is to just copy each value and double the frequency. This will not improve sound quality but not make it worse either. This is similar to how you can upscale an image to higher resolution. Without filtering, it will not look worse, but not better either, as long as you upscale with a non-fractional amount.
Can you tell the difference between this image;
and this?
The second image is actually twice the resolution, but looks the same.
As long as you scale a sound (or an image) with a non fractional number, no scaling artifacts are introduced.
However, various hints if you want to smoothen the up-sampled sound:
https://ccrma.stanford.edu/~jos/resample/