Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I might be able to help a tiny bit. However, I am in the same situation as you so I can only tell you about my experiences.</p> <p>I believe you can get your device's preferred sampleRate like so:</p> <pre><code>int sampleRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM); </code></pre> <p>The 16Bit encoding mode is the only one that works with AudioRecord. I am unsure why you are getting 8Bit like output (right?). Maybe someone knows.</p> <p>I am also unsure how you pull the amplitude from the retrieved bytes, did you do this?</p> <p>Finally, I believe you need to use the periodic listener functions, like so:</p> <pre><code>int sampleRate = AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_SYSTEM); int channelMode = AudioFormat.CHANNEL_IN_MONO; int encodingMode = AudioFormat.ENCODING_PCM_16BIT; int bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelMode, encodingMode); AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, channelMode, encodingMode, bufferSize); recorder.setPositionNotificationPeriod(intervalFrames); recorder.setRecordPositionUpdateListener(recordListener); recorder.startRecording(); private RecordListener recordListener = new RecordListener(); private class RecordListener implements AudioRecord.OnRecordPositionUpdateListener { public void onMarkerReached(AudioRecord recorder) { Log.v("MicInfoService", "onMarkedReached CALL"); } public void onPeriodicNotification(AudioRecord recorder) { Log.v("MicInfoService", "onPeriodicNotification CALL"); } } </code></pre> <p>There are two big questions here which I cannot answer and want to know the answer of myself as well:</p> <ol> <li>What should be set as intervalFrames?</li> <li>Why are the listener methods never called?</li> </ol> <p>I wish I could help more.</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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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