Category Archives: ALSA

Jack2 Audio Connection Kit

Jack2 is the connector for audio within and between computers.  It connects your audio soundcard to the guts of your computer using a simple to visualize jackfield, where you connect audio paths from one output to any number of inputs.  You can also connect several computers’ audio together over ethernet!  It is available for Linux (Ubuntu Studio), MacOS, and Windows!  It does not know multi-channel audio natively, so you have to hook up the left and the right ‘cables’ independently.

Jack Logo

 

 

My first exposure to Jack was back in Ubuntu 10.04 where I installed it manually in a system that had ALSA (Advanced Linux Sound Architecture) and an early version of Pulseaudio  installed.  It drove me crazy, no audio or audio that had dropouts.  Dozens of settings poorly documented.  AARRRRGH!

9/2019  Update:    Ubuntu 18.04 runs jacks quite nicely without problem when set up by KXStudio   (See Article)

No longer! Ubuntu Studio comes with Jack2 already installed so all that grief is mostly behind you.  Many web sources tell you to get rid of Pulseaudio, but the case is not so compelling as it once was, but if low latency or several sound cards are in your plan, dump it.  Check out my article “Use Pulseaudio with Jack Audio Connection Kit?”

You should have your final soundcard(s) installed when you install Ubuntu-Studio so that it can pick up the cards automatically.  Jack comes with a little utility called qjackctl that lets you set all the necessary configuration that lets you correct much of what might not work right away.  KXStudio cadence application (See below) is much prettier, and shows status in a much more easy to understand way and hooks up plugins and other features that I didn’t figure out Cadence’s tools are more robust than qjackctl, although it has no internal provision for saving patches in a patchbay.   No audio can usually be fixed with a command line utility called alsamixer because some sound card drivers set the volume to “0” not “11”.

There are packages from a site called KXStudio that make using Jack2 on Linux beautiful.  If you dive into KXStudio, you will not need  most of the Jack2 utilities like Patchage, qjackctl, etc.  I will have a script on this site soon that automates installing all these Uber Cool features.

Once you can hook up an audio editor like Audacity to the audio outputs and connect a parametric equalizer to the microphone inputs and the equalizer to Audacity inputs, along a  Jack meterbridge or spectrum analyzer you can see the power of this system. Jack can hook up Lapsda and .vst plugins for a multitude of effects.

 

NetJack is a way to hook up several computers’ audio  together via ethernet with one master computer connecting to another, or several others.  This can work over a typical quiet office network, but the NetJack audio should be on its own network with no competing uses of the bandwidth.  If there is too much audio flying around even a 1 GB network can get overloaded.

There are more convenient and higher fidelity options than NetJack, Such as Zita-NJBridge  the included zita-j2n and zita-n2j open audio ports to other jack instances on other networked computers.

So, the possibility of shipping audio around between workstations and a server is pretty easy, getting rid of lots of conventional cabling, and removing hundreds or thousands of places where the audio can get degraded.

One of the trickiest parts of Jack2 is making persistent setups and patchbay configurations that can automatically re-appear upon reboot or relogin, and understanding the relationships between applications started by different users and different sessions.  There is no standard command line tags for jack naming, and automatic jack connecting.  Auto-connecting a program’s output generally takes the form of

-<port tag>  Jack_Device_name:Jack_port_name

On some programs the Jack_Port_Name can be a regex, sometimes a complete name, or sometimes a port name less the variable part.  You have to play with the program to figure it out.

 


Use PulseAudio with Jack Audio Connection Kit?

Ubuntu Studio 14.04 uses Pulseaudio -> Alsa -> Jack as the connection interface for audio devices.  Pulseaudio is a very simple interface, and with it most audio cards just “show up” and play with Jack as the pulseaudio-sink and pulseaudio-source devices on the Jack patchbay.

In the olden days (Ubuntu Studio 10.04 and before) Pulseaudio was  buggy and not worth the effort to deal with the bugs.  Pulseaudio is now much more mature, and for a single sound card machine makes it much more likely that you will have Jack working right away.  If you are using Debian or regular Ubuntu, you will need a Pulseaudio plugin to hook it up with Jack.  I have not used the plugin as it is all nicely done in Ubuntu Studio.

