TwoToneDetect TwoToneDetect on a Raspberry Pi - How To

Status
Not open for further replies.

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
That's actually a slightly different error than the one above. I suspect this may have to do with whatever causes "pulse" to show up as index 2 sometimes and index 3 other times. I think it may be index 2 but when TTD tries to use index 3 it throws this error. The next time you run the program it's back to index 3, for whatever reason. If it does it repeatedly, try running LevelMeter.pyc and see if the index of the "pulse" devices has changed.

Andy
Okay, that may be the issue. The last time i had the meter open it showed Index 2 so i changed the program setting. That may be why i am now getting the error much more frequently.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I have TTD59Pi up and running on the RPi now. All is working well except that the audio is terrible. I have been fooling with all sorts of settings trying to improve it. Attached are links to two audio recordings of the same dispatch, one off v56 running on an old WinXP computer at the firehouse and the second one off the Pi. I would love to be able to duplicate that audio quality on the Pi. Anyone have any suggestions for the audio settings? On the Windows computer I have the audio in volume on the computer set as low as it will go and control the volume with the knob on the scanner. Also there is a check box called AGC I think that has been cleared.

On the Pi I have the input level of the microphone set to 18%.

http://dl.dropbox.com/u/96733977/Sunderland_Fire_pi_recording.mp3

http://dl.dropbox.com/u/96733977/Sunderland_Fire_v56_recording.mp3
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
I have TTD59Pi up and running on the RPi now. All is working well except that the audio is terrible. I have been fooling with all sorts of settings trying to improve it. Attached are links to two audio recordings of the same dispatch, one off v56 running on an old WinXP computer at the firehouse and the second one off the Pi. I would love to be able to duplicate that audio quality on the Pi. Anyone have any suggestions for the audio settings? On the Windows computer I have the audio in volume on the computer set as low as it will go and control the volume with the knob on the scanner. Also there is a check box called AGC I think that has been cleared.

On the Pi I have the input level of the microphone set to 18%.

http://dl.dropbox.com/u/96733977/Sunderland_Fire_pi_recording.mp3

http://dl.dropbox.com/u/96733977/Sunderland_Fire_v56_recording.mp3

Are you running your USB at 2.0 (default) or have you changed it to 1.0? I had similar-sounding audio (although not that bad) before setting mine to 1.0. It would cause it to miss tones because of the distortion. See the very bottom of the web page (under USB audio input issues) for instructions on how to change it to 1.0 if you haven't already.

Andy
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Not really sure...

Not really sure what I might have done but I just sat down at the computer and the terminal had this displayed:

Freq: 527 Level: 3053
Freq: 510 Level: 3053
Freq: 521 Level: 3053
Freq: 521 Level: 3053
Freq: 532 Level: 3053
Freq: 516 Level: 3053
Freq: 451 Level: 3053
Freq: 677 Level: 3053
Expression 'alsa_snd_pcm_poll_descriptors_revents( self->pcm, pfds, self->nfds, &revents )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3597
Expression 'PaAlsaStreamComponent_EndPolling( &self->capture, capturePfds, &pollCapture, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 3793
Expression 'PaAlsaStream_WaitForFrames( stream, &framesAvail, &xrun )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 4338
Traceback (most recent call last):
File "TwoToneDetect59Pi.py", line 683, in <module>
File "TwoToneDetect59Pi.py", line 672, in record
File "/usr/lib/pymodules/python2.7/pyaudio.py", line 564, in read
return pa.read_stream(self._stream, num_frames)
IOError: [Errno Unanticipated host error] -9999
pi@raspberrypi ~/TTD59/dist $

The log doesn't show any problem prior to that. It looks like it shut TTD down.

I have been working on sound settings this morning but hadn't touched anything for an hour or so before this happened.

Now when I try to restart TTD I get the name "stream" error. This makes it look like it changed Index numbers mid-stream?

You are correct that I hadn't put the line in from the Audio issues comment at the end of the instructions. Will do that now.

Jim
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
You are correct that I hadn't put the line in from the Audio issues comment at the end of the instructions. Will do that now.

Jim

My memory is becoming shorter than my...

Yes, I did put the line in cmdline.txt when I originally set it up.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Yes, I did put the line in cmdline.txt when I originally set it up.

ok i found another cheap chinese sound card and replaced the Plantronics one that i was using. From my dummy tone test, it sounds much better, only it seems to be missing several seconds of message up front. Time to get on to something else for a while and let some real tones come through to see what happens.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I do remember running in to this, but can't remember what i did to get it working. Is your USB sound card plugged into a hub or directly into the Pi? I had some issues with my hub and had to plug it straight in to get it working.

Andy

A few more bits, andy:

1. The usb sound card is now in the hub and is working fine. The problem was in the configuration in pavumeter. There was an ALSA input of some sort that i disabled.

2. I also ran into very erratic keybard/mouse behavior when i plugged them in to the pi's usb port. When i plugged them into the usb hub they worked normally again.
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
From my dummy tone test, it sounds much better, only it seems to be missing several seconds of message up front.

