Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AudioRecord Supported Sampling Rates

I'm trying to figure out what sampling rates are supported for phones running Android 2.2 and greater. We'd like to sample at a rate lower than 44.1kHz and not have to resample.
I know that all phones support 44100Hz but was wondering if there's a table out there that shows what sampling rates are valid for specific phones. I've seen Android's documentation ( http://developer.android.com/reference/android/media/AudioRecord.html) but it doesn't help much.
Has anyone found a list of these sampling rates??

like image 262
Summit Avatar asked Nov 07 '11 22:11

Summit


People also ask

What sampling rate should I use?

What sample rate should I use? Stick with the most common sampling rates of 44.1 kHz or 48 kHz. If you're only focusing on music production, 44.1 kHz is a common format. However, if you're planning on integrating with video, 48 kHz is a better choice.

What is the best sampling rate for digital telephones?

The most common values for the sampling rate is the aforementioned 8kHz (most common for telephone communications), 44.1kHz (most common for music CDs), and 48kHz (most common for audio tracks in movies).

Is 192 sample rate good?

There's much debate whether sample rates higher than 44.1kHz, like 96kHz or even 192kHz, yield a significant sonic improvement. According to many people, higher sample rates aren't necessary. Yet others insist higher sample rates are audibly better.

What is the highest quality sample rate?

High-resolution audio (high-definition audio or HD audio) is a term for audio files with greater than 44.1 kHz sample rate or higher than 16-bit audio bit depth. It commonly refers to 96 or 192 kHz sample rates.


2 Answers

The original poster has probably long since moved on, but I'll post this in case anyone else finds this question.

Unfortunately, in my experience, each device can support different sample rates. The only sure way of knowing what sample rates a device supports is to test them individually by checking the result of AudioRecord.getMinBufferSize() is non negative (which means there was an error), and returns a valid minimum buffer size.

public void getValidSampleRates() {     for (int rate : new int[] {8000, 11025, 16000, 22050, 44100}) {  // add the rates you wish to check against         int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT, AudioFormat.ENCODING_PCM_16BIT);         if (bufferSize > 0) {             // buffer size is valid, Sample rate supported          }     } } 
like image 178
Yahma Avatar answered Sep 23 '22 03:09

Yahma


Android has AudioManager.getProperty() function to acquire minimum buffer size and get the preferred sample rate for audio record and playback. But yes of course, AudioManager.getProperty() is not available on API level < 17. Here's an example code sample on how to use this API.

// To get preferred buffer size and sampling rate.
AudioManager audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
String rate = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
String size = audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
Log.d("Buffer Size and sample rate", "Size :" + size + " & Rate: " + rate);

Though its a late answer, I thought this might be useful.

like image 34
Reaz Murshed Avatar answered Sep 23 '22 03:09

Reaz Murshed