Automating WIA Broadcasts

Automating WIA Broadcasts

Postby VK7DB » Mon Apr 07, 2014 4:57 pm

Hi All,

Has anyone here setup a system to automate the WIA broadcasts. I envisage a Raspberry Pi interfaced to a low power radio.. It would have to get the file, enable broadcast mode on the repeater, play the file at the scheduled time and then return the repeater to normal mode. I'm just starting to play with the RPi now, but not clever enough to make something like this work..

Dion
7DB.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK2OMD » Mon Apr 07, 2014 5:12 pm

VK7DB wrote:Hi All,

Has anyone here setup a system to automate the WIA broadcasts. I envisage a Raspberry Pi interfaced to a low power radio.. It would have to get the file, enable broadcast mode on the repeater, play the file at the scheduled time and then return the repeater to normal mode. I'm just starting to play with the RPi now, but not clever enough to make something like this work..


You might want to consider the reliability of RPi. Linux is not a high reliability system, though it does get better, but my experience of the RPi port is that it is quite unreliable. I have one box that runs continuously running a single end user application, mpd (a music player daemon), and it freezes more than once a month on average.

In pursuing IPUSB solutions, the effectiveness of the development team in properly integrating components is shown to be poor, and they don't seem responsive to problem reports.

I wonder if they will stabilise the package before it is outdated / superceded (and that might already have occured).

Owen
VK2OMD
Forum Diehard
 
Posts: 1063
Joined: Tue Oct 10, 2006 8:34 am

Re: Automating WIA Broadcasts

Postby VK2TS » Mon Apr 07, 2014 6:08 pm

It can be done on an IRLP Node. I haven't done it on the one i administer as there is an auto RF link to the local repeater but it can be done.

Cheers
Tony
VK2TS
VK2TS
Frequent Poster
 
Posts: 195
Joined: Sun Jan 10, 2010 6:13 am

Re: Automating WIA Broadcasts

Postby VK7DB » Mon Apr 07, 2014 8:02 pm

I want to try to avoid IRLP if I can.. IRLP has been suggested twice already, so maybe thats the easiest method..

Owen, I didn't realise there were reliability issues with the RPi.. I have one doing music at the moment, originally it was doing RaspyFi which is just a fancy mpd.. Now its doing piCorePlayer which runs Microcore linux connected to a media server on Ubuntu playing Internode Freezone steams all day long. Its never missed a beat. The piCorePlayer Pi has a HiFiBerry DAC on it, you might be interested..
I have another Pi doing APRX and although it hasn't been going for very long, while it has been its never given trouble..

Dion.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK2JDH » Tue Apr 08, 2014 8:52 am

VK2OMD wrote:
Linux is not a high reliability system, though it does get better,
Owen


Realy? The mail store at work that's been up for more that 1800 days begs to differ, And the IRLP node I look after thats been up for > 1 year. ( commercial power fail last outage) Where people go wrong us using crappy 3rd party drivers on flaky peripherals.
VK2JDH
Forum Diehard
 
Posts: 222
Joined: Thu Mar 12, 2009 10:57 am

Re: Automating WIA Broadcasts

Postby VK2JDH » Tue Apr 08, 2014 8:54 am

VK7DB wrote:I want to try to avoid IRLP if I can
Dion.


You can run IRLP on a Pi.
VK2JDH
Forum Diehard
 
Posts: 222
Joined: Thu Mar 12, 2009 10:57 am

Re: Automating WIA Broadcasts

Postby VK2OMD » Tue Apr 08, 2014 9:25 am

VK7DB wrote:I want to try to avoid IRLP if I can.. IRLP has been suggested twice already, so maybe thats the easiest method..

Owen, I didn't realise there were reliability issues with the RPi.. I have one doing music at the moment, originally it was doing RaspyFi which is just a fancy mpd.. Now its doing piCorePlayer which runs Microcore linux connected to a media server on Ubuntu playing Internode Freezone steams all day long. Its never missed a beat. The piCorePlayer Pi has a HiFiBerry DAC on it, you might be interested..
I have another Pi doing APRX and although it hasn't been going for very long, while it has been its never given trouble..

Dion.


Dion,

I cannot recall the distro I used for the RPis, I was an early adopter and there were a few but I think like a lot of these kind of project multiple distos spring up instead of people contributing to make one excellent distro.

I put lots of maintenance on these every month and they are flaky compared to my Ubuntu server which just runs and runs.

In time they may get getter, but the question is whether they become good before the hardware platorm is dated (and that is happening now).

You can try developing something, but it is probably prudent to make sure the system is running prior to scheduled broadcast time, or install some ongoing monitoring.

