6

I have IR sensor which have TRS connector and I can record my remotes signals into audio. Now I want to control my computer with TV remote, but I don't have any clue how to compare audio input with pre-recorded audio. But after I realized that these audio waves contains only some kind data (binary) I can turn these into binary or hex, so it is much easier to compare.

Waves look just like this: wave 1

And this: wave 2

These are records of "OK" button, sometimes there are some impulses on right channel too and I don't know why, it seems like connections in sensor are damaged maybe. Ok thats not matter, anyway

I need help with python program which read these impulses and turn these into binary, in realtime from audio input(mic). I know it's sounds like "Do it for me, while I enjoy my life", but I don't have experiences with sound transforming/reading... I've looking for python examples for recording and reading audio, but unsuccessfully.

martineau
  • 119,623
  • 25
  • 170
  • 301
Timo
  • 153
  • 2
  • 2
  • 7
  • These SO questions may help you get started in the right direction: http://stackoverflow.com/q/892199/397366 and http://stackoverflow.com/q/2668442/397366 . Have a look and give the mentioned module, PyAudio, a shot. – spade78 Dec 24 '10 at 17:05
  • You might be going at this the hard way. Check out this section on [PC control](http://en.wikipedia.org/wiki/IR_remote_control#PC_control) of the Wikipedia article about [IR remote control](http://en.wikipedia.org/wiki/IR_remote_control). There's other articles there about the different protocols like [RC-5](http://en.wikipedia.org/wiki/RC-5) commonly used with these devices if you still want to do it in software yourself. – martineau Dec 24 '10 at 17:16
  • Just so you know, you can get a remote control with software and a USB receiver for something like $20. Now if you want to do this for some reason, go ahead, but you don't have to. – Lennart Regebro Dec 25 '10 at 18:02

1 Answers1

5

The this is quite easy if you can forgo the real time requirement: just save the data as a .wav file, and then read it in using Python's wave module.

Here's an example of how to read a wav file in Python,

import wave

w = wave.open("myfile.wav", "rb")
binary_data = w.readframes(w.getnframes())
w.close()

It's possible to do this in real time, but it's harder, though still not super difficult. For real time, I use PyAudio, and a good start would be to follow the examples in the demos. In these you basically open a stream and read small chunks at a time, and if you want any interactivity, you need to do this in a thread.

(Also, note, that the sound card will filter your audio inputs, so what you see isn't going to be the true input signal. In particular, I think remote controls often have a carrier frequency around 40KHz, which is higher than human hearing, so I doubt that sound cards work well in this range, though they may be sufficient depending on what you want to do.)

tom10
  • 67,082
  • 10
  • 127
  • 137