you can try this code: private static final int AUDIO_SAMPLE_FREQ = 8000; private static final int AUDIO_BUFFER_SIZE = 200000; private AudioRecord recorder; try { // init recorder recorder = new AudioRecord(MediaRecorder.AudioSource.MIC, AUDIO_SAMPLE_FREQ, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, AUDIO_BUFFER_SIZE); } catch (IllegalArgumentException e) { e.printStackTrace(); }
On Apr 24, 3:32 am, szabolcs <szabolcs.vr...@gmail.com> wrote: > I was trying to record sound using the MIC with the AudioRecord class: > > mRecord = new AudioRecord( > MediaRecorder.AudioSource.MIC, > SAMPLE_RATE, > AudioFormat.CHANNEL_CONFIGURATION_DEFAULT, > AudioFormat.ENCODING_DEFAULT, > BUFFERSIZE > ); > > This call results in: > > ERROR/AudioRecord(1120): Recording parameters are not supported: > sampleRate 11025, channelCount 1, format 1 > ERROR/AudioRecord-JNI(1120): Error creating AudioRecord instance: > initialization check failed. > ERROR/AudioRecord-Java(1120): [ android.media.AudioRecord ] Error code > -20 when initializing native AudioRecord object. > > whenever the SAMPLE_RATE is some value other than > AudioRecord::DEFAULT_SAMPLE_RATE (8000) declared in ./frameworks/base/ > include/media/AudioRecord.h from GIT. > The documentation says 11025/22050/44100 should be ok too. > > Am I missing something? > > Thank you for your help, > > -Szabolcs --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---