I try to capture the sound from the microphone and no matter what size ( bufferSizeInBytes) buffer I set during construction AudioRecord, when I do a AudioRecord.readI always get 8192bytes of audio data (128 Miz). I would like to AudioRecord.readbe able to read 40msdata ( 2560 bytes). The only working code example I can find is Sipdroid ( RtpStreamSender.java), which I have not tried. Here is the relevant snippet of my code:
public void run()
{
running = true;
android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URG ENT_AUDIO);
try {
frameSize = AudioRecord.getMinBufferSize(samplingRate,
AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
Log.i(TAG, "trying to capture " + String.format("%d", frameSize) + " bytes");
record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRate,
AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, frameSize);
record.startRecording();
byte[] buffer = new byte[frameSize];
while (running)
{
record.read(buffer, 0, frameSize);
Log.i(TAG, "Captured " + String.format("%d", frameSize) + " bytes of audio");
}
record.stop();
record.release();
} catch (Throwable t) {
Log.e(TAG, "Failed to capture audio");
}
}
My questions / comments:
- Is this a limitation of the AudioRecord class and / or specific device?
- I do not see a method for requesting a supported sample rate (bufferSizeInBytes steps) that this device can execute. It would be nice if there was one.
- AudioRecord.OnRecordPositionUpdateListener ?
- pcm 8 . ?
- sipdroid, .
,