Owen
VK2OMD
Forum Diehard
 
Posts: 1063
Joined: Tue Oct 10, 2006 8:34 am

Re: Automating WIA Broadcasts

Postby VK2OMD » Tue Apr 08, 2014 9:38 am

VK2OMD wrote:...

I cannot recall the distro I used for the RPis, I was an early adopter and there were a few but I think like a lot of these kind of project multiple distos spring up instead of people contributing to make one excellent distro.


I logged on and checked (box was frozen, needed a reboot). I am using bog standard Raspbian at current maintenance level.

I see there are at least 31 distros for RPi!!!

Owen
VK2OMD
Forum Diehard
 
Posts: 1063
Joined: Tue Oct 10, 2006 8:34 am

Re: Automating WIA Broadcasts

Postby VK7DB » Tue Apr 08, 2014 10:56 am

Interesting..

Yes, I was looking at PiIRLP.

I have worked out that I can do this to get the files.
Code: Select all
DATE=`date +"%Y-%m-%d"`
wget http://www.wia-files.com/podcast/wianews-$DATE.mp3

That would have to be run at a time that the file was there. I think wget can do a spider function, so maybe that can work too?

I have also worked out that I can use omxplayer to play the mp3 files directly without needing to transcode. So I can do
Code: Select all
omxplayer wianews-$DATE.mp3 && omxplayer VK7_regional_news_$DATE.mp3 && file_that_contains_dtmf_for_normal_mode.wav


Then I found this
Code: Select all
# Set up GPIO 4 and set to output
echo "4" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio4/direction

# Write output
echo "1" > /sys/class/gpio/gpio4/value
So I could probably use that to change the state of a GPIO pin to do PTT..

If I got clever I could use another GPIO pin to look at the radios mute to see if the repeater was busy before sending the broadcast enable tones, but I'm not that clever..

Dion.
Last edited by VK7DB on Tue Apr 08, 2014 1:02 pm, edited 1 time in total.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK2JDH » Tue Apr 08, 2014 11:10 am

VK7DB wrote:If I got clever I could use another GPIO pin to look at the radios mute to see if the repeater was busy before sending the broadcast enable tones, but I'm not that clever..

Dion.


If you have got that far I think you are!. The way the IRLP news player works is that it checks the COS line. I must be idle for x minutes before the news starts playing out to avoid playing over a existing QSO. So if it due to start at 10am but the repeater is inuse till 10:14 it will play at (say) 10:18. I can also be set up to give a announcement y minutes before the scheduled time that it is about to start.

Some ideas, samples from this VK2

http://stn6732.ip.irlp.net/scripting.html
VK2JDH
Forum Diehard
 
Posts: 222
Joined: Thu Mar 12, 2009 10:57 am

Re: Automating WIA Broadcasts

Postby VK7DB » Tue Apr 08, 2014 11:52 am

Theres some good examples in there..

I see theyre using email notifications. Maybe I could make it do that too..

I think I can make this work without IRLP. The only problem we will have is that the VK7 regional news is never uploaded to the same place each week, as we have different news readers on a roster..
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK4UQ » Tue Apr 08, 2014 12:23 pm

Hi Dion

I have been running a PiRLP node at home that has been flawless. I have it set to disable the node prior to the broadcast (10am) and then once the broadcast is completed, I have the node enable again (back to normal)

Sure, it takes some time to get it up and running, but it is rock solid.

I have to downloading nearly every news broadcast around the country aswell as from overseas. I have the node download the WIA, QNews, VK5, VK6, VK7, NZART, RSGB, Newsline to name a few....

I have to automated to play the WIA news and provide callbacks automated aswell.

Yes, it can be done... A little work involved but it works just as well as the PC version of Linux that I was running. No noise and less power - what is there not to like about it?

Cheers
Dave
VK4UQ
Forum Novice
 
Posts: 22
Joined: Tue Apr 13, 2010 6:42 pm

Re: Automating WIA Broadcasts

Postby VK2AVR » Tue Apr 08, 2014 1:07 pm

Remember that rPi is a hobby platform, not a fully fledged server. it's totally unfair to blame "linux" as an all-encompassing entity, a normal distribution on decent hardware is solid as a rock.

I've also seen plenty of reports that 99% of your problems are usually power supply related. Depending on what you've got hanging off your Pi, a 5V 1 Amp or 5V 2 amp power supply is vital. I just bought a couple of dual USB outlet mains chargers off ebay and they are very poor quality. They don't deliver on spec and one of them smells a bit funky already. Serves me right. Off to Jaycar I reckon, for a decent 5V 2.1A USB charger supply.
Geoff
VK2AVR
VK2AVR
Forum Diehard
 
