1. Are you ready for the Galaxy S20? Here is everything we know so far!

Could not get audio input for record source 1

Discussion in 'Android Development' started by cjm32, Feb 10, 2011.

  1. cjm32

    cjm32 Lurker
    Thread Starter

    Hi

    I keep getting this error when trying to initialize and AudioRecord object, in an attempt to record sounds using the emulator using Eclipse.

    I have tried with various bit sampling rates, 8000 is the only one that is valid, but the error continues to appear. I have tried on various versions of the sdk, 1.5, 1.6, 2, 2.2 and 2.3.1. (and combinations of with the AVD).

    Here is the code:

    Code (Text):
    1.  
    2.     Log.v(TAG, "About to initialize recording");
    3.     //int[] samplingRates = {44100, 22050, 16000, 11025, 8000};
    4.     int[] samplingRates = {8000};
    5.   for (int i = 0; i < samplingRates.length; ++i)
    6.   {
    7.    try
    8.    {
    9.     Log.d(TAG,"Trying sampling rate: " + samplingRates[i]);
    10.     int min = AudioRecord.getMinBufferSize(samplingRates[i],
    11.       AudioFormat.CHANNEL_CONFIGURATION_MONO,
    12.       //AudioFormat.CHANNEL_IN_MONO,
    13.       AudioFormat.ENCODING_PCM_16BIT);
    14.     Log.d(TAG,"MinBufferSize: " + min);
    15.     AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRates[i],
    16.       AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, min);
    17.     if (record.getState() == AudioRecord.STATE_INITIALIZED)
    18.     {
    19.      Log.d("Recorder", "Audio recorder initialised at " + record.getSampleRate());
    20.      return record;
    21.     }
    22.     record.release();
    23.     record = null;
    24.    }
    25.    catch (IllegalArgumentException e)
    26.    {
    27.     // Try the next one.
    28.     Log.d(TAG,"Initialization failed");
    29.    }
    30.   }
    31.   // None worked.
    32.   return null;
    33.  
    Has anyone seen this same problem, it seems to be a straight forward request so i
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...