Welcome to Part 2 of a DIY digital jukebox project. Part 1 of this project addressed how to tweak the system to provide optimal audio performance. With a minimal installation of Fedora Server, the system focused on doing one thing: playing audio. The article covered how to configure audio processing with real-time priority and enhanced disk response time with the I/O scheduler to aid with audio data delivery from the hard drive. It also touched on what bit-perfect playback is, why it’s essential to maintain the purity of the audio source, and how to avoid tainting that data on its way to the hardware. All these contribute to achieving that crisp sound demanded by audiophiles.
This guide provides “do-it-yourselfers” who may be audiophiles and new to Linux the resources and collective information to build their own audio transport system from scratch. Part 2 completes the transformation from computer to appliance. You’ll learn how to:
- Install common open-source codecs like FLAC and Ogg-Vorbis from the official Fedora repository
- Install and configure the XMMS2 software
- Configure XMMS2 systemd service and open TCP ports via Firewalld
- Connect the client to the digital jukebox
- Test for bit-accurate playback via the command-line
Installing the codecs
To play your audio files you must install some codecs. This article only covers popular, open-source codecs available in the official Fedora repository. To install non-free or legally encumbered codecs, you’ll need to use third-party repositories.
To play FLAC, Vorbis and MP3 files, run this command using sudo:
sudo dnf install flac vorbis libmad
Installing the XMMS2 server software
For server/client software you’ll use XMMS2 (X-Platform Music Multiplexing System 2). XMMS2 is a framework built specifically for audio processing. XMMS2 is modular by design and has a variety of plugins to expand its capabilities. These plugins apply to audio transport, decoders, effects, output, and importing and exporting playlists. For the sake of simplicity, and to avoid additional processing, you won’t install any plugins in this article.
To install the XMMS2 server software, and allow the jukebox to broadcast for discovery on the local network, run this command:
sudo dnf install xmms2 avahi
When the installation is complete, run:
This command executes the XMMS2 daemon and creates the configuration files in the user’s home directory. Some errors may appear, but that’s OK since you still need to configure the player. For now, press Enter to return to the shell prompt. Now run the command:
The xmms2> prompt appears. XMMS2 is a sophisticated piece of software, and to go through all the commands is beyond the scope of this article. To learn more, type help at the prompt, or consult the man pages. To exit the prompt type:
Finally, reboot the computer.
Now comes the fun part of the project: tweaking the configuration files for XMMS2. You’ll also create a systemd service file to start the XMMS2 daemon on boot and open ports that allow client access.
First, you need the IP address of the jukebox. To determine that, run this command:
Below is an example of results:
ens3: connected to ens3 "Red Hat Virtio network device" ethernet (virtio_net), 52:54:00:8B:D5:A1, hw, mtu 1500 ip4 default inet4 10.0.0.210/24 inet6 fe80::34fa:a011:f20e:c0a2/64
Note the numbers beside inet4. The IP address in the above example is 10.0.0.210. This is what you need to configure the XMMS2 server for client connectivity. Now run:
This command displays a list of audio hardware connected and recognized by the system. In the example from Part 1 you saw:
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
If you have a Linux-compatible USB DAC it is listed here. The examples in this article use PCH (or card1). Now type:
You should get something similar to the following:
card: 1 device: 0 subdevice: 0 stream: PLAYBACK id: ALC3234 Analog name: ALC3234 Analog subname: subdevice #0 class: 0s ubclass: 0 subdevices_count: 1 subdevices_avail: 0
Note the numbers beside card and device. You need this information for the next step when you configure ALSA to process the audio straight to the hardware.
XMMS2 configuration files
To open the XMMS2 configuration file, run:
Find this line:
<property name=”device”> is set to default. You want to change that to direct the audio straight to the hardware. Remove default and enter: hw:x,y (where x is the card number and y is the device number).
Next, change the mixer property to Master, and mixer_dev to hw:x (again where x is the card number). Your file should look similar to the example below:
<section name="alsa"> <property name="device">hw:1,0</property> <property name="mixer">Master</property> <property name="mixer_dev">hw:1</property> <property name="mixer_index">0</property> </section>
Scroll down to <section name=”clients”>. The entry for watch_dirs property is empty. Here, add the path to the directory that contains the music files. Remember to enter the directory path for your music.
<section name="clients"> <section name="mlibupdater"> <property name="watch_dirs">/home/sassam/Music/</property> </section> </section>
Next, configure <section name=”core”>. Look for the ipsocket property, and remove the unix:///tmp/xmms… entry and enter a TCP port 6600 for your system:
Remember to replace 10.0.0.210 with your IP address. The section should look similar to the example below:
<section name="core"> <property name="ipcsocket">tcp://10.0.0.210:6600</property> <property name="logtsfmt">%H:%M:%S </property> <property name="shutdownpath">/home/sassam/.config/xmms2/shutdown.d</property> <property name="startuppath">/home/sassam/.config/xmms2/startup.d</property> </section>
The last setting to configure is the output section. Change the plugin property from pulse to alsa.
<section name="output"> <property name="buffersize">32768</property> <property name="flush_on_pause">1</property> <property name="plugin">alsa</property> </section>
Be careful if you edit the buffersize property. If it’s set too low you may encounter playback issues. This example keeps the defaults, but feel free to experiment. Save the file and exit.
Creating the XMMS2 systemd service
Edit a new service file using sudo:
sudo nano /etc/systemd/system/xmms2d.service
In the file enter:
[Unit] Description=XMMS2 Service After=NetworkManager.service [Service] ExecStart=/bin/bash -c "sleep 3; /usr/bin/xmms2d --yes-run-as-root --conf=/home/sassam/.config/xmms2/xmms2.conf" [Install] WantedBy=multi-user.target
Save the file and exit. To enable the service on boot, and in this session, enter:
sudo systemctl daemon-reload; sudo systemctl enable --now xmms2d.service
Now, open port 6600 in your firewall, to allow the XMMS2 client access to the system over your local area network:
sudo firewall-cmd --permanent --add-port 6600/tcp; firewall-cmd --reload
Success! Your digital jukebox is fully configured. You can adjust the volume on the server-side with:
The XMMS2 Client
The client used is GXMMS2, available in the Fedora repository. GXMMS2 is a simple client with a small window that allows users to control audio playback on the XMMS2 server. To install GXMMS2 on your Fedora desktop, open the terminal and enter:
sudo dnf install gxmms2
When the installation is complete, open the GXMMS2 program to create the client configuration file. To edit the file, go back into the Terminal and enter:
Here, set AutoReconnect to yes, and change the IPCPath to the socket path you entered in the server configuration file above. For example:
Again, remember to use the IP address of your digital jukebox. Feel free to go through the configuration file and adjust the settings to your liking. Then save the file, exit the editor, and close the GXMMS2 window.
Re-open GXMMS2, click the Open playlist editor button, then click the MLib Browser tab. A list of your audio files appears. Double-click the artist, then double-click the album. GXMMS2 displays a list of songs. Highlight the songs you want to add the playlist and click the Add button, or double-click the song. Click the Playlist tab, then double-click on a song to start playing.
Testing for Bit-Perfect Playback
Now let’s check for bit-perfect playback. Go back to your server and at the shell prompt enter:
Remember to use the card number you configured in the xmms2.conf file. For the song playing in the above screencast, the following information is shown:
access: RW_INTERLEAVED format: S16_LE subformat: STD channels: 2 rate: 44100 (44100/1) period_size: 735 buffer_size: 22050
This shows the playback format is 16-bit using two channels with a sample rate of 44100. The software is not resampling and playback is identical to the audio file, and bit-perfect playback has been achieved. Remember, if you try to play an audio format beyond the resolution of your audio device, like a 24-bit FLAC file on a 16-bit DAC/soundcard, you may get unstable, or no, playback. To play these files you can configure ALSA/XMMS2 for software mixing, or install and configure a sound server like Pulseaudio or JACK to resample the audio information. However, bit-perfect playback will be lost.
Congratulations! You have successfully created your own digital jukebox optimized for sound quality. What was once old is now new again thanks to Fedora and open source software.
This article touched upon some of the fundamentals of digital audio. Readers and audiophiles looking to refine their systems, and improve upon the information provided, can find more details from the sites below. Some of the referenced software may be outdated, but the concepts are still relevant.