Posts: 379
Joined: Wed Jan 04, 2012 12:53 pm

Re: Automating WIA Broadcasts

Postby VK7DB » Tue Apr 08, 2014 1:20 pm

G'day Dave,

Thanks for your first post, welcome!

This is why I like the Pi. Its small, cheap to run, quiet, etc..

It seem the scripts could get files from VK7AX.. Is that how you get the VK7 news? I'm not aware of a static location of a file with a generic name, I get the notifications of the file locations from the readers.. They usually put it on a dropbox.

Reading further into the scrips I've discovered that I can get the file from http://www.wiaq.org.au/ftp/ with a generic name, that makes everything easier with not having to mess about with dates.. I have no interest in archiving files, I just want something to play them, so thats simple.

Dion.
Last edited by VK7DB on Sat Apr 12, 2014 5:13 pm, edited 1 time in total.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK7DB » Tue Apr 08, 2014 1:25 pm

On the subject of power supplies, last time I made an order I got two of these http://www.buyraspberrypi.com.au/shop/1 ... ansformer/ I have one in use now running my APRX Pi. It makes 5.1V with the TNC-Pi, USB powered TNC-X and wifi adaptor installed. I just supply power to the Pi through the GPIO port.. Seems to work well.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK7DB » Sat Apr 12, 2014 5:01 pm

I have it working.. Here is what I did..

I have 3 scripts doing the work. One gets the files and prepares them, the next puts the repeater into broadcast mode and the third plays the files.

The getnews script
Code: Select all
#!/bin/bash

# Set directory
NEWS="/media/USB"
LOG=$NEWS/log/getlog.txt

# Set date for file naming
DATE=`date +"%Y-%m-%d"`

# WIA file name
WIAFILENAME="wianews-`date +"%Y-%m-%d"`.mp3"

# Change directory
cd $NEWS

writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}

# Get WIA file
/usr/bin/wget http://www.wia-files.com/podcast/$WIAFILENAME && writelog "Got WIA file OK" || writelog "Download WIA file failed!"
cp $WIAFILENAME $NEWS/archive/wianews-$DATE.mp3 && writelog "Archived WIA file OK" || writelog "Archive WIA file failed!"
rm wianews.mp3 && writelog "Removed last weeks WIA file OK" || writelog "Remove last weeks WIA file failed!"
mv $WIAFILENAME wianews.mp3 && writelog "Rename WIA file to generic name OK, file prepared :)" || writelog "Rename WIA file to generic name failed!"

# Get VK7 file
/usr/bin/wget http://www2.vk7ax.id.au/wianews/VK7Regional.mp3 && writelog "Got VK7 file OK" || writelog "Download VK7 file failed!"
cp VK7Regional.mp3 $NEWS/archive/tasnews-$DATE.mp3 && writelog "Archived WIA file OK" || writelog "Archive WIA file failed!"
rm tasnews.mp3 && writelog "Removed last weeks VK7 file OK" || writelog "Remove last weeks VK7 file failed!"
mv VK7Regional.mp3 tasnews.mp3 && writelog "Rename VK7 file to generic name OK, file prepared :)" || writelog "Rename VK7 file to generic name failed!"

exit 0


The broadcast mode script, this gets played about 10 mins before start time
Code: Select all
#!/bin/bash

# Set news directory
NEWS="/media/USB"

# Set pause time value
pause=1

# Change directory
cd $NEWS

# Set up GPIO 17 and set to PTT output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
# Set up GPIO 18 and set to COR input
echo "18" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio18/direction

# Broadcast mode function
bcmode()
{
# PTT up
echo "1" > /sys/class/gpio/gpio17/value
# Wait a while
sleep $pause
# Play VK7DB
mpg123 $NEWS/VK7DB.mp3
# Wait a while
sleep $pause
# Play timeout disable
mpg123 $NEWS/bcmode.mp3
# Wait a while
sleep $pause
# PTT down
echo "0" > /sys/class/gpio/gpio17/value
# Goto end
end
}

# End function
end()
{
# Clean up
echo "17" > /sys/class/gpio/unexport
echo "18" > /sys/class/gpio/unexport
exit 0
}

# Main loop
while :
do
value=`cat /sys/class/gpio/gpio18/value`
if [ $value -eq 0 ]; then
bcmode
fi
done
# Goto end
end


The playnews script
Code: Select all
#!/bin/bash

# Set directory
NEWS="/media/USB"
LOG=$NEWS/log/playlog.txt

writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}

# Set pause time value
pause=1

# Change directory
cd $NEWS

