4. Installing AirPRO 2.21 with Jack audio support.

Installing AirPRO 2.21

These instructions will allow you to install AirPro 2.21 on Linux Mint 19 64bit (tested using our Linux Mint 19 XFCE 64bit install detailed elsewhere on this site).

These instructions assume you're logged in as user "broadcast" (without quotes) as documented in our Linux build notes. If this is not the case then we recommend you create and use that username to avoid having to modify these notes.

Install required dependencies:

Open a terminal and run:

sudo apt-get -y install build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libaudio-dev libcilkrts5 libcups2-dev libcupsfilters-dev libcupsimage2-dev libdrm-dev libexpat1-dev libfakeroot libfontconfig1-dev libfreetype6-dev libgcc-7-dev libgl1-mesa-dev libgles1 libglu1-mesa-dev libglvnd-core-dev libglvnd-dev libice-dev libiodbc2 libitm1 libjbig-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev liblcms2-dev liblsan0 liblzma-dev libmng-dev libmng2 libmpx2 libmysqlclient20 libopengl0 libpq5 libpthread-stubs0-dev libquadmath0 libsm-dev libstdc++-7-dev libtiff-dev libtiff5-dev libtiffxx5 libtsan0 libubsan0 libx11-dev libx11-doc libx11-xcb-dev libxau-dev libxcb-dri2-0-dev libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb1-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxmu-dev libxmu-headers libxrandr-dev libxrender-dev libxshmfence-dev libxt-dev libxxf86vm-dev make mesa-common-dev pkg-config x11proto-core-dev x11proto-damage-dev x11proto-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev x11proto-input-dev x11proto-randr-dev x11proto-xext-dev x11proto-xf86vidmode-dev x11proto-xinerama-dev xorg-sgml-doctools xtrans-dev libflac++6v5 libid3-3.8.3v5 sox lame libsox-fmt-all docbook5*

Install and configure the MySQL server:

sudo apt-get -y install apache2 mysql-server

sudo mysql_secure_installation
When prompted, select "N" to "VALIDATE PASSWORD PLUGIN".
Set a password.
Remove anonymous: Y
Disallow root login remotely: N
Remove test database: Y
Reload tables: Y

Fix root MySQL login issues (change from socket to password auth):

sudo mysql -uroot -p
(enter the password you set above)

SELECT User,Host FROM mysql.user;
DROP USER 'root'@'localhost';

ALTER USER 'root'@'%' IDENTIFIED BY 'yourpassword';

Turn off MySQL strict mode to avoid database errors:
sudo vi /etc/mysql/conf.d/disable_strict_mode.cnf
Paste in:

We need some old libraries that are in 16.04 but not 18.04 so we need to add them:
sudo vi /etc/apt/sources.list
Paste in:
deb http://security.ubuntu.com/ubuntu xenial-security main
deb-src http://security.ubuntu.com/ubuntu xenial-security main

sudo apt-get update
sudo apt-get -y install libpng12-0 libpng12-dev libmng2

Install QT3 and HPI support:
Note: Credit for this pre-compiled QT3 and HPI support belongs to Luigino Bracci.

Download the .deb tarball to the Downloads directory:
Click here to download the QT3 and HPI support file.

