This page describes how to get a special version of TwoToneDetect up and running on a $35 Raspberry Pi single board computer. Along with a $5 USB sound card and a cheap receiver ($50 Wouxon or similar), you can have a full TTD setup running 24/7 that consumes very little power for under $100. This page describes what I did to get it running on my Pi. Your mileage may vary.
First, follow the instructions here to get the latest Raspbian operating system installed on your SD card. Then take a look at this tutorial to get the Pi configured during the initial boot up. You'll want to configure the keyboard, locale, and timezone, as well as expand the root partition so that you can use your entire SD card. Finally, make sure you enable SSH server on your Pi. This will save you later if you find (like I did) that your keyboard and mouse don't work with USB 1.1 if you have to disable USB 2.0 to get your sound card to work properly.
After you've done your initial configuring, get yourself familiar with the Pi. You can type:
to start a graphical interface similar to Windows, or just work with the command line, whichever you prefer. Most of the TTD setup will be done at the command line, although configuring the audio input is done with a GUI for simplicity.
Because Pyinstaller doesn't work with the ARM platform that the Pi uses, I can't build an executable for the Pi that will automatically incorporate all of the required prerequisite packages for running TwoToneDetect. Instead, we'll have to install them manually. If you follow the instructions here you should get everything you need. Make sure your Pi is connected to the web before proceeding.
First, we need to install distribute so that we can install a few Python packages. We do this by entering the following at the command prompt:
Then do this, which gets the python.h header file required to compile other modules using PIP:
Then download PIP and install it by doing this:
Once we have PIP installed we can use it to grab and install a couple more required Python modules:
Installing Pyaudio requires a few more steps:
We also need to install ffmpeg with and amr codec:
And we'll install pulse audio and the pulse audio control GUI for setting our audio levels:
Finally, we'll need to change the resampling method for pulseaudio, since TwoToneDetect uses a lower sampling rate than the default of most sound cards. Use this to start open the required file in the "nano" text editor:
then find the line that says:
and change it to:
note that you need to remove the semicolon at the beginning of the line!
Then reboot to cause changes to take effect.
To install TwoToneDetect, simply download the latest tarball to the directory of your choice on the Pi and extract it using:
The Raspberry Pi version of TwoToneDetect does not include any GUI (to reduce CPU load), which makes configuration a little more difficult. To edit the tones.cfg file, there are a few options:
To edit the config.cfg file, you'll need to manually edit it using either nano (from the command line) or Leafpad (in the XWindows GUI). Before editing the config.cfg file, you'll need to determine the index of the pulseaudio input and output so that you can set the input_device_index and output_device_index parameters accordingly. You'll also need to determine what level to set the audio_threshold parameter to. To help with these tasks, I've include a LevelMeter utility. To start it, navigate to your TwoToneDetect directory and type:
The utility will list all of your input and output sound devices. You want to find the input and output named pulse. Make note of the index (number) of these, as this is what you'll want to specify for the input_device_index and output_device_index in your config.cfg file.
Enter in the index corresponding to pulse for the input and output, and the utility will start taking audio samples and printing the audio level to the console window. Make note of what the audio levels are with no audio input present, and also with audio present. You'll want to set your audio_threshold parameter to be somewhat above the levels you see with no audio present, but not so high as to be above the levels when audio is present. You can adjust the audio of your scanner or radio using this utility as needed. To stop the audio sampling and terminate the LevelMeter utility, hit CTRL-C.
Now that you now what the input_device_index, output_device_index, and audio_threshold parameters should be set to, you can edit the config.cfg file. Note that the email password must be base64 encoded in the config.cfg file. There are a number of websites that can do this encoding for you, or you can copy this parameter over from a Windows computer that you have running TwoToneDetect.
Once you have the tones.cfg and config.cfg files set up correctly, you can start TwoToneDetect by typing:
The USB audio support on the Raspberry Pi still has some issues. See this forum thread for more information. To solve this, I had to add this statement to the beginning of /boot/cmdline.txt file:
After modification, /boot/cmdline.txt should look something like this:
After doing this my USB mouse and keyboard stopped working, so I had to access my Pi via PuTTY using SSH. However, this fixed my audio issues and made TwoToneDetect work well.
To manually edit the tones.cfg file without using the GUI, open the file using a text editor. Each tone set is specified by
a [Tone] or [Longtone] delimiter. For two-tone (A-B format) pages, use
[Tone], for long tone pages (long A or long B format), use [Longtone].
See below for a simple example.
playback_during_record = 1record_delay = 2.5