1

I have saved recorded audio raw PCM into a file rxrawpcm.pcm, after that i tried to play the pcm file but unable to play recorded PCM? I didn't hear recorded voice hearing only a buzzy sound

Configuration

AudioRecorder and AudioTrack configuration

Stream Type     :STREAM_VOICE_CALL
Sample Rate     : 8000
Audio Format    :PCM_16BIT
MODE        :MODE_STREAM
Channel Config  :CHANNEL_CONFIGURATION_MONO

Recording

byte[] buffer=new byte[1600];
int read = audioRecord.read(buffer, 0,buffer.length);
if(recordAudio){
if(out!=null){
out.write(buffer);
}

Player Side

FileInputStream fis=new FileInputStream(rxFile);
byte[] buffer=new byte[1600];

while(fis.read(buffer)!=-1){
audioPlayer.write(buffer, 0, buffer.length);
}
Sureshkumar Menon
  • 1,165
  • 7
  • 27
  • 49

1 Answers1

1

Your buffer size may be too small. You are supposed to use the getMinBufferSize method to determine the smallest buffer size that doesn't result in buffer overflows. The top voted answer in this question Android AudioRecord class - process live mic audio quickly, set up callback function demonstrates how to properly setup audio recording with an appropriate buffer size.

Community
  • 1
  • 1
Matt Esch
  • 22,661
  • 8
  • 53
  • 51
  • Actually i am able to play audio loop back. But only when it comes to playing from file it give's me trouble.i have set buffer size to 8320. – Sureshkumar Menon Mar 29 '12 at 12:55
  • It also looks like you are writing the entire read buffer, when you should be using the read count to write only the number of bytes you have read. `out.write(buffer, 0, read);` – Matt Esch Mar 29 '12 at 14:08
  • this is a simple task but i dono why i am not getting the right output – Sureshkumar Menon Mar 29 '12 at 14:40