cd /tmp
tar -zxvf /home/broadcast/Downloads/qt3-for-1804.tar.gz
sudo dpkg -i qt3/*.deb
sudo dpkg -i hpi/*.deb

Setup JACK audio:

sudo apt-get -y install jack screen samba patchage vlc-plugin-jack jackd libcdparanoia-dev libflac++-dev libsamplerate0-dev libid3tag0-dev libid3-3.8.3-dev libcurl4-gnutls-dev libsndfile-dev libpam0g-dev libsoundtouch1-dev libasound2-dev libtwolame-dev libmp3lame-dev libmp4v2-dev libfaad-dev libmad0-dev libjack-jackd2-dev libice-dev libsm-dev libxt-dev libxi-dev libssl-dev build-essential libx11-dev libxext-dev xsltproc evince

Do not enable "realtime" if prompted.

Make JACK run on login:
mkdir rdscripts
cd rdscripts
vi on_startup.sh

Paste in the following:
screen -DmS jack jackd -dalsa -dhw:0 -r48000 -p1024 -n3 -s &
The -dhw:0 line above may need to be changed to your primary sound adaptor number (for example if your machine has both digial and analogue audio or multiple adaptors).
aplay -l and aplay -L will show these.

The sample rate is set to 48000 in the script above.
You might choose to change this to 44100 if you have an existing database using that.
When creating a new database 48000 is recommended for maximum compatibility with hardware and digital broadcasting standards.

chmod +x on_startup.sh

Make the script run at login:
On the Linux desktop, run "Session and Startup".
Click "Application Autostart". Click "Add":
Name: Broadcast Startup
Path: /home/broadcast/rdscripts/on_startup.sh
Add and Close.

Begin the actual AirPRO build and install

Download the source code to the Downloads folder:

cd ~/Downloads
wget http://www.readyformed.com/download/rd.tar.gz
wget http://www.readyformed.com/download/airpro-2.21.zip

Unzip and compile the source:

tar -zxvf /home/broadcast/Downloads/rd.tar.gz
mv rivendell-2.19.3 airpro-2.21
cd airpro-2.21
unzip -o /home/broadcast/Downloads/airpro-2.21.zip
./configure --disable-docbook --libexecdir=/usr/local/libexec

Note: This can take some time. Anywhere from 5 to 60 mins depending on the speed of your machine. Ignore any minor "warning" messages. They're normal and are not a cause for concern as long as it does not end with an error message.

Now install the files:

sudo make install

Stop the RDmonitor running at boot (not used in this configuration):
sudo rm /etc/X11/xinit/xinitrc.d/start-rdmonitor.sh

sudo addgroup rivendell
sudo adduser broadcast rivendell
sudo adduser broadcast audio
sudo adduser broadcast www-data

Configure Apache:

vi ~/airpro-2.21/conf/rd-bin.conf
Around line 24 you will see:
  Options ExecCGI FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
Delete these two lines:
  Order allow,deny
  Allow from all
...and replace with the new way of doing things:
  Require all granted
sudo cp ~/airpro-2.21/conf/rd-bin.conf /etc/apache2/sites-available/

Now make the site active:
sudo a2ensite rd-bin
sudo service apache2 reload

We also need to enable the CGI module otherwise your audio won't import
(because CGI is now disabled by default):
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
sudo service apache2 restart
sudo a2enmod cgi
sudo service apache2 restart

Creating /var/snd:
sudo mkdir -p /var/snd
sudo chown broadcast:broadcast /var/snd
sudo chmod ug+rwx /var/snd

sudo rdcleandirs

cd /usr/local/bin
sudo chmod -s caed ripcd rdcatchd
sudo chmod 777 /var/run/rivendell
sudo chown broadcast /var/run/rivendell

Note: For some reason Mint and Ubuntu delete the /var/run enteries on boot.
Therefore we need a systemd script to fix this.

sudo vi /etc/systemd/system/rivendell-helper.service
Paste into the empty file everything between the two ### lines:
Description=Rivendell Helper Service

ExecStartPre=-/bin/mkdir /var/run/rivendell
ExecStart=/bin/chown broadcast:broadcast /var/run/rivendell

sudo systemctl start rivendell-helper
sudo systemctl status rivendell-helper

sudo systemctl enable rivendell-helper

The services (caed etc) will now run automatically when an application is run.

Some MySQL tweaks:
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
In the mysqld section (under [mysqld] at around line 31) add the following line:
default_storage_engine = MyISAM
Also change bind-address to

sudo service mysql restart

sudo rdalsaconfig
Ensure no sound cards are set as active or JACK won't work.

sudo cp ~/airpro-2.21/conf/rd.conf-sample /etc/rd.conf

Configure the system:
sudo vi /etc/rd.conf





Add the following section to the end of the file:

Create the logs folder:
mkdir rdlogs

Run RDadmin to create the inital database.
You will be prompted for the SQL username (root) and password the first time this is run.
Once it complete it will prompt to login. The username is admin and the password is blank.

IMPORTANT: In RDadmin click "System Settings" and set the sample rate
to match the JACK config above (48000 in the example above).

(Rebooting at this stage is important.)

The system is now ready to use.

We can now make some cosmetic improvements to Rivendell:

Make the Rivendell interface look a bit nicer:
sudo qtconfig-qt3
Select GUI Style: CDE
Tune Palette:
Active Palette\ Tune Palette\ Background\ Select Color\ Change 239.239.239 to 180.180.180
Active Palette\ Tune Palette\ Forground\ Select Color\ Change 0.0.0 to 32.32.32
Active Palette\ Tune Palette\ Button\ Select Color\ Change 221.223.228 to 181.183.188
Active Palette\ Tune Palette\ Base\ Select Color\ Change 255.255.255 to 255.255.255
Active Palette\ Tune Palette\ Text\ Select Color\ Change to 0.0.0
Active Palette\ Tune Palette\ BrightText\ Select Color\ Change to 140.140.140
Close and save the settings.

Run RDadmin:
Click "Manage Hosts" and double click on the current hostname.
Click "RDairplay".
Click "Display Settings", "Background Image".
Select: /home/broadcast/wallpapers/pixmap-background/rdairplay_skin.png.
Click "Ok" and close all the windows.

On dedicated playout machines, the volume control can be removed from the taskbar as it's now not functional: Right click on Panel / Panel preferences: Remove the Pulseaudio volume control.

Additional Notes:

"patchage" can be used to check JACK patching.

To adjust the system volume if it's too quiet or loud, run "alsamixer" from a terminal.
Ensure the "Master" output on the soundcard is enabled if no audio.

Troubleshooting JACK.
Both JACK and Rivendell must run as the same user. If there are issues this can be checked with:
ps -C caed -C jackd -o pid,user,group,cmd

For a studio playout system, set the screen resolution of the RDairplay window to 1024x768.
This can be done by running the "Display" utility.
This will ensure RDairplay fills the screen.

Modification to allow JACK and Pulse audio at the same time!

The Rivendell setup above takes full control of the system audio via JACK, so sounds from other applications should not by default be broadcast. This is desired in a radio environment.

However for home or production use you might need to have other applications on the system provide audio. To allow this you can install the Pulse to JACK audio bridge as follows:

sudo apt-get install pulseaudio-module-jack
sudo vi /etc/pulse/default.pa
Add the following lines, underneath the #'ed out line that says #load-module module-alsa-sink
load-module module-jack-sink
load-module module-jack-source

Ensure Pulseaudio is disabled at startup (if not done already):
sudo vi /etc/pulse/client.conf
(uncomment the autospawn=yes line, and set it to no)

Make Pulseaudio start AFTER Jack:
cd rdscripts
vi on_startup.sh
Add as last lines in file:
sleep 5
pulseaudio &


Install some apps known to work well with this configuration:
sudo apt-get install linphone chromium-browser

Once installed you can do some other cool things using the "patchage" utility, such as connecting the output of non-JACK desktop apps to the JACK input of Audacity to allow their audio to be directly recorded, or you can connect Rivendell to Pulse, allowing the use of cleanfeed.net in the Chromium browser so remote users can hear real-time high quality audio for remote voicetracking.