I’m trying to develop an Audio Capture application using the AudioRecord
class from android api, setting, how audio source a
MediaRecorder.AudioSource.MIC, the aplication works, but when I try to use
the echo cancellation, setting a
MediaRecorder.AudioSource.VOICE_COMMUNICATION how source, when AudioRecorder object is
created, a IllegalArgumentException throws, but I don’t know why:
My code is:
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);
}
In my android manifest I have:
uses-permission android:name=”android.permission.RECORD_AUDIO”
Maybe it is because I’m using a Samsung galaxy tab p1000 and it run with android 2.2? Any idea?
Thanks a lot
Yes that is correct. The problem is that you are using Android 2.2. The new VOICE_COMMUNICATION got introduced in Android 3.0. When run on older versions you will get the DEFAULT source instead.