Make a DIY Digital Jukebox

Full Article :

Fedora Magazine -

Have you ever wondered what to do with an old computer sitting in a closet collecting dust? Why not create your own digital jukebox! This Do It Yourself (DIY) project will guide you through the steps to do just that with the help of Fedora and open-source software. In this article we will:

  • Explain the concept of real-time processing and why it is necessary in achieving bit-perfect playback
  • Give a step-by-step tutorial in configuring the kernel for real-time processing and optimizing the hardware for audio priority
  • Show you how to install the basic tools required for configuring and displaying your audio device (i.e. sound card, or Digital Audio Converter (DAC))

Before we begin installing and configuring the system we need to go through some basic digital audio theory to understand how the jukebox can achieve optimal sound performance.


The kernel must be configured for real-time processing, and top priority given to any audio request to provide crisp playback. This is done to reduce latency – the delay in time when the signal enters the system and is output through the audio device.

It’s best to experience latency with a fun experiment. With a friend in the same room, call their cellphone and talk. Notice the slight delay from the cellphone speaker?

This is because when talking to someone physically beside you, the audio is transmitted in real-time – a straight path from mouth-to-ear. If you’re using a cellphone, your voice (analogue) would first be converted into binary (digital). The signal would then be routed through the towers to the receiving phone. That phone would then convert the digital signal back into analogue for the listener. The processing of this audio causes a delay. This is latency.

The same goes for digital audio. The path that the audio packets travel from the source file to the audio device takes time. When we add layers and filters we add more processing and thus increase latency. This is why for the jukebox we are going to keep it simple and only use ALSA (Audio Linux Sound Architecture). By eliminating Pulseaudio, or the Jack-Audio-Connection-Kit (JACK), we can keep the processing of audio data to a minimum. By sending the audio data straight to the audio device without additional processing, the path is significantly shortened and allows us to achieve bit-perfect audio.

What is Bit-Perfect?

Bit-perfect audio is the transmission of bits from the audio file (FLAC, MP3, OGG-Vorbis, &c.) to the audio device without altering the bit depth, sample rate, or number of channels. Bit depth refers to the number of bits in each sample: 16-bit, 24-bit, &c. The sample rate is the number of audio samples transmitted per second. For example, Audio CDs have a bit depth of 16-bit and a sample rate of 44.1 kHz, or 44,100 samples per second. High quality audio files have a bit depth of 24-bits per sample with a sample rate of 96 kHz or 192 kHz. Channels consist of: mono (1), stereo (2 – left and right), or surround sound (5.1).

In other words, playing a 24-bit audio file at 96 kHz on an audio device limited to 16-bits at 48 kHz playback is not bit-perfect. This is because the audio software, will have to convert the information, or down-sample the signal, into a format readable by the device during playback. For optimal sound quality it is best to let the audio device take care of re-sampling. This also minimizes the amount of CPU processing, keeping the kernel open for what really matters, transporting the audio information.


Now that the technicalities are out of the way, we can fire up that old computer and start configuring the jukebox. First, download Fedora Server and perform a minimal installation. Enable administrative rights for the user account. If you need help with installing Fedora, consult the Fedora Project’s Documentation site. Once the installation is complete, update the system, install your favourite text editor (we will use nano in the examples), and reboot.

Configuring for Real-Time

Once you’re logged in, type:

sudo nano /etc/security/limits.d/20-audio.conf

This creates a file which dictates the priority of any audio request.

Enter the following in the file:

# Gives top priority to all audio requests
@audio - rtprio 99
# Gives favour to any audio requests
@audio - nice -20
# Allows unlimited memory access
@audio - memlock unlimited

Save the file and exit the editor.

Using these settings are safe because this is a dedicated device with a single purpose. For a desktop or workstation, the above settings can cause system instability. This is why Pulseaudio or JACK for these systems can make a difference.

Next we will add the user account to the audio group so that any audio software the user runs can take advantage of the settings we entered in the 20-audio.conf file. To do this run:

sudo usermod -aG audio user

Remember to replace user with your username.

Next, configure the I/O scheduler to minimize disk latency. The deadline scheduler works best for this task as it guarantees a higher priority for read requests. To see what scheduler the system is using type:

cat /sys/block/sda/queue/scheduler
noop [deadline] cfq

The square-brackets displays the I/O scheduler enabled on the system. If deadline is not in those square-brackets, open the grub configuration file:

sudo nano /etc/default/grub

At the end of the “GRUB_CMDLINE_LINUX” line, just before the end-quotes, type elevator=deadline and save the file.

To apply the GRUB configuration switch the user to root and type:

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

for EFI systems, or:

grub2-mkconfig -o /boot/grub2/grub.cfg

for legacy BIOS systems.

Installing the Audio Linux Sound Architecture:

To install ALSA do:

sudo dnf -y install alsa-lib alsa-utils alsa-tools

And reboot the computer.

To view the audio devices Fedora detected on your system type:

cat /proc/asound/cards

This will list the sound cards installed on your system.

0 [HDMI]: HDA-Intel - HDA Intel HDMI
HDA Intel HDMI at 0xf731c000 irq 49
1 [PCH]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xf7318000 irq 48

As you can see in this example, the HDMI (digital stream) is assigned to card0, and PCH (analogue stream) is assigned to card1. USB DACs compatible with Linux will appear in this list.

Congratulations, optimal sound quality is successfully configured. Tune-in to the Fedora Magazine for part two where we will install and configure XMMS2, and finalize the transformation of that old computer into a Digital Jukebox.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: