IRN Switching – The Weird Way

It’s approaching the top of the hour. Your jock has padded out their last link as much as possible to hit the news on time. The jingle fires and IRN goes out on time. It sounds neat when it’s done correctly. However, doing it in automation is a bit of a pain.

The problem is how to route the IRN feed to air for the two minutes every hour. I’ve seen all sort of approaches ranging from flying faders and automated routing to piping it through a soundcard on a timer. The later of these was supposed to be the approach when I was a presenter on a small commercial radio station. Except… the weekend automation hadn’t been setup correctly and I had to resort to taking it manually. That’s the joys of being in the now defunct station’s opening line-up.

However, none of these approaches quite match what we’re working with at one volunteer station. The station audio router is a 12-way Alice OS switch. Yup, clunking great physical buttons with no automated control. Well, unless we built a robot of some sort to push them for us.

On top of that, we only want the feed to go out during our automated output. It’s that or keep interrupting live sport (sports teams don’t take well to this and actually question why we bother with news at all).

For that reason, we’re doing a playout controlled mix. Now we would do this with soundcards and even toyed with the idea timeshifting to allow the song to end before going to the bulletin. However, as the previous post alluded to, it’s been a right pain getting the soundcards to work.

So, out with the software and in with the Raspberry Pi and a modified Alice Mixpak. We’ve actually cracked out a soldering iron and put a four pole relay across the first pair of inputs on the Mixpak. With a transistor in the circuit and tapping off the +15V line in the Mixpak, we can switch the input on and off with a little bit of voltage.

If you can’t picture what we’re doing here, check out It’s got the original diagrams we worked from.

That said, I would show you the guts of this but it’s not very neat. Well, that and it’s now live and I forgot to take a photo. On top of that, my soldering skills are pretty poor.

What I can tell you about though, is wiring and configuring the Pi. On the Pi we connect GPIO 17 to our transistor and join the grounds together. However, a word of warning. The Pi doesn’t have much in the way of circuit protection on the GPIOs. Do it wrong and you could fry it.

Despite that dire warning, if you’ve got this far, you’re ready for the software side of things. We start by installing Raspbian on the Pi. So long as you set a sensible password for the pi user and enable SSH, it should be enough to get us going.

We now want to create a file called /home/pi/ with the following contents:


use IO::Socket;

# Script-wide variables

$port = 5050;
$gpio = 17;
$MAX_LENGTH = 1024;

# Setup the basics

system("echo \"${gpio}\" > /sys/class/gpio/export");
system("echo \"out\" > /sys/class/gpio/gpio17/direction");

# Setup the UDP socket and wait

$server = IO::Socket::INET->new(LocalPort=>$port, Proto=>"udp") or die "Failed to create a socket on port $port. The error $@";
while ($server->recv($action, $MAX_LENGTH)) {

        # Check the input

        if (index($action, 'ON') != -1) {

                system("echo \"1\" > /sys/class/gpio/gpio${gpio}/value");
                print "IRN ON\n"

        } elsif (index($action, 'OFF') != -1) {

                system("echo \"0\" > /sys/class/gpio/gpio${gpio}/value");
                print "IRN OFF\n"



The script doesn’t do anything too clever. It prepare GPIO 17 to be an output pin then toggles it as UDP packets come in on port 5050.

Specifically, we’re looking for the values “on” or “off” in the packet before we toggle. These packets in turn are generated by Rivendell as and when we need to switch. The benefit of doing it this way (as opposed to using timers) is the ability to be flexible with things like the Queen’s speech.

The final step is to configure the script to launch on boot. We do that by adding the following to the /etc/rc.local file:

/home/pi/ &

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: