Online Jukebox

MPD and Cantata

Author(s):

The MPD server helps you manage your music collection flexibly and remotely and integrates external content.

For a long time, Linux had a reputation as not being suitable for multimedia applications because of a lack of appropriate codecs and applications. The tide has turned, and the package sources of most distributions contain more multimedia programs than many other operating systems. Almost every standard installation comes with audio players that play music files in all common formats. These programs usually only run locally on a desktop computer, where the audio files are also located. The players cannot be used on the web – or only to a very limited extent.

The Music Player Daemon (MPD) [1] lets users enjoy music far more flexibly and from any location: It acts as a music server on a standalone system or on the local network completely independent of the clients. On standalone systems, the advantages of MPD are less obvious than on the network, because the server and client run on the same machine and the function is thus similar to any conventional playback software for audio files. On your home network, for example, you can connect an MPD server to a hi-fi system and then control it with a notebook or smartphone. The streaming capabilities of the MPD server also let you play audio files on remote clients, if desired.

The MPD server can be found in the package sources of almost all major distributions, from Debian and Fedora to Mageia and from openSUSE to Slackware and Ubuntu. It can therefore be installed with just a few mouse clicks. However, configuring the service requires some manual work: As an administrative user, you will be concerned with the /etc/mpd.conf file, which you can open in an editor. This file groups all the important server settings.

Because MPD manages the audio files in a database, you need to change the path in the music_directory section in mpd.conf for where you want the service to search for music files. MPD can handle numerous file formats, from classic MP3s to the free Ogg Vorbis and FLAC formats. The software also stores individual playlists in a separate path on the server. Enter this in the playlist_directory section of the configuration file.

Architectural

Linux comes with several historically grown sound architectures, but not all of them support all applications. The MPD server shows its flexible side: It supports the most common sound architectures with OSS or ALSA and works in combination with PulseAudio. Furthermore, it gets on with the JACK audio server, which is more established in the professional sector.

Which sound architecture is used depends on the operating system and the hardware. You need to make the appropriate settings in the audio_output section of the server configuration file, where you will find preconfigured entries for the (default) ALSA subsystem and the older OSS sound architecture. You can enable them by deleting the hash sign (#) at the beginning of the corresponding lines. Conversely, you can disable entries by placing a hash sign at the start of the respective line (Figure 1).

Figure 1: The MPD server configuration takes place in a single file.

After changing the basic settings, launch the MPD server with:

sudo service mpd start

If the server was already active when the system rebooted, you can stop and reactivate it with the new settings by typing:

sudo service mpd restart

The server now waits for connection requests from the clients on the local network, default port 6600.

Clients

The many Linux MPD clients have different desktop-specific interfaces and ranges of functions. Cantata [2] is a relatively new but functionally mature front end based on the Qt5 libraries, although it also works under other graphics libraries.

Most popular distributions have Cantata in their repositories, so the program usually can be installed with a click of the mouse. The installation routine creates a starter in the Multimedia or Entertainment Media submenu. The program opens a clear-cut wizard for the configuration steps after the first start.

The first dialog gives some hints about the MPD server. In the second dialog, you define the operating mode: The function is available as a front end for an MPD server on the network or for use on the local system. For use as a client on the network, specify the IP address of the computer on which the MPD daemon is running (also see the "Static IP" box). If this requires authentication, enter the corresponding password in the dialog. You do not usually need to change the port number (Figure 2).

Static IP

On a home network, the router repeatedly assigns new IP addresses to the connected computers. Therefore, you will want either to talk to the MPD server in Cantata via the hostname or to configure the router interface so that the server always receives the same IP. Alternatively, enter a static IP address on the MPD server system itself. Be careful not to interfere with the router's DHCP server. This usually avoids a defined IP range, which you can then use for static assignments.

Figure 2: Cantata has a configuration wizard for easy setup.

You additionally need to define the directory where the music files are located. If the MPD server is running on the same system as Cantata, just enter localhost in the Host input field. Once the configuration is complete, click the Connect button to establish the connection between Cantata and the MPD server.

In the next step of the dialog, specify whether Cantata is allowed to download additional data from the Internet about the individual songs and albums and store them in the music folder. Data to be downloaded primarily includes lyrics and covers for albums. The configuration is now complete, and the wizard branches to the program window.

Settings

Cantata is somewhat reminiscent of the Rhythmbox audio player, which is often used on the Gnome desktop: On the left side of the window, you will find various buttons for managing audio files, playlists, and music sources. The center of the window is occupied by an empty list segment. On the right, in a large, at first still empty, area the individual tracks or sources appear in tabular form after selecting albums or lists.

Additionally, you will see a grayed out control bar at the top, which you can use later to play the individual tracks. On the far right next to the controls is a gear symbol, which opens another settings menu. Alternatively, you can access the configuration dialog by right-clicking on one of the buttons in the left sidebar of the software and then choosing the Settings option.

Pressing Ctrl+M displays a menubar at the top of the screen to facilitate individual operating steps. When you get there, you can also access the configuration menu from the Settings | Configure Cantata entries. This menu arranges the individual configuration groups in a sidebar on the left, and you can adjust the numerous options in a larger area on the right (Figure 3).

Figure 3: Granular adjustments of Cantata are made in a clear-cut dialog.

In the dialogs, you can configure settings for the individual groups in the sidebar of the main window as well as for the appearance of the application. For example, you can hide entire groups from the main window if you do not need them. Numerous sources for lyrics or cover images can be activated at this point. The modified options only take effect after pressing the Apply button at bottom right in the settings window. After entering all options, press OK to close the dialog.

Disk Jockey

The main controls on the left side of the program window are used to create and manage playlists. To begin, click Artist to display the names of the tracks imported from the hard drive in the central window pane. A click on the second button instead shows the imported Albums, which Cantata displays with the cover images, if it finds them on the hard drive or on the web. Clicking on one of the albums opens a list of tracks in the central pane.

Clicking on the plus symbol to the right of each track transfers it to the temporary playlist. The matching title then appears in the right-hand window pane. Clicking on the Play icon in the upper left corner of the taskbar in the program window starts playing back the current playlist. The horizontal bar to the right shows what is currently playing. Playback of the track on the MPD server starts immediately without latency (Figure 4).

Figure 4: Cantata makes creating playlists easy.

To generate a permanent list from this temporary playlist that can be recalled at any time, first select the individual tracks and then right-click to open a context menu. Click Add to Playlist and then New Playlist and enter the name of the new list in the dialog that then appears. Then use the Playlists button on the left side of the window to open the playlist. Now you can fill the list with tracks in the same way as you did the temporary playlist. In the context dialog of the music selection, use the Add to Saved Playlist menu item.

Playlists can also be edited. To help you do this, you will find various options in the context menu of the titlebar, which you can access by right-clicking on a selected track. Use the Edit Track Information entry to edit the metadata of individual tracks and Remove Duplicates to remove duplicate tracks. The Sort By submenu lets you sort the list by artist or album, for example. You can remove unloved pieces of music with the Remove option, and clear the entire list with the Clear entry. Click Save As to save the current playlist under a new name.

Localization

Cantata not only lets you manage and play your private music collection on the MPD server but also integrates external sources. The Streams menu group can be used, for example, to integrate web radio stations into your audio collection. Additionally, Cantata lets you integrate online services such as SoundCloud [3] or podcasts into the software. Even external devices such as smartphones that transfer audio data to Cantata via the MTP protocol find their place in the software.

To access these sources conveniently, create a corresponding group in the sidebar if it is still missing by opening the preferences dialog. Select the desired option in the Interface group in the Sidebar tab and enable it by checking the box. Cantata copies this group to the sidebar of the main window. Then, select one of the active providers from the Streams group. Cantata already offers some streaming services, and you can add others from the settings menu in the Streams dialog. After loading the streams, you can include individual streams in the playlist in the same way you manage a music collection. You start the desired stream just like a track; Cantata immediately loads it and plays it on the MPD server (Figure 5).

Figure 5: You can also play web radio broadcasts with Cantata and the MPD server. Note that the interface of this version of the software places Streams under the Internet icon.

You can also integrate podcasts into the system under the Internet group; this opens a dialog for subscribing to podcasts. You will find many preset podcasts here, but you can also enable your own subscriptions in the Enter URL option. All you need is the corresponding URL, which you will find on the respective website. After entering the URL in Cantata, press the Load button on the right-hand side of the window to subscribe to the podcast. The podcast details then appear on the right side (Figure 6). In the main window, you can then open the desired podcast like any song.

Figure 6: Playing podcasts is no problem in Cantata.

Info Center

Cantata provides background information on artists, albums, and lyrics. To this end, the application accesses a number of online services. During track playback, you can hide the list window by clicking on the info bubble at top right and display an informational window instead.

In its three-part view, you will find biographical information for each artist on the left, a cover photo of and information about the current album in the middle, and the lyrics of the track you're currently playing on the right. On moving to the next title, the application automatically retrieves the new information and displays it immediately (Figure 7).

Figure 7: A full set of information about the artist, the album, and the track is available at the click of a mouse.

External Playback

Alternatively, you can configure the MPD server to send content to a remote streaming server such as Icecast 2 [4], which then distributes it. In this scenario, the MPD server acts as the source client. The program then does not play the content through the sound card of the MPD server and devices connected to it (e.g., hi-fi systems or sound systems), but through the sound card of any client that retrieves the contents of the streaming server.

Most modern audio players under Linux are capable of receiving streams off the web, for which you need a computer running an Icecast 2 server. On the MPD server, adjust the /etc/mpd.conf configuration file; to do so, enable the default configuration for the Icecast server in the Audio Output section by removing the hash signs from the start of the corresponding lines. After restarting the MPD server, it contacts the Icecast server and then streams content to it.

Another option is to access the MPD server from external clients in a web browser. The developers have integrated a small web server into the system, which you can also enable in the /etc/mpd.conf file. The web server is configured in the Audio Output area and is usually used with Ogg Vorbis or an MP3 encoder. The bitrate or quality option lets you adjust the quality of the playback to suit your needs. Please note that only one option can be active. Then, call the stream in the web browser on a client on the network by entering the matching URL http://server_IP:8000.

Conclusions

Thanks to the MPD server and Cantata duo, you can change the way you play back your favorite audio in an extremely flexible way. The MPD server is configured in a single file whose entries are well documented by the developers. Cantata is intuitive to use and does not require much training.