我目前在 Android 中使用 AudioTrack 和 AudioRecord 类。
我使用纯 PCM 数据,但我想知道其他编解码器有哪些选择?
从这个页面看来我只能使用 AMR 窄带进行编码和解码?
我目前设置音频类如下:
arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,
buffersize);
atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
AudioFormat.ENCODING_PCM_16BIT,
buffersize,
AudioTrack.MODE_STREAM);
所以我的问题是如何将编码从 PCM 更改为其他支持的编解码器之一?
当我尝试在 AudioFormat 上更改 ENCODING_PCM_16BIT 时,我只会获得默认或无效编码的选项以及 PCM 选项。
如果有人知道这里的任何帮助或任何帮助,任何指向 Android 上编码和解码音频的教程的链接都会非常感谢。
谢谢
编辑:我已将代码更改为以下内容:
arec = new AudioRecord(MediaRecorder.AudioSource.MIC,
11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
**MediaRecorder.AudioEncoder.AMR_NB**,
buffersize);
atrack = new AudioTrack(AudioManager.STREAM_VOICE_CALL,
11025,
AudioFormat.CHANNEL_CONFIGURATION_MONO,
**MediaRecorder.AudioEncoder.AMR_NB**,
buffersize,
AudioTrack.MODE_STREAM);
The code runs properly but I'm wondering does it actually encode the Audio as AMR_NB and if this is not a proper way to do it?
I was getting a buffer overflow when using raw PCM but none have appeared since using the new code with the MediaRecorder.AudioEncoder.AMR_NB used instead of the AudioFormat.PCM