Alsa is perfectly capable of connecting sound cards to Jack, with infinitely more flexibility, and (unfortunately) with more complexity.  Remember to turn the volume controls up in alsamixer!

There still remain some reasons to dump Pulseaudio:

  • Pulseaudio adds a fair amount of latency in the link between the sound cards and Jack  If you are just recording and playing back stuff and “real time” audio is not important, this might be insignificant, but for sound reinforcement and broadcasting, it is a serious consideration.
  • Pulseaudio works best with a single sound card – if you have an in-computer card and a USB card and want to use both, Pulseaudio is complicated at least and may not let you use the second card. (I have not been successful, but I didn’t try very hard)
  • Pulseaudio devices want to hook up to stuff in the patchbay, and I have not figured how to keep them from automatically doing so.
  • Pulseaudio and Rivendell get in the way of each other.  Rivendell wants to have multiple audio inputs and multiple outputs, and that can be a problem with Pulseaudio if they are on different cards.  (Newer versions of Rivendell connect to jack2 very nicely.
  • Pulseaudio devices Pulseaudio-sink and Pulseaudio-source hide the names of the actual sound devices, so they can be confusing when patching.
  • Pulseaudio hides and plays with some sound card settings in Alsa, so special configurations might just get reset to the defaults at next boot.

The reasons to keep Pulseaudio:

  • Alsa can be tricky to get all your audio devices working right unless you are happy to use the command line.
  • Ubuntu Studio comes with Pulseaudio installed and working, and dumping it can cause your installation to stop working until you figure out what Alsa settings for your sound card are undone.
  • There are some tricks to getting Pulseaudio to uninstall or to disable it. (It keeps coming back) (disabling works well on Ubuntu 18.04)
  • Pulseaudio now keeps a simple setup simple (except for those crazy patchbay devices)
  • Removing pulseaudio has limitations because some applications (ex Firefox) insist on only using pulseaudio and getting them to work with jack if pulseaudio is defeated or uninstalled may be impossible.

Assuming you want to simply disable Pulseaudio, here is what you do:  (Preferred if you are not in a storage limited environment)

  1.   Make a backup of the configuration file –
    sudo cp /etc/pulse/client.conf  /etc/pulse/client.conf.ORIG
  2.  Run the following command to edit the configuration file:
  3.   sudo sed  s/; autospawn = yes/autospawn = no/ /etc/pulseaudio/client.conf
  4. Install package alsa-tools
    sudo apt-get -y install alsa-tools
  5. and reboot.

Assuming you want to remove Pulseaudio, here is what you do:

From hecticgeek.com:

1. First let’s remove PulseAudio from your Ubuntu OS. I don’t remember since when Ubuntu used to come installed it by default, but for the recent versions such as: 12.04 Precise Pangolin, 11.10 Oneiric Ocelot, 11.04 Natty Narwhal, 10.10 and 10.04 the below command should remove it.

sudo apt-get -y remove pulseaudio

2. Now do a reboot since PulseAudio daemon (system service) is also running from the background. So it’s better to let the OS update everything.

3. You need the package alsa-tools, but that is already installed in Ubuntu-Studio, but not in regular Ubuntu.

4.  The script I will be publishing later will do this all automagically.

If you just want to just disable PulseAudio, you can edit the config file

1.   Copy /etc/pulseaudio/client.conf for a backup

sudo cp /etc/pulseaudio/client.conf /etc/pulseaudio/client.conf.orig

2.  Modify /etc/pulse/client.conf  the line   ; autospawn = yes to autospawn=np

sudo sed  s/; autospawn = yes/autospawn = no/ /etc/pulseaudio/client.conf

3.  Reboot or kill the pulseaudio job.


Hardware for Audio – Server and Workstation

The Playout Station

A Rivendell playout (Radio automation) box with with Jack2 and zita–njbridge can be incredibly simple thanks to edgeradio 99.3 FM in Hobart, Tasmania, Australia.  A raspberry pi 3B+ or raspberry pi 4 with the raspberrian sd card and a good two channel or  four channel sound USB interface or an Octo 8 sound card hat from audio injector.   You will need a robust power supply, preferably battery backed with shutdown.  The raspberry pi Rivendell Playout can be used as a full automation system when attached to a server containing an NFS media store and a MySQL (Mariadb) database.   Alternately, it can be a stand alone playout for advertisments and liners on a hyper-local station or feed that takes its main programming from a network or service.  It is well suited for a station that stitches together podcasts and other programming that does not require large storage. The raspberry pi has no real time clock, so it is important to set up ntp (see Raspberry Pi -Rivendell post ) to a local server to acquire correct time quickly.  The Raspberry PI doesn’t have a good audio output, so it is necessary to add a hat or USB sound device.

If you need Rivendell to do more than a simple automation, but want to add audio processing, virtual console, etc., you should use should use a reliable  PC with a motherboard with an X64 processor  with two to four cores, Several Gigs (4+?) of Memory, and if it is to be used with a server for audio storage and database, you only  need 120 Gigs of SSD.     In a playout or editing environment, an SSD is important for fast boot, low noise  and fast loading of applications. The $50 a little SSD costs is well worth it.  An additional hard drive is useful to keep keep work files in the /home folder.  If you have a good server, you don’t need a big hard drive for the workstations unless you want to duplicate the library and database on the workstation (this is tricky because they need to be kept synced) and you would need to write a script to make the switchover quickly.

If you work with a server, you need a good quality Gigabit network card which you will set up for static addressing.

You need a good sound card fully rated for ALSA compatibility.  I have used PCI (PCI and PCIe cards don’t work with the PI) and USB  M-Audio hardware with good results, particularly the Delta 1010 cards and the all of the 17xx cards work well too.  Ubuntu studio 20.04 has also learned to play nice with M-Audio Fast Track 8R USB rack mounted box. (earlier versions did not), as well as nearly every other USB quality sound card from Beringer, Presonus, M-audio.  Pick ones that have balanced input and output and quality microphone amplifiers (If you have mikes)  Rivendell loves the Audio Sciences cards in PC computers, but they are pricey.

If the workstation computer is physically in the studio, you also want one with high volume LOW NOISE fans. This is where the Raspberry PI shines.  The little fan to cool a PI can be very quiet.   Bigger PC cabinets seem to have quieter fans than micro cases because they use larger 120 mm fans that move more air with slower blades. Use a good quality power supply and UPS.  The UPS should be connected to the computer USB  port and setup with USB drivers for that brand for graceful shutdown when the power goes out, and stays out.

The current version of Rivendell playout has a fixed window size so don’t go crazy on monitor resolution or the control window will be too small.  (I have heard that this is likely to change in the next major revision).   Your video card does not need to be anything special, motherboard cards work fine.  rdAirplay will work with a touchscreen, and there are many that work with Ubuntu, but not all.  Your touchscreen mileage may vary.  You are looking for high reliability, not blazing performance. Do not overclock.

Rivendell works with audio switchers such as the Broadcast Tools SS 8.2, and with digital IO cards that talk by RS-232 serial ports.  It would be nice if the motherboard had an RS-232 port, but a high quality USB-RS-232 converter will work.  There are cheap converters that are tricky to make work because they need a special driver that might not be available in Linux.  The machines that will be running RdCatch and RdAirplay will need this if you need these outputs to switch satellite receivers and such.  (You may be able to avoid audio switches if you have enough inputs and outputs on your soundcard when running Jack2.)  Rivendell macros can run jack_connect and jack_disconnect commands.

I am looking for a suitable case for the Pi with the Octo

The Server

A server for Rivendell should have excellent computing  performance to the workstation, and should have six or more cores on an X64 chip, with eight or more gigs of memory.  Hard drives should start with a 128 Gig SSD for the operating system, and at least 2 TB of high quality raid hard drives to use in ZFS ‘raid’ mode for audio and database.  The new ZFS file system for the large raid drives allows for flexible organization of the data volumes.  ZFS data compression on a fast machine will both increase the hard drive capacity and speed.

You should have two or three Gigabyte Ethernet ports on this machine.

It theoretically could be a “headless” machine, but some of the audio applications just really need GUI interfaces.  Sharing a monitor, mouse and keyboard with a KVM switch (Don’t confuse with KVM virtualization discussed elsewhere) to share Keyboard Video and Mouse  with another machine (such as a standby server) would be useful.    Be careful that the KVM switch and the motherboard have the same mouse and keyboard connectors.  USB to DIN adapters generally don’t work on KVM switches. No fancy video card is needed.  Some allow switching audio as well, but you will be limited to 3.5 mm jacks from the onboard sound cards which may not be easily accessible in Jack.

If this will be the “master control for audio” it will need a good ALSA compatible sound card with as many output channels as you will have outputs and inputs.  The server should have at least a  USB removable drive or a Network Attached Storage device of the same size or bigger than the RAID drive for backups.  You may have trouble finding servers that are quiet enough for the average station.  If you will be running the servers in a server closet, I recommend recently pulled 2U to 4u servers with dual power supplies. They will, however, be much too noisy for an office or studio environment.  You probably can’t afford them new, but used are inexpensive, just make sure you get multiprocessor X64 machines with enough memory.  Check whether the drive interface is SCSI or eSATA.  Make sure you can get a SSD with the drive interface you choose.  Many servers come without drives.  Make sure you get the caddys with the server and you can get new drives at a reasonable price.  You probably don’t want to use the hardware raid, as the ZFS file system in Ubuntu 20.04  is much more flexible, provides RAID functionality as well as data compression and encryption.

Your “music” ethernet network should be built with good Cat6 cables – any that go through the ceilings or floors should be ‘plenum’ rated.  Use high quality gigabit switches.  You probably can do without managed switches unless you have a lot of workstations, and then we have to tune things that I haven’t had to do yet.  There are plenty of surplus managed gigabit switches available, but they make a lot of noise.

It is possible to set up a server standby system for Rivendell, where you have two identical servers for Rivendell and the audio store or the database are kept up to date on both.  This way a failure will not put you off the air until a new server can be configured.  Similarly, you should keep your workstations as close to identical as possible  so you can switch over quickly in the case of an equipment failure.  Fred Gleason of Paravel Systems is the guy to hire if you want to get this to play.

If you are doing hot standby  servers, it would make sense to have two independent UPS systems – one for each server, and a ups for each workstation.  (Or, if you have dual power supply servers, one for each power supply in the two servers) The idea is “no single point of failure”!  This is where the use of a real router (not bestbuy specials, but ubiquity or cisco) become important.

When you set up Ubuntu on these machines make sure you choose to add .mp3 codec and use ZFS file system with LZ4 compresson.  The account you use to setup will be the main “SUDOER” account.  Use a real password and require it to be entered.  It might make sense to encrypt the main account’s /home folder.

I have not been successful in running Rivendell reliably in a straight Ubuntu LTS environment.  Back “in the day” there were a number of Rivendell boxes working in Europe on Ubuntu 14.04 and 16.04, but Centos7 is so baked into Rivendell, it just makes sense to run it in a virtual box under Linux Kernel Virtualization  (KVM).  Too many of the libraries do not align between what Rivendell expects and what Ubuntu provides, particularly the QT version.  Centos7 is not a very good jack2 host – jack itself works well, but few of the jack utilities work or work reliably in the Centos7 Environment.  We can do all the fancy stuff in Ubuntu and the bread and butter automation in the business oriented Centos7 world.

The server might be called on to do more than switch audio, serve the databases, and stream.  You may want to run the station’s phone system using Freeswitch, or at least the phone interfaces to the studio.  It makes sense to put these into separate “boxes” using Linux Kernel Virtualization  (KVM) or the more sophisticated OpenStack. If you are thinking about using openstack, you will need at least one processor per “node” so an eight processor computer for the server makes sense, along with lots of memory, as each node has its “own” memory.