7

I'm experimenting with Android's audio recording and playback. Is there a way to enumerate the available audio parameters on my device?

Right now, when I pass a combination of parameters that the hardware (or emulator) doesn't like, I just get an error. So I am having to "guess":

int bufferSize; int sampleRate; // does the audio hardware do 44 kHz? sampleRate = 44100; bufferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); if (bufferSize != AudioTrack.ERROR_BAD_VALUE) { // Nope, how about 22 kHz? sampleRate = 22050; } bufferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); if (bufferSize != AudioTrack.ERROR_BAD_VALUE) { ... 

Surely there's a better way!


This chart indicates that the only supported audio input sampling rate is 8 kHz? Is that correct?

1 Answer 1

5

Have you already looked at AudioTrack.getNativeOutputSampleRate(int streamType)?

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Marc - yes, I've seen that and it's one piece of the puzzle, but I'm hoping for something more comprehensive (and includes input settings too).
Bummer. Seems like looping through the possible parameters might be the only way possible currently. See bit.ly/c3BieY for another developer's work on this. I agree this is not very optimal, a getCapabilities() function would be nice to have.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.