# Set up GPIO 17 and set to output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction

# PTT up
echo "1" > /sys/class/gpio/gpio17/value && writelog "PTT up" || writelog "PTT fail!"

# Play WIA news
writelog "Play WIA news start"
mpg123 $NEWS/wianews.mp3 && writelog "WIA play finished" || writelog "WIA play fail!"

# Play Tas news
writelog "Play VK7 news start"
mpg123 $NEWS/tasnews.mp3 && writelog "VK7 play finished" || writelog "WIA play fail!"

# Wait a while
sleep $pause

# Play timeout enable
writelog "Enable timeout start"
mpg123 $NEWS/normalmode.mp3 && writelog "Enable timeout done" || writelog "Enable timeout fail!"

# Wait a while
sleep $pause

# Play VK7DB
writelog "Play VK7DB start"
mpg123 $NEWS/VK7DB.mp3 && writelog "Play VK7DB done" || writelog "Play VK7DB fail!"

# PTT down
echo "0" > /sys/class/gpio/gpio17/value && writelog "PTT down" || writelog "PTT down fail!"

# Clean up GPIO
echo "17" > /sys/class/gpio/unexport

exit 0


I have also written a script to get the RAOTC file, should Winston not be able to run it.
Code: Select all
#!/bin/bash

# Set directories
NEWS="/media/USB"
LOG=$NEWS/log/getlog.txt

# Set date for file naming
DATE=`date +"%Y-%m-%d"`

# Set file naming
RAOTC=`date +%B%Y`.wma
RAOTC=${RAOTC,,} # convert to lower case

# Change directory
cd $NEWS

writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}

# Get RAOTC file
/usr/bin/wget http://www.raotc.org.au/Audio_files/$RAOTC && writelog "Got RAOTC file OK" || writelog "Download RAOTC file failed!"
cp $RAOTC $NEWS/archive/raotc-$DATE.wma && writelog "Archived RAOTC file OK" || writelog "Archive RAOTC file failed!"
rm raotc.wma && writelog "Removed last weeks RAOTC file OK" || writelog "Remove last weeks RAOTC file failed!"
mv $RAOTC raotc.wma && writelog "Rename RAOTC file to generic name OK, file prepared :)" || writelog "Rename RAOTC file to generic name failed!"

exit 0

And to play it
Code: Select all
#!/bin/bash

# Set news directory
NEWS="/media/USB"

# Set pause time value
pause=1

# Change directory
cd $NEWS

# Set up GPIO 17 and set to output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction

# PTT up
echo "1" > /sys/class/gpio/gpio17/value

# Play WIA news
mplayer $NEWS/raotc.wma

# Wait a while
sleep $pause

# Timeout enable
mpg123 $NEWS/26501.mp3

# Wait a while
sleep $pause

# Play VK7DB
mpg123 $NEWS/VK7DB.mp3

# PTT down
echo "0" > /sys/class/gpio/gpio17/value

# Clean up GPIO
echo "17" > /sys/class/gpio/unexport

exit 0


These scripts are scheduled with cron
Code: Select all
# m h  dom mon dow   command
@reboot /usr/bin/amixer set PCM 4dB unmute >/dev/null 2>&1
0 18 * * 6 /media/USB/getnews.sh >/dev/null 2>&1
50 22 * * 6 /media/USB/bcmode.sh >/dev/null 2>&1
59 22 * * 6 /media/USB/playnews.sh >/dev/null 2>&1


Just for something to do, I made another script log repeater usage to a file and echo it to the screen.
Code: Select all
#!/bin/bash

NEWS=/media/USB
LOGDIR=$NEWS/log
CORLOG=corlog.txt

# Set up GPIO 18 and set to COR input
echo "18" > /sys/class/gpio/unexport
echo "18" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio18/direction


writeopen ()
{
echo; echo
echo "Mute opened at `date`"
echo "Mute opened at `date`" >> $LOGDIR/$CORLOG
}

writeclosed ()
{
echo "Mute closed at `date`"
echo "Mute closed at `date`" >> $LOGDIR/$CORLOG
echo >> $LOGDIR/$CORLOG
loop
}

loop ()
{
while :
do
cor=`cat /sys/class/gpio/gpio18/value`
if [ $cor -eq 1 ]; then
   writeopen
   while :
   do
      cor=`cat /sys/class/gpio/gpio18/value`
      if [ $cor -eq 0 ]; then
      writeclosed
      fi
   done
fi
done
}

loop


I set the audio output of the Pi to 100% on startup and adjust level inside the modified PRM8010.

