TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

Status
Not open for further replies.

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
Sorry I tried every option I could find and no luck. I want my RPi 3b+ to boot TTD 70 on boot but it wont work no matter what I try. I am completely new to this. I was able to get the program to execute a script that plays a station tone and activates a strobe in the bunkroom and play audio after the tone. .

I noticed that TTD will not open unless I open and run pulse audio first so I make sure to do that when I SSH in or use a tv/monitor so I added pulse audio in crontab

When I went into the crontab it shows a syntax error Non-ASCII character '\x99' in file /home/pi/TTD/TwoToneDetect70 on line 2, but no encoding declared...

Maybe Im doing it totally wrong, idk...went through a bunch of searches and youtube videos with no luck

So I got frustrated and tried to download the TTD image from the website onto a brand new SD card I bought today and no matter what I do to the SD card (followed instructions from raspberry pi site) its just the rainbow screen.

Any help is appreciated!

WHOA! You sound perfectly capable of making this work.

Try this route:

1. Download the v70 zip file from the Windows version section to your regular computer.

2. Extract the files.

3. Image your new SD card with the latest Raspbian image ( no need for the recommended software, just make sure you get the full image, not the lite version.). The pi3 B+ requires the latest OS otherwise you get the rainbow screen that you saw. Boot the pi using the fresh image.

4. Create a directory in the /home/pi directory called TTD.

5. Copy the four highlighted files from the extracted folder (see attached pic) to new directory on the pi. If you struggle with this, try putting them on a usb stick and inserting it into the pi.

6. On the pi, in the TTD folder create an empty file called simply ffmpeg.

7. Install pavucontrol on the pi. You can search for it in the add software menu item or install it from a Terminal window by typing sudo apt install pavucontrol. Now in the Sound and Video menu item, start pavucontrol.

8. Open the Terminal window on the pi’s desktop. Change to the TTD directory (cd TTD). Type python TwoToneDetect70.pyc at the command prompt. This will attempt to start TTD . You will likely get an error message, report back here what it is. I am not sure what dependencies may be missing from the new Raspbian OS but there will likely be a couple to install. You may be able to figure out from the messages which ones they are and install them yourself. I believe one is related to pushbullet.

Once you get this far and have TTD running we can then work on autostart.

Good luck

Jim
 

Attachments

  • 40E02E49-9220-4EF5-B76C-0F6A5485BCB3.jpg
    40E02E49-9220-4EF5-B76C-0F6A5485BCB3.jpg
    50.7 KB · Views: 108
  • E77C0FF6-739B-4167-BC0E-7ABDBB4BD077.jpeg
    E77C0FF6-739B-4167-BC0E-7ABDBB4BD077.jpeg
    83.6 KB · Views: 109

rparker87

Member
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
WHOA! You sound perfectly capable of making this work.

Try this route:

1. Download the v70 zip file from the Windows version section to your regular computer.

2. Extract the files.

3. Image your new SD card with the latest Raspbian image ( no need for the recommended software, just make sure you get the full image, not the lite version.). The pi3 B+ requires the latest OS otherwise you get the rainbow screen that you saw. Boot the pi using the fresh image.

4. Create a directory in the /home/pi directory called TTD.

5. Copy the four highlighted files from the extracted folder (see attached pic) to new directory on the pi. If you struggle with this, try putting them on a usb stick and inserting it into the pi.

6. On the pi, in the TTD folder create an empty file called simply ffmpeg.

7. Install pavucontrol on the pi. You can search for it in the add software menu item or install it from a Terminal window by typing sudo apt install pavucontrol. Now in the Sound and Video menu item, start pavucontrol.

8. Open the Terminal window on the pi’s desktop. Change to the TTD directory (cd TTD). Type python TwoToneDetect70.pyc at the command prompt. This will attempt to start TTD . You will likely get an error message, report back here what it is. I am not sure what dependencies may be missing from the new Raspbian OS but there will likely be a couple to install. You may be able to figure out from the messages which ones they are and install them yourself. I believe one is related to pushbullet.

Once you get this far and have TTD running we can then work on autostart.

Good luck

Jim

Jim,

Thanks for the prompt reply! I am brand new to this raspberry pi and python LOL! Lots of guessing and youtube and forums and Im sure my script for the light and audio is hokey but it works lol

I checked the directory and the only file missing was the TTD.py so I copied it in there. I attached screen snippets of what I have. (I have no idea what the fix is haha)
 

Attachments

  • TTD directory.jpg
    TTD directory.jpg
    41.6 KB · Views: 103
  • TTD error.jpg
    TTD error.jpg
    42.6 KB · Views: 96

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
Jim,

Thanks for the prompt reply! I am brand new to this raspberry pi and python LOL! Lots of guessing and youtube and forums and Im sure my script for the light and audio is hokey but it works lol

I checked the directory and the only file missing was the TTD.py so I copied it in there. I attached screen snippets of what I have. (I have no idea what the fix is haha)

Nice try! But you need to back up and start over. The TwoToneDetect70 file that you have there is the executable and that won’t work.

Rename your present TTD directory to something else and creat3 a new TTD directory.

You can copy in the tones.cfg and config.cfg, ffmpeg, and TTD70.pyc that you have in the renamed TTD directory. From the extracted files you need to put the TwoToneDetect70.pyc file into the new TTD folder.

Then try running it.
 

rparker87

Member
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
Nice try! But you need to back up and start over. The TwoToneDetect70 file that you have there is the executable and that won’t work.

Rename your present TTD directory to something else and creat3 a new TTD directory.

You can copy in the tones.cfg and config.cfg, ffmpeg, and TTD70.pyc that you have in the renamed TTD directory. From the extracted files you need to put the TwoToneDetect70.pyc file into the new TTD folder.

Then try running it.

Ok thanks, Download on my PC then move the unzipped files over? OR go to the website on the RPi?
I copied just those files over from my pc via VNC and made the ffmpeg file.
 

Attachments

  • New TTD directory.JPG
    New TTD directory.JPG
    43.1 KB · Views: 92
Last edited:

rparker87

Member
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
Nice try! But you need to back up and start over. The TwoToneDetect70 file that you have there is the executable and that won’t work.

Rename your present TTD directory to something else and creat3 a new TTD directory.

You can copy in the tones.cfg and config.cfg, ffmpeg, and TTD70.pyc that you have in the renamed TTD directory. From the extracted files you need to put the TwoToneDetect70.pyc file into the new TTD folder.

Then try running it.

Yeah Im lost LOL. Sorry

Got an error of no directory found and If i go to double click the TwoToneDetect70 icon it asks me for an application to open the file.
 

Attachments

  • TTD error.JPG
    TTD error.JPG
    56 KB · Views: 94

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
Yeah Im lost LOL. Sorry

Got an error of no directory found and If i go to double click the TwoToneDetect70 icon it asks me for an application to open the file.

To wrap this up for others who may be watching, Ryan figured out that he fat-fingered the directory name. There were three missing dependecies that needed to be added:

sudo apt-get install python-pyaudio

sudo pip install iniparse

sudo pip install pushbullet.py

Then TTD70 would start and run.

Jim
 

rparker87

Member
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
To wrap this up for others who may be watching, Ryan figured out that he fat-fingered the directory name. There were three missing dependecies that needed to be added:

sudo apt-get install python-pyaudio

sudo pip install iniparse

sudo pip install pushbullet.py

Then TTD70 would start and run.

Jim

Thanks for the help!

Lastly, any suggestions on script to add to my existing script to umute audio, run the rest of the script IE tone, lights, playback and then mute the script and stop until the next tone?
 

rparker87

Member
Joined
Apr 22, 2014
Messages
8
Location
Mystic, CT
Thanks for the help!

Lastly, any suggestions on script to add to my existing script to umute audio, run the rest of the script IE tone, lights, playback and then mute the script and stop until the next tone?
Update- I have a fully working script now. Took a lot of head scratching but with TTD and my RPi I have a cheaper version of a plectron for our station.

Sent from my SM-G960U using Tapatalk
 

n6oi

Member
Joined
Dec 1, 2018
Messages
8
Location
San Jose, CA
Thanks for getting this to work on a Pi... it's a great weekend project.

I'm able to get TTD70 to run, but I'm having a problem similar to rparker87 in that I'm getting a lot of error messages when starting it up on a Raspberry Pi 3B+. A good number of them are related to the sound card -- things like "Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0' -- which makes sense since I'm not using the one you recommended on your web page. I'm using a Sabrent external USB card, and it is stereo rather than 5.1 surround sound. So it looks like the card I'm using simply isn't what the program was expecting. Can you tell me what I need to change to get this Sabrent card to work, or do I need to use the card you specified?

