Personal tools

How to trigger events from tones on your network

From Rivendell Wiki

Revision as of 16:04, 21 February 2018 by Higgles (Talk | contribs) (Created page with "== The Problem == Our network, EWTN, uses in-band tones to trigger local breaks and rejoins. A 25 Hz tone signals the start of a local break, and a 35 Hz tone signals the sta...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Problem

Our network, EWTN, uses in-band tones to trigger local breaks and rejoins. A 25 Hz tone signals the start of a local break, and a 35 Hz tone signals the start or resumption of a program.

Most stations use some sort of hardware tone detector to trigger a relay closure, which signals the automation to act accordingly. Conex Electro-Systems and Circuitwerkes are two manufacturers that offer these detectors.

I prefer not to buy something if I can build it. So I set out to solve the problem through software.

The Solution

Our group's first station runs a Windows-based automation. For tone detection on that system I employed a neat little program from NCH Software in Australia called ToneDet. ToneDet listens to the audio input of your choice and fires an .exe or .bat file when it senses a tone of the right frequency, level and duration. It can listen for multiple frequencies, so you can have one program or script that fires for a 25 Hz tone, and different one for a 35 Hz tone. In the Windows environment it's proven to be very dependable.

For our newest station I chose Rivendell as the automation system, which means running Linux not Windows. I searched for a program like ToneDet which could run under Linux. I found three types of apps that came close: tone detectors for communication use (CTCSS, DTMF, etc), audio spectrum plotters, and musical instrument tuners. With enough time and ability I could have massaged the source code of one of those programs to produce a Linux equivalent to ToneDet.

Unfortunately time and ability (for writing C source code) are two things I am short on. Frustrated and out of options, I turned to Wine.

Don't worry -- I don't have a drinking problem. Wine is an open-source project that lets you run Windows programs under other operating systems, particularly Linux.

You install Wine like any other Linux package, and it associates itself with any .exe files on your system the same way OpenOffice associates itself with .doc files. When you start an .exe file on your Linux system, Wine automatically launches and creates an environment that makes the .exe act just as if it was on a Windows box.

So I installed Wine and ToneDet on my system and set about making them work with Rivendell.

How It Works (so far)

  • Using the RRAbuntu distro, Wine and ToneDet install flawlessly.
  • Audio input is a challenge. I cannot get ToneDet to work with Jack. If I select Jack as the audio system in wineconfig, ToneDet will crash, if not immediately then after a few seconds.
  • I activated the motherboard's built-in sound card to use with ToneDet. The system uses an M-Audio Delta44 sound card for broadcast audio, but I could not sort out a way to have Wine use it alongside Rivendell.
  • I changed the ALSA configuration to always load the M-Audio card as hw:1 and the builtin ATI system as hw:0.
  • Using the motherboard's sound card, fed by a line output from our satellite box ToneDet shows good audio levels but tone detection was spotty at first. It was set to detect 25 Hz tones but seemed to be detecting 35 Hz tones instead. Using Audacity I figured out that the ATI card's sample rate was 50% fast! This may account for the problems with Jack noted above.
  • I compensated by setting ToneDet to trigger on 16 Hz (25 divided by 1.5). Shazam! It works reliably now.
  • When a tone is detected, ToneDet calls rmlsend --from-file=25Hz.rml on the Linux side. (A Windows program running in Wine can call a Linux program).
  • As a safeguard against false triggering, the file 25Hz.rml is usually empty. Just before a scheduled break, Rivendell executes a macro cart that "arms" the system with echo>25Hz.rml PN\ 1\! The second command in each break event (after the one that turns off the network audio) "safes" the tone system again with echo>25hz.rml.

Still To Do

  • Figure out why the onboard ATI sound card is sampling at 66000 samples/sec when I tell it to sample at 44100.
  • See if that resolves the problem with Jack.
  • Ultimately replace this with a native Linux application.