title: Decode remote control codes through audio input
body: <p>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. 
  <img src="https://i.stack.imgur.com/JetDf.png" alt="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. </p>