Line them up

Radio Auto-asaad earns its name only if it’s (very) autonomous in what it does. But wait a minute! Radio stations have been boys on the block for over a century years now. Haven’t this problem solved already? As you expect, the answer is yes. In fact there are solutions out there, to which Radio Auto-asaad isn’t even qualified for side-by-side comparison. But do I afford them?

Putting commercial software aside, there are freeware platforms for this purpose too. Radionomy is one of them which I only recently learned about (I know I did my homework late but TBH I become very excited to see that their terminology is similar to our ubiquitous language and this is a good sign that I am heading the right direction). My problem with such platforms is that they don’t give me the flexibility I need. I am bound to their web GUI, their policies for content publishing and their design limits for the specific use-cases I am planning for (such as PreShows). I need something more flexible and extensible and since nobody did that before, I will carry this burden myself!

Before I move into details, I need to point out that there are parts of the problem that are solved already and I didn’t reinvent those wheels. Icecast is a broadcast server that receives a stream and serves it to listeners while providing necessary reporting and control over the distribution. Liquidsoap is a open-source yet powerful tool to build streams. Its DSL language give you power to define several source streams, mix them, transition between them and manage them. If Radio Auto-asaad was a bit simpler (see below), one could write it completely in Liquidsoap.

It should be clear by now that RAA integrates with Liquidsoap and uses it directly in order to playback media files and convert them to scripts. However, it’s worthy to state what you cannot do in Liquidsoap (and hence what justifies adding another level of complication). Here is a list:

  • You cannot schedule programs for arbitrary times during the day.
  • Changing the order of scheduled boxes requires changing the code.
  • Except for the song metadata (which will be published by Icecast), you have no other means of communicating with the clients.
  • I have a fairly complicated scenario for replaying programs that are very hard (if not impossible to implement in Liquidsoap scripts.
  • A clear separation between managing the underlying streams and program planning will make it easier for non-technical people manage content without fear of breaking serious stuff.

Lineup Management in RAA

Having all this said, let’s now cover the lineup management process in Radio Auto-asaad. Fig. 1 illustrates the lineup generation flow.

Figure 1. The journey of a program in RAA's lineup manager
Figure 1. The journey of a program in RAA's lineup manager

Each stage in the figure above is represented by a JSON file. We have a single lineup template file for the whole radio and one planned and compiled lineups per day. Let’s take a look at each level with more details:

  • Lineup template: Programs usually follow a regular weekly schedule for playback. They start at specific times of specific days and new episodes of the program should be aired each time. Lineup templates are the most abstract way of specifying programs (and how to select episodes) in RAA.

  • Planned lineup: Every day, raa.js script wakes up, reads the template and plans programs based on the conditions provided. It puts together program boxes and add programs to them based on the day of the week and other criteria. The planning step also specifies a playback starting time for each box.

  • Compiled lineup: Having the lineup of programs, the lineup compilation stage examines all the files listed for playback, ensures their existence and duration and calculates exact start time and end time for each program. During compilation, we also make sure that programs do not overlap and reject the lineup if these criteria is not met. Finally, compiled lineup is scheduled for playback.

In case you are scratching your head, asking what is the purpose of lineup planning stage and what problem does it solve, I have just the thought to share with you! I said before that programs are usually on a periodical weekly schedule but this is not always the case. What should we do if we want to add a one-time special program to the lineup or how should we manage cases where we want to change parts of todays lineup but isolate the change to the current day only? To address this issue, RAA’s lineup manager watches the planned lineup file for changes and recompiles it when it is modified (without planning from template). This way, radio admins can easily modify the lineup file and fine-tune it.

Also note that when the time of playback for a program comes (and the scheduled job triggers), it calls a tiny script that finds the appropriate clips and push them into Liquidsoap’s playback queue.

OK! So far we successfully created a radio broadcast with minimal features and very low CPU and memory footprint. There are no services, web containers and databases that keeps our maintenance cheap and simple. But how long can we hold this promise? Only time can tell :-)

- Back -