I'm sure there are other issues too, but fixing the sound card errors should narrow down my remaining problems a lot.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
Thanks for getting this to work on a Pi... it's a great weekend project.

I'm able to get TTD70 to run, but I'm having a problem similar to rparker87 in that I'm getting a lot of error messages when starting it up on a Raspberry Pi 3B+. A good number of them are related to the sound card -- things like "Unable to find definition 'cards.bcm2835_alsa.pcm.surround51.0:CARD=0' -- which makes sense since I'm not using the one you recommended on your web page. I'm using a Sabrent external USB card, and it is stereo rather than 5.1 surround sound. So it looks like the card I'm using simply isn't what the program was expecting. Can you tell me what I need to change to get this Sabrent card to work, or do I need to use the card you specified?

I'm sure there are other issues too, but fixing the sound card errors should narrow down my remaining problems a lot.

The long list of sound card errors is normal. Attached is an image of what mine looks like upon a successful launch of TTD. I find that the more “feature-rich” sound card you use, the more errors you get. I use the $5 sound cards. I really doubt that your sound card is an issue.
 

Attachments

  • 21CDA15E-1A2F-4AE3-A2EB-318BB61CA23A.jpg
    21CDA15E-1A2F-4AE3-A2EB-318BB61CA23A.jpg
    66.5 KB · Views: 66

n6oi

Member
Joined
Dec 1, 2018
Messages
8
Location
San Jose, CA
The long list of sound card errors is normal. Attached is an image of what mine looks like upon a successful launch of TTD. I find that the more “feature-rich” sound card you use, the more errors you get. I use the $5 sound cards. I really doubt that your sound card is an issue.

Thanks for the reply, DC31. The errors shown in your screenshot pretty much match up with what I see, except that I see many, many more errors than you show -- my list of errors would fill multiple screenshots. But maybe that's a result of the soundcard I'm using... who knows.

The program is running, but it is retrieving the local tone info every 10 minutes. Is that normal behavior?

And I'm not sure what I'm looking at in the log files. It reports successfully retrieving the local tone info, but it shows that line multiple times. Also, I sometimes see tone frequencies in the log and sometimes not, and the frequencies aren't always ones that I've entered. What should I see in the log?

Finally, I'm seeing one recurring error in the log files. It is:
File "TwoToneDetect70.py", line 1006, in <module>
File "dist-packages/pyaudio.py", line 750, in open IOError: [Errno -9997] Invalid sample rate

Is there a configuration setting that I missed somewhere that sets sample rate?
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
Thanks for the reply, DC31. The errors shown in your screenshot pretty much match up with what I see, except that I see many, many more errors than you show -- my list of errors would fill multiple screenshots. But maybe that's a result of the soundcard I'm using... who knows.

The program is running, but it is retrieving the local tone info every 10 minutes. Is that normal behavior?

And I'm not sure what I'm looking at in the log files. It reports successfully retrieving the local tone info, but it shows that line multiple times. Also, I sometimes see tone frequencies in the log and sometimes not, and the frequencies aren't always ones that I've entered. What should I see in the log?

Finally, I'm seeing one recurring error in the log files. It is:
File "TwoToneDetect70.py", line 1006, in <module>
File "dist-packages/pyaudio.py", line 750, in open IOError: [Errno -9997] Invalid sample rate

Is there a configuration setting that I missed somewhere that sets sample rate?

In your TTD folder there is a file titled config.cfg. Most parameters are adjusted using the “Edit Config Info” button in the TTD window. However, there are other parameters. Open the file manually with a text editor. update_interval= controls how often the program reads the local file. Every 10 min is excessive. I use 240 min, but could easily use a daily update.

While you are in the file, change your input device and your output device each to zero. This may correct the invalid sample rate error. That error is likely the one preventing proper program function. Otherwise, i would say that you are real close.


Make sure that you close TTD before you edit the config.cfg file. Otherwise, your changes will be lost.
 
Last edited:

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
And I'm not sure what I'm looking at in the log files. It reports successfully retrieving the local tone info, but it shows that line multiple times. Also, I sometimes see tone frequencies in the log and sometimes not, and the frequencies aren't always ones that I've entered. What should I see in the log?

