[android-developers] Re: SDK1.5 AudioRecord sample rate problem
> Since the current android > emulator is like a G1 type phone, and phone systems are usually > 8000hz, the hardware probably only supports that frequency. Nope. My actual G1 seems to record just fine at 11025 or 22050 hz (running The Dude's 0.8 cupcake build from xda-developers). But those sample rates are not guaranteed for every device, so the best strategy is probably aim for the quality you'd like, try/catch and eventually settle on the quality you can get out of the hardware you happen to have, whether that's a G1 at 44100 hz/16-bit or the emulator at 8000 hz or some new piece of unknown hardware that does 8-bit/11025 only. Of course, a code sample in the SDK to show best practices there would have been nice, since the exceptions thrown by AudioRecord are fairly uninformative. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
I believe this is a known limitation of the emulator. There is a feature request to allow for more sample rates, but no one is actively working on it. The source code is available if someone wants to take it on. On Apr 25, 2:36 pm, szabolcs wrote: > Dave, Yoni, > > Thank you for replying. > > > Is this on the emulator? If so, it may be a limitation of the emulator. > > Yes, I experienced the problem using the 1.5 prerelease SDK emulator. > I dont know how the G1 would behave. > > > Make sure you're using 16 bit samples.. > > I have tried pretty much ALL permutations of the different parameters, > including PCM_16BIT, with no DEFAULTS. Still, Recording works only > with a sample rate of 8000Hz. > > From now on I will assume its an issue with the pre release 1.5 > emulator that will get fixed into the final version. Dave, is it > enough that you know about this issue, or am I supposed to fill out a > bugreport somewhere? > > Best regards, > > -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
Hi, The documentation for AudioRecord specifies that the constructor may fail based on what the hardware supports. The format of the data will depend on if the hardware supports it. Since the current android emulator is like a G1 type phone, and phone systems are usually 8000hz, the hardware probably only supports that frequency. On Apr 24, 5:25 am, szabolcs wrote: > Steven, > > Thank you for your reply. > > I know AudioRecord works with a sample frequency of 8000Hz. In my > initial post I was asking why this frequency is the ONLY frequency > that works?! > > BTW, there is no exception thrown when the initialization of > AudioRecord fails. I figured you are supposed to check that yourself > by something like: > if(mRecord.getState()==AudioRecord.STATE_INITIALIZED), not a try-catch > block. > > So again: the question is, why does the initialization fail, if I > supply the constructor with AUDIO_SAMPLE_FREQ= 11025 || 22050 || > 44100? > > Thank you, > > -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
Dave, Yoni, Thank you for replying. > Is this on the emulator? If so, it may be a limitation of the emulator. Yes, I experienced the problem using the 1.5 prerelease SDK emulator. I dont know how the G1 would behave. > Make sure you're using 16 bit samples.. I have tried pretty much ALL permutations of the different parameters, including PCM_16BIT, with no DEFAULTS. Still, Recording works only with a sample rate of 8000Hz. >From now on I will assume its an issue with the pre release 1.5 emulator that will get fixed into the final version. Dave, is it enough that you know about this issue, or am I supposed to fill out a bugreport somewhere? Best regards, -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
Make sure you're using 16 bit samples. 8 bit samples seem to just not work. Don't use the default anythings - actually set it to MIC, PCM_16BIT, 11025, MONO. Then once that works you can try tweaking other options. Also, make sure your buffer is big enough - you can use AudioRecord.getMinBufferSize to set up your recorder with a value with minimal latency. The way AudioRecord fails is really gross and uninformative. Hopefully they'll fix that (and 8-bit recording) before 1.5 final... On Apr 24, 4:42 pm, Dave Sparks wrote: > Is this on the emulator? If so, it may be a limitation of the > emulator. > > On Apr 24, 3:25 am, szabolcs wrote: > > > Steven, > > > Thank you for your reply. > > > I know AudioRecord works with a sample frequency of 8000Hz. In my > > initial post I was asking why this frequency is the ONLY frequency > > that works?! > > > BTW, there is no exception thrown when the initialization of > > AudioRecord fails. I figured you are supposed to check that yourself > > by something like: > > if(mRecord.getState()==AudioRecord.STATE_INITIALIZED), not a try-catch > > block. > > > So again: the question is, why does the initialization fail, if I > > supply the constructor with AUDIO_SAMPLE_FREQ= 11025 || 22050 || > > 44100? > > > Thank you, > > > -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
Is this on the emulator? If so, it may be a limitation of the emulator. On Apr 24, 3:25 am, szabolcs wrote: > Steven, > > Thank you for your reply. > > I know AudioRecord works with a sample frequency of 8000Hz. In my > initial post I was asking why this frequency is the ONLY frequency > that works?! > > BTW, there is no exception thrown when the initialization of > AudioRecord fails. I figured you are supposed to check that yourself > by something like: > if(mRecord.getState()==AudioRecord.STATE_INITIALIZED), not a try-catch > block. > > So again: the question is, why does the initialization fail, if I > supply the constructor with AUDIO_SAMPLE_FREQ= 11025 || 22050 || > 44100? > > Thank you, > > -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
Steven, Thank you for your reply. I know AudioRecord works with a sample frequency of 8000Hz. In my initial post I was asking why this frequency is the ONLY frequency that works?! BTW, there is no exception thrown when the initialization of AudioRecord fails. I figured you are supposed to check that yourself by something like: if(mRecord.getState()==AudioRecord.STATE_INITIALIZED), not a try-catch block. So again: the question is, why does the initialization fail, if I supply the constructor with AUDIO_SAMPLE_FREQ= 11025 || 22050 || 44100? Thank you, -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 -~--~~~~--~~--~--~---
[android-developers] Re: SDK1.5 AudioRecord sample rate problem
you can try this code: private static final int AUDIO_SAMPLE_FREQ = 8000; private static final int AUDIO_BUFFER_SIZE = 20; 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 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 -~--~~~~--~~--~--~---