Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect input data through the audio jack?

I know that some devices headphone ports (maybe all of them? any reference here would be good) have 3 channels, for stereo sound and microphone. So I was wondering if it's possible to detect something like this pedal on these devices.

If it's possible, using the audio recorder would be enough? I'm studying possibilities for an app here, and this sounds promising if possible.

Thanks

EDIT

I was searching more about it and I was wondering if the pedal would have the same effect as those headsets with buttons. It's deadly easy to override their effects, I created a simple app that does it and now I'm waiting for my pedal to try. Any thoughts about it ?

UPDATE

I just tried it in the pedal and it doesn't work. Although we managed to use the pedal to pause a music app. The device was running Cyanogen though. The voice recorder also didn't detect anything on the key press. Need suggestions on how to detect it :).

UPDATE

AS the bounty is about to expire, a minor update. The last link provided by @Nick.T got some helpful info but I'm still not able to create a sample to detect the pedal. So I made a small change on the title question, and any guidance on that direction would be very much appreciated!

like image 295
caiocpricci2 Avatar asked Nov 27 '12 22:11

caiocpricci2


People also ask

How do audio jacks detect plugs?

While audio jacks often have switches that can be used for plug detection, most codecs now implement jack sensing that measures the impedance and other characteristics of the plugged in device and make that information available to the processor they are connected to.

What is the extra terminal on an audio jack used for?

Most all jacks (DC power or audio) have an extra terminal that is switched on plug insertion. This is a mechanical switch. Some designs use this extra terminal to switch between battery and external power (in the case of DC jacks) or to switch between headphones and speakers (in the case of audio jacks).

What is the audio jack on a laptop used for?

The audio jack on a laptop is generally used to connect headphones or an external mic but you can also use it to connect a pair of external speakers or to split audio out to two different devices. Any audio device that can connect via a 3.5mm plug can be connected to your system.

What to do if your audio jack is not working Windows 10?

Any audio device that can connect via a 3.5mm plug can be connected to your system. Audio Jack Not Working (Windows 10) The audio jack on a Windows 10 laptop can connect both input and output devices. They’ll be detected immediately and you will not need to install additional drivers for it no matter how obscure the device is.


1 Answers

It's not clear if this will work without having the actual hardware in my hands, but... Don't plug the jack all the way into the socket. The tip of the jack should then connect to pin 2, left audio out, of this diagram: http://pinoutsguide.com/CellularPhones-P-W/samsung_galaxy_headset_pinout.shtml and the ring should connect to pin 3, microphone in. If you push the jack all the way in, the ground pin on the jack shorts out the microphone input and you won't detect anything - pictures at https://en.wikipedia.org/wiki/File:Photo-audiojacks.jpg show how the connections will mate.

Play some audio out the Left channel, record it on the mic channel, and measure the amplitude. That may - if it's all wired up right - tell you the pedal position. If the far end of the potentiometer is connected to the ring of the jack, that's not going to work.

That all sounds rather Heath Robinson. You could buy an inline 3-pin female jack socket and a 4-pin male jack plug and wire the two together to get whatever pinout you need. No electronics; just connectors and bits of wire! Or use a cable like this one: http://www.ebay.co.uk/itm/1mt-3-5mm-4-Pin-Jack-Male-Plug-4-Pole-Jack-female-Socket-Extension-Lead-Cable-/251172651017?pt=UK_Computing_Sound_Vision_Audio_Cables_Adapters&hash=item3a7b0e8009&_uhb=1 and a sharp knife and some stickytape.

The other problem would come if the phone refuses to send audio to the jack when the jack isn't plugged fully home - there's an extra contact in the socket that detects that mechanically. But it would work if you made 3-pin to 4-pin adapter.

Or, just cut the 3.5mm jack off your (shiny new) expression pedal. Replace it with the 4-pin connector off one of those broken phone headsets you have lying around.

like image 62
emrys57 Avatar answered Oct 20 '22 12:10

emrys57