Note that there are some explanatory texts on larger screens.

plurals
  1. POAudioRecord - how to get data in to buffer?
    primarykey
    data
    text
    <p>I' m having some issues using AudioRecord class. I want to store recorded data in a buffer, but I' m not sure what is the proper way to achieve that. I went through great number of examples, but most of them were comlicated and representing many different approaches. I' m looking for simple one or simple explanation.</p> <p>Here are my audio settings for my project:</p> <pre><code>int audioSource = AudioSource.MIC; int sampleRateInHz = 8000; int channelConfig = AudioFormat.CHANNEL_IN_MONO; int audioFormat = AudioFormat.ENCODING_PCM_16BIT; int bufferSizeInBytes = AudioRecord.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat); short[] buffer = new short[bufferSizeInBytes]; AudioRecord audioRecorder = new AudioRecord(audioSource, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes); </code></pre> <p>I' m trying to create a Recording function:</p> <pre><code>public void Recording() { audioRecorder.startRecording(); ... audioRecorder.stop(); audioRecorder.release(); } </code></pre> <p>I know that I' m supposed to use .read(short[] audioData, int offsetInShorts, int sizeInShorts) function. And here my problems start. I' m not sure how audioData buffer works - I assume function puts recorded samples into the audioData. What happens if it completely filled with data? It starts rewriting from the earliest position? If it does I believe I have to copy all collected samples somwhere else. It raises another question - how can I check if .read(...) function buffer is already full? Do I need to measure time and copy buffer content or there is another way to reach that? Also do I need to create a thread for whole recording operation?</p> <p>Sorry for asking so many questions in one topic :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload