I noticed that android.media.AudioRecord
failed to work
when using wrong sampleRateInHz
You can also reproduce easily that issue using pcmrecorder on Samsung Nexus S (by Google) :
https://market.android.com/details?id=com.kohei.android.pcmrecorder
http://ko-yasui.com/home/pcmrecorder/
So It fails to record at 48Khz while the hardware audio chip supports up to 96KHz :
http://www.wolfsonmicro.com/products/audio_hubs/WM8994/
Is this a device/firmware bug or known limitation?
Note that the android platform only ensure about 44100Hz (not even 24KHz)
http://developer.android.com/reference/android/media/AudioRecord.html
sampleRateInHz
: the sample rate expressed in Hertz. 44100Hz is currently the only rate that is guaranteed to work on all devices, but other rates such as 22050, 16000, and 11025 may work on some devices.
You'll find a sample code to reproduce those issues at :
https://github.com/rzr/rzr-android-test/blob/api-android-media/src/fr/online/rzr/test/
How to overcome this limitation ?
could any other API be used ? opensl, alsa, openal ? and how ?
could alsa driver be reconfigured from user side to be able to sample above 44100Hz ? ( .asoundrc )
Is it possible to do a such thing without reflashing/rooting/rebooting the device
else how to workaround this ? upsampling (interpolation) efficiently, using native code ?
http://www.anddev.org/multimedia-problems-f28/how-to-set-audio-sampling-rate-higher-than-44-1hz-nexuss-t54722.html
http://en.androidwiki.com/wiki/Nexus_S
The maximum sample rate supported for the nexus s is 44.1 kHz, the audio hardware is throwing an error when the Android platform requests to set the sample rate at 48 and higher. To answer your question, the limit for the sample rate is determined by the specific hardware you're running the program on. I tried your code on my nexus s and got the same result as you, but if I tried it on my old mytouch 3g the maximum sample rate would probably be 22.05 kHz. Basically you need to check what the supported range of sample rates is when you're initializing the audio configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With