Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioSource value for USB microphone on Android

Tags:

android

audio

usb

An audio capture application on rooted MK809/Android 4.1.1. There is no internal mic so I am trying to use a USB one which is correctly detected as "USB Audio Device" in Settings/Sound/Sound Devices Manager/Sound Input Devices when connected.

What is this device's AudioSource value to pass into AudioRecord constructor (first argument). I tried every one in MediaRecorder.AudioSource, none worked. I am only interested in reading the capture buffer, not saving into a file.

like image 532
Industrial Control Freak Avatar asked Jan 12 '13 01:01

Industrial Control Freak


People also ask

How do I change my USB microphone settings?

Right click the sound icon on desktop > Click Open Sound settings. Under Input, You should see your input device in the dropdown menu. Select your USB Microphone from the dropdown.

How do I enable my USB microphone?

Open the computer's audio input/output and select the USB microphone to be the computer's input audio device. Open the computer's audio input/output and select the USB microphone to be the computer's out audio device if you want headphone monitoring from the mic. Unmute the microphone if it is muted.

Do USB microphones work on phone?

Most modern Android smartphones support OTG and can easily supply the smidgen of power a microphone needs. Problem solved, right? Well, it's not that simple. While you can absolutely use a USB microphone with your phone, you can't yet use it as a system-level microphone in every app.


1 Answers

Answering my own question. The following values did work: DEFAULT, MIC, CAMCORDER, probably others too as it is the only input device.

I was trying to use sample rate of 48000 (works on Windows) and AudioRecord creation failed with:

ERROR/AudioRecord(1615): Could not get audio input for record source 1 ERROR/AudioRecord-JNI(1615): Error creating AudioRecord instance: initialization check failed. ERROR/AudioRecord-Java(1615): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.

Somewhat misleading info considering that a call to getMinBufferSize() with the same set of agruments does not return an error as it is supposed to. I assumed that it was a valid sample rate for the device. Setting it to 44100 (guranteed) fixed the problem.

USB audio input devices do work on Android, Jelly Bean at least. Hope this helps someone.

like image 53
Industrial Control Freak Avatar answered Oct 07 '22 00:10

Industrial Control Freak