/QUOTE]

Here is a snippet from my logfile:

Successfully retrieved remote tone info at 18:02:44 on 12/02/18
Tone1
Tone2
Tone3
Tone4
Longtone1
Tone9
247.0 5849.45450324
543.0 430.404486037
736.0 4110.27219001
709.0 1034.42735619
833.0 2023.49988246
801.0 1707.36779242
424.0 1040.2117738
500.0 1528.88974764
758.0 2090.29490569
828.0 115.407636906
763.0 97.23936302
349.0 3963.65044337
1753.0 874.546117022
1236.0 164.534551274
354.0 72.6077287344
354.0 61.1601003138
354.0 51.7967562913
354.0 91.9588958757
354.0 57.583161659
2054.0 317.441020867
661.0 1102.01850569
403.0 4945.9721793
247.0 8310.28058326
903.0 1770.22566793
903.0 1744.58314182
903.0 1714.88758324
903.0 1702.04472902
903.0 1681.65548041
580.0 1972.65087809
580.0 1994.34845185
580.0 1972.30416528
First_Alarm Tone Set Found
580.0 2020.64929477

TTD samples audio that it is receiving every 200ms and determines the dominant frequency in the sample. The numbers you see at the left side are those dominant frequencies. The relatively random ones are just regular radio transmissions. Near the end, you will see five 903 samples ( a 1 sec Atone of 903hz) followed by several 580 hz samples (the Btone). I use Atone and Btone lengths of both 0.6. So three samples of 903 followed by three samples of 580 causes a decode. The Btone is actually 3 sec long so there are a total of fifteen 580 samples.

Ideally you have your TTD squelch set so that it is only analyzing samples when there are actual radio transmissions. If the numbers scroll continuously even when there are no transmissions, then you need to adjust the squelch.

Does that help?
 

n6oi

Member
Joined
Dec 1, 2018
Messages
8
Location
San Jose, CA
TTD samples audio that it is receiving every 200ms and determines the dominant frequency in the sample. The numbers you see at the left side are those dominant frequencies. The relatively random ones are just regular radio transmissions. Near the end, you will see five 903 samples ( a 1 sec Atone of 903hz) followed by several 580 hz samples (the Btone). I use Atone and Btone lengths of both 0.6. So three samples of 903 followed by three samples of 580 causes a decode. The Btone is actually 3 sec long so there are a total of fifteen 580 samples.

Ideally you have your TTD squelch set so that it is only analyzing samples when there are actual radio transmissions. If the numbers scroll continuously even when there are no transmissions, then you need to adjust the squelch.

Does that help?

Excellent... that all makes perfect sense.

I have it working now. I have my input and output index set to 5 rather than 0 because the program couldn't find an audio device when it was set to 0, but 5 works.

The Update Interval was set to 60, but when I first tried to run it I was seeing it update more frequently than every 60 minutes... not sure why. Nonetheless, I like your approach, and set mine to 240 as well.

And yes, I also have Atone and Btone lengths of 0.6, and have the squelch set such that there is no audio detected until there's an actual signal.

It successfully detected a page this morning, and tried to send emails to the two addresses I entered for testing. However, the "from" email address I chose was set up to require two-factor authentication (which I didn't think about, obviously), so the program couldn't log in. I've fixed that now, so the next time a page comes through that matches one of the 5 tone pairs that I've put into the tones.cfg file, the emails should go out.

Thanks very much for the prompt support!
 

hazard78

Member
Feed Provider
Joined
Apr 1, 2003
Messages
49
Location
St Clair, mi
Error message

I got it up and running on pi 3. I get an error can’t find ffmpeg can’t create amr email.

Any help would be great.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,545
Location
Massachusetts
neither one will work I cant get the photo to copy here and can get the text to paste either.

When you set up your pi, did the following two commands run successfully?

sudo apt-get install ffmpeg

sudo apt-get install libavcodec-extra57

It won’t hurt to run them again.

Did you enable vnc on the pi?
 

bikeplatt

Newbie
Joined
Jan 3, 2019
Messages
3
Can someone host a finished, stable, image file? I've run through the setup 3 times with a couple different sound cards and its never stable. Either the program freezes after a couple days with no error or it fails to load from a psaudio error. List the sound card and I'll get it.
 
Status
Not open for further replies.
Top