Installing Rivendell on Ubuntu

Setting up an entire audio playout and automation system can take days of constant work, tweaking Windows boxes, fixing network shares… you name it. It doesn’t have to be like this.

Rivendell is fantastic for a number of reasons- but in addition to being a great bit of software, it’s a breeze to install. While the core developers mostly use SuSE Linux, many people prefer to stick with Ubuntu for all the benefits it brings. The documentation on setting Ubuntu up with Rivendell is a bit thin on the ground, though, so here’s a guide.

First, let’s pick our version. Ubuntu 10.10 has a fun bug in the kernel relating to realtime audio, so let’s avoid that. 10.04 is stable and doesn’t have the bug; 11.04 will be stable in a couple of months and also doesn’t have the bug. The following guide relates to 11.04, but should work fine on 10.04.

For this guide we’ll assume JACK is being used. Using JACK brings a number of benefits in terms of what you can do with routing audio and so on, and it’s mind-blowingly stable and completely seamless so there’s no real reason not to use it unless you’re trying to use the AudioScience HPI drivers.

First, grab the ISO from the Ubuntu website and make a CD or USB. Boot up, do a standard by-the-books Ubuntu install. Pick a sensible username (not rivendell) for your user account; at Insanity, we use insanity for all the machines, for example.

Next you’ll want to get the system entirely up to date and make a few changes to clear the ground before we crack on with installing Rivendell.

First, let’s get PulseAudio out of the way. Edit /etc/pulse/client.conf and look for the line that says ‘autospawn = false’. There’s a ; at the front of the line, indicating a comment- remove the ; and save the file. If you’re doing this on the command line I’d recommend the nano editor as a nice simple editor – ctrl+O to write a file to disk, ctrl+X to close. Just ‘sudo nano -w /etc/pulse/client.conf’ to open the file. This’ll stop PulseAudio from starting when you log in, so JACK can use the sound card. Note the use of the sudo command; on Ubuntu, to gain superuser privileges needed to edit some system files you need to prefix your editor’s command with this. We also use sudo to perform other superuser commands.

Next, let’s set up /etc/security/limits.conf to properly give people realtime permissions and such- open it up and add these lines:

@rivendell - rtprio 99
@rivendell - memlock 250000
@rivendell - nice -10

We’ll also want to make Rivendell’s run directory, used for storing process ID files.

sudo mkdir /var/run/rivendell
sudo chmod 777 /var/run/rivendell

Now we’ve got that out of the way let’s rock on and sort out our software. First, let’s make sure the basics are all up to date.

sudo apt-get update
sudo apt-get upgrade

And now we need to add the custom repositories. We’re going to add the Rivendell repository and the KXStudio PPA- the PPA gets us up-to-date versions of JACK and some audio tools. First let’s add that:

sudo apt-add-repository ppa:kxstudio-team

Onwards, then – open up /etc/apt/sources.list and add the Rivendell repository by adding these two lines at the bottom. Note you’ll want to change maverick to lucid if you’re on 10.04; keep it set to maverick for 11.04, as right now there’s no natty in that repository.

deb http://debian.tryphon.eu maverick main contrib
deb-src http://debian.tryphon.eu maverick main contrib

We also need to import the repository’s key to allow apt to verify the packages it receives.

wget -q -O - http://debian.tryphon.eu/release.asc | sudo apt-key add -

Now let’s update apt and install what we need. The second line here is stuff you really, really need, no matter what. The third line lists stuff you really, really want but might want to look twice at- if this is your only Rivendell box, you need mysql-server, but you can skip this on any other Rivendell boxes on the network since we’ll be using one server for all your clients. Polymer and qt3-qtconfig enable shiny buttons and is recommended. Patchage is a visual JACK connection browser and is a very handy thing to have around.

sudo apt-get update
sudo apt-get install rivendell jack screen samba
sudo apt-get install mysql-server polymer qt3-qtconfig patchage

At some point during the Rivendell installer it’ll ask if you want debconf to manage the configuration for you. Say no! We’ll do this manually for extra flexibility. Don’t worry, it’s easy.

You’ll also be prompted for a MySQL root password at some point if you’re installing the server – make it good and secure. You’ll need it in a moment.

In theory you can run JACK on startup and have everything run by initscripts and whatnot. I prefer to keep things in userspace, so here’s how I do it.

Make a rdscripts folder in your home folder – it’s nice to have a place for all the scripts you might want to use with Rivendell, and helps keep things organized. Open the file on_startup.sh and put in the following:

#!/bin/bash
service rivendell stop
sleep 5
screen -DmS jack jackd -dalsa -dhw:0 -r48000 -p256 -n3 -s &
sleep 5
service rivendell start

What this does is quite simple so I’ll explain it so you know! We’re stopping any running Rivendell services, starting up JACK using the ALSA backend and a 48kHz sample rate (plus a 256 sample period and a 3 period latency), and then starting Rivendell up again. We’re also starting JACK in a screen, so we can have a look at it while it runs and check that all is well – screen -x will attach your session, and ctrl+a+d will detach you again.

Just add this as a startup application under the user preferences menu. Make sure it’s executable by running

chmod +x on_startup.sh

Next is the only big configuration challenge – setting up /etc/rd.conf. Here’s mine, with passwords and such set to the defaults- we’ll go through it in a second. Open up nano or another editor and paste this in.

