0

I capture sound in real time to buffer and then I process these data. But sometimes I get warning: buffer overflow what cause of problem in the processing.

I created AudioRecord:

 bufferSize = ???; recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, RECORDER_SAMPLERATE, RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING, **bufferSize**); 

but there are not method for getMaximumBufferSize or semthing like that (only getMinBufferSize - but here is buffer owerflow). And I think that setting own buffer size is not good solution.

1 Answer 1

1

According to the API:

Upon creation, an AudioRecord object initializes its associated audio buffer that it will fill with the new audio data. The size of this buffer, specified during the construction, determines how long an AudioRecord can record before "over-running" data that has not been read yet. Data should be read from the audio hardware in chunks of sizes inferior to the total recording buffer size.

Your buffer should be large enough for the amount of buffered data you want to support, ie bitrate*time, and you need to make sure that you are reading from the AudioRecord consistently so that it does not fill the buffer, and that the size of the chunks that you read are smaller than the buffer size in the AudioRecorder. I like to read/write in 8k chunks but have seen other values too.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.