Other people have reported that issue with the regular (non-Pi) v59. I'm still trying to troubleshoot it having a hard time reproducing it here.

Andy
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
2. I also ran into very erratic keybard/mouse behavior when i plugged them in to the pi's usb port. When i plugged them into the usb hub they worked normally again.

I had similar issues when I had the keyboard, mouse, and sound card all plugged in to the same hub. I can't get my hub to work at all in 1.0 mode, so I just ditched the keyboard and mouse in favor of SSH after switching to 1.0.

Andy
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I had similar issues when I had the keyboard, mouse, and sound card all plugged in to the same hub. I can't get my hub to work at all in 1.0 mode, so I just ditched the keyboard and mouse in favor of SSH after switching to 1.0.

Andy
I have been using SSH also. I moved my equipment to the firehouse last night to get the audio in from the scanner there which has a much better antenna. I can also ssh in at the FH. So i left it set up there last night and got no page detections although v56 got several. Not sure what the issue is. How do i know that TTD is running? Once i exit Terminal, i just have to hope that it stayed running. When i again log in thru ssh, i go right to a linux prompt and then have to start TTD. When i exit Terminal, does it stop the Python program?
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I have been using SSH also. I moved my equipment to the firehouse last night to get the audio in from the scanner there which has a much better antenna. I can also ssh in at the FH. So i left it set up there last night and got no page detections although v56 got several. Not sure what the issue is. How do i know that TTD is running? Once i exit Terminal, i just have to hope that it stayed running. When i again log in thru ssh, i go right to a linux prompt and then have to start TTD. When i exit Terminal, does it stop the Python program?

The NOHUP command does the trick.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Hi everyone,

I finally had some time to put together a page showing how I got TwoToneDetect running on a Raspberry Pi. Along with a cheap receiver, this could allow you to have a TTD setup up and running that uses very little power for under $100.

I'm by no means a Linux guru, so if you run into problems trying to duplicate this I'm not sure how much help I'll be, but feel free to post here if you'd like. I thought I'd start a new thread to keep the Linux stuff separate from the main Windows version of TTD.

Regards,

Andy

Andy, i thought it time to give you a quick update. I have learned more Linux this week than i ever thought that I would. Making it even more interesting is the fact that I am remoting in to the pi from out of state on my iPad. This is also new to me. I seem to have it running flawlessly now. Six tone sets detected overnight last night with complete audio recording, no missed audio. I am also running v56 on another computer and that shows me that i didn't miss any detections. I am still not pleased with the audio quality from the pi, i believe it to be related to Mic-in on the usb sound card. I tried turning the scanner volume down and the mic level up. That did improve it considerably. I plan on tinkering with this some more when i get home.
 

nightmicu

Member
Joined
May 23, 2012
Messages
11
Problem recording audio - file is empty

Greetings,

First, love the program. I'm really hoping to use this in conjunction with the Raspberry Pi for a local department - helping them get it set up.

I ordered my Pi this morning and won't have it for a while. In the meantime, I thought I'd follow your tutorial in Linux and see how it all works. I have everything working EXCEPT for recording of audio - the files that are being generated are empty (0 bytes).

This is what I see on the screen during the recording process -
Code:
done writing WAV Fire Department 1 11:42:38
ffmpeg version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[wav @ 0x13798c0] max_analyze_duration reached
Input #0, wav, from './audio/Fire_Department_1_2013-03-2811_42_38_782109.wav':
  Duration: 00:00:27.86, bitrate: 176 kb/s
    Stream #0.0: Audio: pcm_s16le, 11025 Hz, 1 channels, s16, 176 kb/s
Output #0, mp3, to './audio/Fire_Department_1_2013-03-2811_42_38_782109.mp3':
    Stream #0.0: Audio: [0][0][0][0] / 0x0000, 11025 Hz, 1 channels, s16, 200 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Encoder (codec id 86017) not found for output stream #0.0
done converting to MP3 Fire Department 1 11:42:38
Any ideas?
 

nightmicu

