DVBTheremin

Everyone with a DVB-T receiver knows that the tuner signal can get corrupted by the weather or in my case the bus which stops in front of the house I live in. Some DVB-T receivers display the tuner signal in an OSD of your TV. Since I’m using a DVB-T card in my PC with mplayer to watch TV I don’t see anything like that, so I found out that if you’ve tuned to some channel you can use the debugging and analyzing tool dvbsnoop to check the signal which looks like this in my case:

[cgie@talia:~] dvbsnoop -s signal -pd 1 -n 10
dvbsnoop V1.4.50 -- http://dvbsnoop.sourceforge.net/
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537
Sig: 10537

I don’t know what these numbers actually represent. 10537 corresponds with a good signal in my case. 10537 is the product of the two primes 41 and 257… but I guess that’s irrelevant. One might think that the numbers have certain range and that the higher numbers correspond with a better signal. In fact it’s the other way around and there are discrete values which represent several states of signal quality. However, the only interesting fact is that the numbers change if the signal does.

Step 1

Tune your DVB card to some channel, for example:

tzap -c .mplayer/channels.conf -r "Das Erste(NDR)"

Step 2

The next step is to convert these numbers to an audio signal, a perfect job for Pure Data which is “is a visual programming language developed by Miller Puckette in the 1990s for the creation of interactive computer music and multimedia works” (Wikipedia). The problem is to pipe the terminal output of dvbsnoop into Pure Data. I solved this by sending the outputs via UDP to my Pure Data patch, bash makes socket programming very easy. I used this simple script:

SERVER="127.0.0.1"
PORT=3333

exec 0<>/dev/udp/${SERVER}/${PORT} || exit # SDTIN
exec 1>&0                                  # STDOUT

while true; do
  dvbsnoop -s signal -pd 1 -n 1 | sed -ne 's/Sig: //p' | tail -1
done

This script does more than you actually need, you can also pipe the output directly to /dev/udp/${SERVER}/${PORT}. STDIN is only used with TCP connections and the script doesn’t receive anything. Anyway, if you run this script the signal values are constantly sent to port 3333 on your localhost.

Step 3

This the Pure Data patch I’m using.
PD patch for the DVB theremin
Basically the patch receives the output with the netreceive object and feeds an oscillator with it. I put some objects into the patch to adjust the volume and the pitch of the sound. The interesting thing to really make it sound like a theremin are the arithmetic operations on the upper left, some frequencies get interpolated between two outputs of dvbsnoop to create the typical sweeping sounds of a theremin, yeah I know, it’s kind of phony.

Here’s the result:

Post a Comment

Your email is never shared. Required fields are marked *

*
*