Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio input through headphone jack in Android?

I am trying to get audio input through the headphone jack for my final year project. It would be a great help if someone can share some code on how to capture the data. I have been trying but as I am fairly new to android, I couldn't find any API for headphone jack in MediaRecorder.AudioSource... There are only these sources available: http://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html

like image 997
ns89 Avatar asked Jul 16 '14 07:07

ns89


People also ask

Can you use headphone jack as audio input?

Short answer: No. The Headphone Jack is designed as an output only.


Video Answer


1 Answers

If you choose e.g. DEFAULT or MIC from MediaRecorder.AudioSource as the input then a TRRS plug attached to your phone will automatically be used as the input instead of the internal microphone.

But you have two keep three things in mind:

1) Number of channels

The TRRS plug has two lines for left and right channel of the headphone but only one line for the external microphone (see e.g. this description of the plug). So you can only do monophonic recordings (the only smartphone exception at the moment: the Sony Z2 has a new TRRRS plug). You can build an adapter on your own (see e.g. the pictures here).

2) Level

You can't connect the line-out of e.g. a CD player directly to the input. You need to use e.g. a resistive voltage divider to reduce the output level to avoid overload.

3) Signal manipulation

Typically, there is smartphone-manufacturer-dependent fancy signal processing in the firmware like automatic gain control (AGC) and/or equalization, noise suppression, echo cancellation. You can't switch it off, so you don't get a perfect copy of your input signal.

like image 129
Hartmut Pfitzinger Avatar answered Oct 27 '22 19:10

Hartmut Pfitzinger