我想使用Oboe Library放大麦克风记录的audioData。
我这样创建AudioEngine.cpp:https://github.com/google/oboe/blob/master/samples/LiveEffect/src/main/cpp/LiveEffectEngine.cpp
这是具有audioData的类:

DataCallbackResult
AudioEngine::onAudioReady(AudioStream *oboeStream, void *audioData, int32_t numFrames) {

    /* some code */


 // add your audio processing here

    return DataCallbackResult::Continue;
}

最佳答案

在LiveEffect样本中,记录和播放流都是AudioFormat::I16,即16位整数。在此行上,您将转换为float:

auto *outputData = static_cast<float *>(audioData);

这将导致您听到的失真,因此,将其转换为int16_t并乘以一个恒定的幅度。

确保检查放大后的样本值是否不超过INT16_MAX,否则会出现环绕和失真的情况。

09-11 18:58