Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audio input to android smartphone through headphone jack?

I'm trying to pass audio into an android phone through the headphone jack from an external player. I am reasonably sure it can be done for two reasons:

1) The square card reader works by sending its information through the headphone jack, so it can handle information input. https://squareup.com/reader
2) In order to get the audio from the player to the phone, I will be using a normal aux-aux cable, similar to those used connecting a music player to speakers. The fact that the audio can be passed to the speakers through a simple two ring cable. I know usually the two rings are used only for output with a third ring for input, but it seems to me this would suggest they are capable of inputting without the third ring.

My problem is there doesn't seem to be any api to deal with input through the headphone jack, and no one seems to know how the square reader works, or deals with the input. It looks like AudioRecord, http://developer.android.com/reference/android/media/AudioRecord.html, could have some potential to work, but it seems to need the size to be specified ahead of time, which is not ideal.

So if anyone could help me with any information on AudioRecord and how it works, or an alternative way of dealing with the input, I'd appreciate it. Also if someone knows for sure if I am correct in thinking the two ring cable can deal with input, that would also help a lot. Thanks.

like image 364
user1988170 Avatar asked Sep 30 '13 19:09

user1988170


People also ask

Can I use the headphone jack as an audio input?

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

Can headphone jack be used as AUX output?

The standard aux connector size is 3.5mm, while headphone jack sizes vary from 2.5mm to 6.35. You can use a headphone jack for an aux-in, but not the other way around. Auxiliary cables are essentially used for mixing consoles.

How do I use my headphone jack input and output?

Right click Volume icon in System Tray at right end of task bar, Open Sounds Settings, in dropdown menus at top make sure Headphones are selected and Connected for both Playback and Recording Default Devices.


1 Answers

SquareUp teardown by North Street Labs is a good point of reference to understand the design of the SquareUp reader. (Archived Link)

Audio Recording With a Smartphone will shed some light on the headphone rings and their configuration.

BrandonLW's GitHub source code provides the Android source code to record and decode the sound data.

HTH

like image 160
ramizmoh Avatar answered Oct 19 '22 22:10

ramizmoh