GPIO 18 is used as an input, it looks at the output of the CTCSS decoder in the receiver of the 8010.. When the repeater user stops transmission, the repeater tone encoder stops. Monitoring of the repeater mute allows the bcmode script to be polite if the repeater is in use.

While typing this I have just received an email saying that RAOTC will change their file format. To get the .wma file to play, I had to install additional software. Now that theyre going with MP3 files, mpg123 will play those..

The next trick will be to write errors to a separate error log file and email me the error log only if it exists.. If something has failed I can fix it, otherwise I don't need to know about it..

Special mention must be made of Matt VK3VS for thanks for his ideas and scripting assistance with this project. Thanks also to the others that commented here and in PMs.

Since I'm new to all of this, if someone can see a better or different way to do things, I'd be happy to know.

Dion.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK2OMD » Sat Apr 12, 2014 5:59 pm

Fetching files can be a problem with congested networks and servers.

I have tried wget, curl and lftp for unattended systems, and found the recovery system in lftp superior to the others.

(There is a new windows build of LFTP with openssl 1.01g released in recent days, addresses the Heartbleed problem for Windows users).

Scripts that allow indefinite retries, either due to the client itself or explicity scripted might have unintended results when the transfer cannot proceed. Programming is often 10% dealing with things that work normally, and 90% dealing with exceptions... that's the way of these things.


Owen
VK2OMD
Forum Diehard
 
Posts: 1063
Joined: Tue Oct 10, 2006 8:34 am

Re: Automating WIA Broadcasts

Postby VK7DB » Sun Apr 13, 2014 10:34 am

I will have a look at lftp and see what I can make it do..

I'm happy to report that the Pi did everything it needed to do and the broadcast went to air as scheduled. Quality reports in the callback were all good.

There was a level difference between the WIA and VK7 news, so I have installed mp3gain to normalise the two mp3 files.. This should make it a bit nicer to listen to.

Dion.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Re: Automating WIA Broadcasts

Postby VK2OMD » Sun Apr 13, 2014 4:18 pm

Dion,

I did some work with VK4BB about 10 years ago developing some guidelines for FM relay of the WIA broadcast from mp3.

At that time, the loudness measure I used was RMS, and Graham's files tended to be around -18dBfs RMS.

I did experiments with home stations and mobile stations to find a deviation regime that was acceptable, a balance between clipping (in the FM transmitter) distortion and readability for mobiles operating with poor signal. The overwhelming opinion of those who took part in the trial was that they wanted to understand the broadcast as a prioirity, but distortion had to be acceptable.

That is not too hard to achieve, you reach a point when overdriving the transmitter that distortion increases rapidly for no improvement in readability.

But to be clear, FM broadcast quality was not the objective.

The result was that the transmitter needed to be set for 2.4kHz deviation on a 1kHz tone at -12.4dBfs for broadcast content with RMS level of -18dBfs, ie the tone at a level of 5.6dB higher than the RMS level of the broadcast file.

I downloaded the current broadcast file, and levels have crept a bit, about 3dB higher than those I worked with 10 years ago.

Your proposal to use mp3gain to harmonise your various sources is a good one, and its advanced algorithms for setting loudness are a step forware on the work I did back then.

I have tried mp3gain on this week's WIA file and a few other speech type sources, and it seems using default settings to set the level such that RMS is about -22dBfs.

For level lineups, using my earlier experiments, you could try a 1kHz sine wave at -22+5.6=-16.4dBfs for 2.4kHz deviation. The test tone is easy to make digitally, and that deviation is easy to set using Bessel zeros if you have an SSB reciever, first carrier zero is at m=2.4,

With this setup, a typical FM land mobile transmitter will clip at around 5kHz deviation at 1kHz, so about 6dB above the set point, and about 12dB above the RMS level... so there is modest headroom, but not BC quality!

Owen
VK2OMD
Forum Diehard
 
Posts: 1063
Joined: Tue Oct 10, 2006 8:34 am

Re: Automating WIA Broadcasts

Postby VK7DB » Sun Apr 13, 2014 5:47 pm

Interesting comments Owen..

I have two test sets, so I think I will just use one of those to set levels :) I have only set it by ear at this stage, but it sounds good.. I did have a look on the deviation scope, and it looked pretty good there too.. It wont take a lot to generate the 1k tone and set it up your way, so I might try that and see what the results are..

Dion.
VK7DB
Frequent Poster
 
Posts: 142
Joined: Fri Mar 18, 2011 12:21 pm
Location: Stowport, Tasmania

Next

Return to Arduino, Picaxe, Raspberry Pi, and variants

Who is online

Users browsing this forum: No registered users and 1 guest

cron