1

I am making an android app to record the raw sound data. But after 5 min it stops.

For initializing the buffer to record audio

bufferSize = AudioRecord.getMinBufferSize(rate, channelConfig, audioFormat);
audioBuffer = new short[bufferSize/2];

To read the audio samples to the audiobuffer.

bufferReadSize = audioInput.read(audioBuffer, 0, bufferSize / 2);

Error:

FATAL EXCEPTION: Thread-3601
Process: com.iot.bcrec.soundcapture, PID: 23173
java.lang.ArrayIndexOutOfBoundsException: length=320; index=320
at com.iot.bcrec.soundcapture.SoundService$1.run(SoundService.java:84)
at java.lang.Thread.run(Thread.java:818)

I was thinking to clear my shortbuffer after 320 entries is there any possible method for that?? If you know please help....

1
  • I would like to answer my question. It all happened because of my stupid mistake, It was the first time that I was making an app using audio record, so didn't know how does it work.s After searching the developers.android it became clear what was my mistake. Actually, I was confused with the concept of the audio buffer. I was printing the Log value as 'Log.i(TAG,"audio data "+i+" is "+ audioBuffer[i])' in a while loop and incrementing 'i' after each iteration. but that was a wrong concept so whenever the 'i' reaches 321, then due to 'audioBuffer[i]' my app crashes after a certain time.
    – joseph
    Commented Sep 21, 2017 at 19:30

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.