RzR
RzR

Reputation: 3176

How to set Audio Sampling rate higher than 44.1kHz on linux/android platform?

I noticed that android.media.AudioRecord failed to work when using wrong sampleRateInHz

REPRODUCE

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.

SOURCE CODE

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/

TRACKS

How to overcome this limitation ?

MORE

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

Upvotes: 5

Views: 7307

Answers (1)

Anthony
Anthony

Reputation: 21

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.

Upvotes: 2

Related Questions