[Identity]
AudioOwner=insanity
AudioGroup=rivendell
[mySQL]
Hostname=127.0.0.1
Loginname=rduser
Password=letmein
Database=Rivendell
Driver=QMYSQL3
[Logs]
Facility=Syslog
[JackSession]
Source1=rivendell_0:playout_0L
Destination1=system:playback_1
Source2=rivendell_0:playout_0R
Destination2=system:playback_2
Source3=system:capture_1
Destination3=rivendell_0:record_0L
Source4=system:capture_2
Destination4=rivendell_0:record_0R
[Tuning]
UseRealtime=Yes
RealtimePriority=9
[Format]
SampleRate=48000
Channels=2

You’ll need to change the AudioOwner line to your username, but otherwise you can leave this pretty much alone. All the real configuration is done inside the RDAdmin app.

Now we’ve just got to do one last thing- adding our username to the rivendell and audio groups. This gives us permissions to use realtime priorities and lock up memory and so on. Note the backticks below rather than quotes – this ‘escapes’ the command and returns the result of running the command within the backticks. whoami is a command that returns the current user. You can ignore the backticks and whoami and just write your username.

sudo adduser `whoami` audio
sudo adduser `whoami` rivendell

And finally, reboot. When the system comes back up we can do ps faux in a console and should see the various Rivendell daemons like ripcd (interprocess communication), caed (core audio engine), and rdcatchd (RDCatch). You should also see mysql-server if you chose to install that, and a jackd process in a screen. Attach to the screen (screen -x) and check that JACK is happy and that it has no errors about realtime processing visible, and that there’s no xruns. Detach with Ctrl+a+d. If we open patchage we should see that the system’s sound card is linked to Rivendell directly.

One last thing – we want our Rivendell stuff to look snazzy and pretty. Let’s sort the fonts and skin out. Fire up qtconfig, and set it to use the Polymer skin, then File->Save. Next, run this:

sudo rm -rf /etc/fonts/conf.d/70-no-bitmaps.conf
sudo ln -s /etc/fonts/conf.avail/70-force-bitmaps.conf /etc/fonts/conf.d
sudo fc-cache -f -v

This will enable bitmap fonts and rebuild the font cache.

So, we’ve now got it all installed, but now we need to set it up. Run RDAdmin from the Sound and Video menu – it’ll ask you for a username and password for MySQL, so give it root as the username and your MySQL root password.

From here you can follow any of the many guides on the Rivendell wiki. If you’re anxious to get started, though, fire up RDAirPlay, press ADD, select the test tone, and then put it onto the log, and hit start. Congratulations – you’ve just made audio with Rivendell!

Next Steps

Of course, you’ll now want to put multiple Rivendell boxes on your network. This is actually really simple. You just need to configure a Samba server on the master, enable remote logins on MySQL from other hosts on your master, and install the other machines with exactly the same configuration except for the master’s IP in rd.conf and a Samba client mounting the audio data on the slaves. Easy! The rest’s done in RDAdmin.

Setting up remote MySQL access is kind of simple – first, edit /etc/mysql/my.cnf and change the bind-address from 127.0.0.1 to 0.0.0.0 to have it bind to external IPs as well as localhost. Then restart it:

sudo service mysql restart

One last thing remains, though – when Rivendell sets up it’s own user, it sets it to explicitly be used only from localhost. We need to set up an account that can be remotely used. Open up a MySQL console with ‘mysql -uroot -p’, and enter your root password when prompted.

CREATE USER 'rduser'@'%' IDENTIFIED BY 'letmein';
GRANT ALL PRIVILEGES ON *.* TO 'rduser'@'%' WITH GRANT OPTION;

On your master, you need to define a Samba share for the sound directory- open /etc/samba/smb.conf and add this to the end.

[snd]
comment = Rivendell audio data
read only = no
locking = no
guest ok = yes
path = /var/snd
browseable = yes

Now reboot Samba:

sudo service smbd restart

We’ve now got the whole directory shared for all and sundry on any networks that can see that box and port. Bear this in mind when setting up firewalls.

So, on your slaves you’d put this in /etc/fstab (all on one line!):

//ip.address.of.master/snd         /var/snd             \
cifs    noatime,password=guest,username=guest   0       0

You can now mount that share with ‘mount /var/snd’ and get the master’s audio as if it were locally stored.

All you need to do now is edit /etc/rd.conf and set the Hostname to your master’s IP address. Then start the slave’s Rivendell services and you should be in business. You then need to add the host in RDAdmin -> Manage Hosts. Make sure you use the actual hostname as given by running ‘hostname’ on the slave.

You’ll also want to set up a time server for your network, with everything synchronized off the same host. This is actually pretty trivial – on all the machines, install ntpd:

sudo apt-get install ntp

By default, the servers configured in /etc/ntp.conf are generic Ubuntu time servers. You ideally want a radio clock on your master, but at least want to be consistent internally with your master, so let’s set up the master to use some local good quality time servers and have the slaves use that for synchronization. In the master’s config file let’s set up peering and some good servers. Below I’ve used the UK pool of NTP servers; try ‘netselect -s 3 pool.ntp.org’ to pick some servers.

server 0.uk.pool.ntp.org iburst
server 1.uk.pool.ntp.org iburst
server 2.uk.pool.ntp.org iburst
# Below is an example network we're allowing.
restrict 134.219.53.0 mask 255.255.252.0 nomodify nopeer notrap

Then on our slaves, just specify the timeserver as the only server:

server ntp.insanityradio.com iburst

At this point you can check how the servers are doing time-wise with ‘ntpq -p’.

Congratulations, you’ve now got a complete radio automation system with all the bells and whistles and you’ve paid nothing for it but the hardware you’re running it on!