问题描述
我正在尝试将 Oboe Resampler 集成到我的 android 应用程序中。
https://github.com/google/oboe/tree/master/src/flowgraph/resampler
想法是将 32000 采样率的音频的 ByteBuffer 转换为 44100 采样率的音频。
我应该如何构建 C++ 库以及我应该如何在我的 android 应用程序中集成和重新采样?有人可以分享一些片段或链接到这个 C++ 库的已经构建的版本吗?
解决方法
您不需要构建重采样器来执行此操作,因为它已经在双簧管中了。您只需打开采样率为 32000 帧/秒的双簧管音频流并开启重采样即可。
方法如下:
// Create a stream builder
oboe::AudioStreamBuilder builder;
// Specify the rate at which you'll be supplying audio frames
builder.setSampleRate(32000);
// Switch on the resampler by specifying the resampling quality - this is a tradeoff between CPU and quality.
builder.setSampleRateConversionQuality(SampleRateConversionQuality::Medium);
请参阅 the docs 以设置数据回调,您可以在其中将 ByteBuffer
写入音频流缓冲区。