我正在尝试使用来自android api的AudioRecord类开发音频捕获应用程序,设置音频源MediaRecorder.AudioSource.MIC,应用程序如何工作,但是当我尝试使用回声消除时,设置MediaRecorder.AudioSource。 VOICE_COMMUNICATION 如何来源,当创建 AudioRecorder 对象时,抛出 IllegalArgumentException,但我不知道为什么:
我的代码是:
private static final int SAMPLE_RATE = 16000;
private static final int BIT_ENCODING = AudioFormat.ENCODING_PCM_16BIT;
private static final int CHANNEL_CONFIGURATION = AudioFormat.CHANNEL_CONFIGURATION_MONO;
private int m_i32BufferSize;
private AudioRecord m_AudioRecorder;
public caudioCapture ()
{
super ();
m_i32BufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, CHANNEL_CONFIGURATION, BIT_ENCODING);
//Create audio recorder object
try
{
m_AudioRecorder = new AudioRecord (MediaRecorder.AudioSource.VOICE_COMMUNICATION,SAMPLE_RATE,CHANNEL_CONFIGURATION,BIT_ENCODING,m_i32BufferSize);
}
catch (IllegalArgumentException e)
{
throw new IllegalArgumentException("Bad arguments on AudioRecorder creation", e);
}
在我的 android 清单中,我有:
使用权限 android:name="android.permission.RECORD_AUDIO"
也许是因为我使用的是三星 Galaxy Tab p1000,它运行的是 android 2.2?任何的想法?
非常感谢