Member
Joined
May 23, 2012
Messages
11
In reference to my previous post, I corrected the e-mail issue by encoding my password to base64 (the Windows version of the program does this for you, then saves in Config - just entering my password plain in config seems to break everything. Also fixed the issue of empty audio files by running
Code:
sudo apt-get install ffmpeg libavcodec-extra-53
Still getting this message when recording -
Code:
done writing WAV Fire Department 1 11:58:12
ffmpeg version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[wav @ 0x1d2bae0] max_analyze_duration reached
Input #0, wav, from './audio/Fire_Department_1_2013-03-2811_58_12_452712.wav':
  Duration: 00:00:27.86, bitrate: 176 kb/s
    Stream #0.0: Audio: pcm_s16le, 11025 Hz, 1 channels, s16, 176 kb/s
[mp3 @ 0x1d2dd20] Unsupported sample rate.
Output #0, mp3, to './audio/Fire_Department_1_2013-03-2811_58_12_452712.mp3':
  Metadata:
    TSSE            : Lavf53.21.0
    Stream #0.0: Audio: libmp3lame, 11025 Hz, 1 channels, s16, 200 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
size=     219kB time=28.00 bitrate=  64.0kbits/s    
video:0kB audio:219kB global headers:0kB muxing overhead 0.014730%
done converting to MP3 Fire Department 1 11:58:12
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
In reference to my previous post, I corrected the e-mail issue by encoding my password to base64 (the Windows version of the program does this for you, then saves in Config - just entering my password plain in config seems to break everything. Also fixed the issue of empty audio files by running
Code:
sudo apt-get install ffmpeg libavcodec-extra-53
Still getting this message when recording -
Code:
done writing WAV Fire Department 1 11:58:12
ffmpeg version 0.8.5-6:0.8.5-0ubuntu0.12.10.1, Copyright (c) 2000-2012 the Libav developers
  built on Jan 24 2013 14:49:20 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[wav @ 0x1d2bae0] max_analyze_duration reached
Input #0, wav, from './audio/Fire_Department_1_2013-03-2811_58_12_452712.wav':
  Duration: 00:00:27.86, bitrate: 176 kb/s
    Stream #0.0: Audio: pcm_s16le, 11025 Hz, 1 channels, s16, 176 kb/s
[mp3 @ 0x1d2dd20] Unsupported sample rate.
Output #0, mp3, to './audio/Fire_Department_1_2013-03-2811_58_12_452712.mp3':
  Metadata:
    TSSE            : Lavf53.21.0
    Stream #0.0: Audio: libmp3lame, 11025 Hz, 1 channels, s16, 200 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
size=     219kB time=28.00 bitrate=  64.0kbits/s    
video:0kB audio:219kB global headers:0kB muxing overhead 0.014730%
done converting to MP3 Fire Department 1 11:58:12

That message is normal, looks like it's working. I may play around with switching from ffmpeg to libav at some point in the future to get rid of that warning, we'll see.

Andy
 

nightmicu

Member
Joined
May 23, 2012
Messages
11
That message is normal, looks like it's working. I may play around with switching from ffmpeg to libav at some point in the future to get rid of that warning, we'll see.

Andy
Hey Andy,
The bit that worries me is this -
** THIS PROGRAM IS DEPRECATED ***

Also, what do you make of the mp3 sample out of range error? It's highlighted red in the terminal
 

nightmicu

Member
Joined
May 23, 2012
Messages
11
Recording quality?

I have been experimenting with this configuration for the past couple of days and cannot seem to get the same quality as on a regular Linux machine running the same USB sound cards that I've been testing with.

Here are two recordings - the first from this sound card - Syba SD-CM-UAUD Amazon.com: Syba SD-CM-UAUD USB Stereo Audio Adapter, C-Media Chipset, RoHS: Computers & Accessories
and the second from the same sound card used in your How To manual.

Recording 1 - https://s3.amazonaws.com/tevfd-recording/Station_3_2013-04-0310_47_22_708715.mp3
Recording 2 - https://s3.amazonaws.com/tevfd-recording/Station_3_2013-04-0310_49_57_245594.mp3

The volumes are different (perhaps when you switch sound cards Pulse Audio changes levels around?) but the underlying quality is about the same. There is some crackling and at times it seems like it's freezing a bit.

I tried your suggestion to change USB to 1 in boot but it did not seem to make any difference. I also tried increasing the MP3 bitrate to 48000. Is this about as good as it gets or is there something else I can try?

Thanks
 

aaknitt

Member
Feed Provider
Joined
Aug 27, 2005
Messages
1,300
There seem to still be lots of issues with USB audio support on the Pi. Some USB cards seem to work better than others, and it doesn't seem like there are any sure fire ways to get them all working, based on what I've seen on the Raspberry Pi forums. Hopefully they'll come out with some updates to address this at some point. In the mean time, all I can do is tell you what I did to get it working decent with my particular sound card.

Andy
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Making progress

I have TTD59Pi up and running on the RPi now. All is working well except that the audio is terrible. I have been fooling with all sorts of settings trying to improve it. Attached are links to two audio recordings of the same dispatch, one off v56 running on an old WinXP computer at the firehouse and the second one off the Pi. I would love to be able to duplicate that audio quality on the Pi. Anyone have any suggestions for the audio settings? On the Windows computer I have the audio in volume on the computer set as low as it will go and control the volume with the knob on the scanner. Also there is a check box called AGC I think that has been cleared.

On the Pi I have the input level of the microphone set to 18%.

http://dl.dropbox.com/u/96733977/Sunderland_Fire_pi_recording.mp3

http://dl.dropbox.com/u/96733977/Sunderland_Fire_v56_recording.mp3

I bought another cheap usb sound card off ebay with a line in port in addition to mic in. After a little tinkering with the settings in pavucontrol it seems to have fixed the audio problems that i was experiencing. The audio is now nearly identical to that coming from TTD on the desktop unit with the internal sound card. I will post some samples later today.

Here is the card: External USB 2 0 Virtual 7 1 Channel CH 3D Audio Sound Card Converter Adapter W | eBay
 
Status
Not open for further replies.
Top