Note that there are some explanatory texts on larger screens.

plurals
  1. POAudioRecord read returns strange values
    primarykey
    data
    text
    <p>I am trying to build some kind of sound-meter to the Android platform. (i am using HTC wildfire) I use the <code>AudioRecord</code> class for that goal, however it seems that the values that are being returned from its "read" are not reasonable.</p> <p>This is how i created the AudioRecord object:</p> <pre><code>int minBufferSize = AudioRecord.getMinBufferSize(sampleRateInHz, android.media.AudioFormat.CHANNEL_IN_MONO, android.media.AudioFormat.ENCODING_PCM_16BIT); audioRecored = new AudioRecord( MediaRecorder.AudioSource.MIC, 44100, android.media.AudioFormat.CHANNEL_IN_MONO, android.media.AudioFormat.ENCODING_PCM_16BIT, minBufferSize ); </code></pre> <p>This is how i try to read data from it:</p> <pre><code> short[] audioData = new short[bufferSize]; int offset =0; int shortRead = 0; int sampleToReadPerGet = 1000;//some value in order to avoid momentaraly nosies. //start tapping into the microphone audioRecored.startRecording(); //start reading from the microphone to an internal buffer - chuck by chunk while (offset &lt; sampleToReadPerGet) { shortRead = audioRecored.read(audioData, offset ,sampleToReadPerGet - offset); offset += shortRead; } //stop tapping into the microphone audioRecored.stop(); //average the buffer int averageSoundLevel = 0; for (int i = 0 ; i &lt; sampleToReadPerGet ; i++) { averageSoundLevel += audioData[i]; } averageSoundLevel /= sampleToReadPerGet; </code></pre> <p>What are those values? are they decibels?</p> <p>Edit: The values goes from -200 to 3000. The value of shortRead is sampleToReadPerGet (1000).</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.
    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