Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Decode remote control codes through audio input

Tags:

java

android

I am currently writing an Android app that functions as an internet radio. Part of the functionality of the app is that it is controllable via infrared remote. The infrared remote codes come in as analogue audio through the microphone port. If I record some of the signals and look at them in Audacity, it's very easy for me to see what each code is. For example, the following is 0111111010011001011111101000001 or 0x3F4CBF41. enter image description here My question is how can I programmatically detect these signals when they come in and convert them to integer code numbers. I have looked into some packaged solutions like LIRC, but they're written in C and would be difficult to integrate. It also seems to me like native would be over kill to do such simple analysis. I also looked into libraries like musicg, but I couldn't find any easy way to convert the codes in real time.

like image 751
krispy Avatar asked Jul 19 '14 23:07

krispy


People also ask

How do I decode any remote controller code with Arduino?

The circuit is too simple, just put IR Tsop receiver and give power using GND and VCC lines. Connect data pin to any digital pin of microcontroller. Print the values using I2C communication on 16x2 LCD. The values are given in Hex decoded format like: F897E456 ( 8- digits).

How do I find my InfraRed signal?

An IR Remote Control sends out a signal using Infrared light. You cannot see this light with your eyes, but by using a digital camera, cell phone camera, or camcorder in camera mode you can see the signal.

What is IR receiver?

An infrared receiver, or IR receiver, is hardware that sends information from an infrared remote control to another device by receiving and decoding signals. In general, the receiver outputs a code to uniquely identify the infrared signal that it receives.


1 Answers

It seems clear from your question that you are familiar with PWM and the method of reading the signal received from the IR receiver. As such, I have looked in to how you can use java to store the data in a method you can interpret as easily as your audacity window.

There are a couple methods in javax.sound.sampled.spi That I think would help.

The first is getAudioStream() in AudioFileReader. This returns an AudioStream which has a few more methods which may prove useful. The one I see as most handy for your purpose is read() which returns the next byte in the stream. You can provide a byte array to read parts or even the whole stream in to as well if that is more convenient.

So now you have a list or array of bytes, and you can interpret them as high or low at regular intervals (because this is sampled audio, the time between each byte is constant) which is all you need for PWM decoding!

By finding an approximate endpoint, you can turn a byte pattern over time to a pattern of high/low durations. Since I know you can read that (demonstrated in your question) I will skip the pedantic conversion, but it is trivial to convert hhhlhllhhhhhhlllhh into a hexadecimal representation of the code.

TL;DR: Capture the stream, read each byte, convert via time, convert to binary.

like image 183
Adam Yost Avatar answered Sep 16 '22 14:09

Adam Yost