Question

Is there an API in android to access the headphone hardware input? Ideally I'd like to be able to directly read the incoming voltage/current. Accessing this in either Java or the NDK would be fine. Preferably if there's a way to do this on non rooted phones.

Was it helpful?

Solution

If you need to recover a low frequency or "DC" component which is not making it through filters (do try it and verify that it is not, you never know) then here are two things you could try:

  • Use a chopper circuit which alternately connects the input normally and then inverted, or simply alternates the input with ground. In software you will then measure the difference between the two readings and apply some pre-measured calibration.

  • Use a voltage controlled oscillator to make a voltage to frequency converter and measure the frequency of the resulting audio tone in software rather than its amplitude (ie, you will use FM modulation)

For the first, if you care about the current you will need to characterize the input impedance of the phone, or more likely use an outboard op amp circuit to present whatever impedance you would like to have to the test signal, and then drive the phone's input from the low impedance op amp output, increased as desired with a resistor. Do exercise some care to determine and not exceed maximum voltage on phone's input. For the second, the impedance presented would be a function of your voltage to frequency modulator's input.

OTHER TIPS

I haven't seen one yet, but I wouldn't count on it.

An audio input goes through a band-pass filter and some automatic gain control. You can sample the audio input, but you won't be able to determine the actual voltage since the sampled value depends on the frequency of the complete signal.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top