Saturday 12 October 2024

GUEST POST: A Raspberry Pi Music System that Punches Above its Weight - Wax by Jeffrey Barish

[Hey everyone, the community of Raspberry Pi audio applications has grown tremendously over the years! SBC's similar to the Pi running on Linux OS are almost ubiquitous inside streamer components these days. Jeffrey Barish recently contacted me about his novel software which looks like a fantastic system for managing a music library that imports art, rich metadata, and other information that can be run in a small all-in-one box with DAC output! Here's his write-up and introduction to Wax.]


Using a Raspberry Pi as the basis for a music system is not novel. Raspberry Pi OS is based on Linux, so at least 20 audio player programs should be compatible. If you listen only to pop and you are satisfied with a program that allows you to simply select and play an album, then you will probably be satisfied with almost any of these programs. However, if you are a serious music lover – and especially if your collection includes classical music – then you are probably looking for more.

Serious music lovers like to know something about the music they are playing. They like to know the identities of the artists performing the music. These capabilities are available in some proprietary solutions, but those products are expensive, they might require additional components (e.g., a DAC or disk drives), and some require that users pay an ongoing fee. This article describes a new program for the Raspberry Pi that provides an inexpensive solution with these and many more capabilities.

Wax is a free Python program for cataloging and playing a collection of music recordings. It was designed for music lovers, not programming wizards. By taking a novel approach to the challenge of cataloging a music collection, Wax avoids frustrations associated with other music management systems, especially when handling classical music. Other programs force users to think about tags, file names and layout, style guidelines, compilations, parents, and more. Wax hides the gears and levers, providing operation that is more natural and intuitive. It makes it possible to enjoy your collection as a collection of music rather than a collection of data.

Wax is fundamentally different from existing music managers in three important ways. First, the fundamental unit for entries in the catalog is a “work”, not a track. A work is usually a collection of tracks. It can encapsulate whatever tracks you choose. In pop music, a work can be an album. For symphonic music, a work can be a single symphony, even when the tracks come from a CD with more than one symphony. For operas, a work can be a single opera even when the tracks come from multiple CDs. Music collectors usually think in terms of works, so a music manager that supports the concept makes operation more natural.

The second distinguishing characteristic of Wax is that genres are fundamental to the organization of a collection rather than a mere attribute of a track. Wax recognizes that the ideal way to catalog works varies by genre. For example, symphonic works can be cataloged using the metadata keys composer, work, conductor; shows can be cataloged with show, composer, lyricist; and pop with group and title. You decide what genres best characterize subsets of your collection, and for each genre you decide how many keys and what keys to assign to the genre.

Finally, Wax tightly integrates three functions: cataloging, selecting, and playing works. With Wax, you can start playing a work as soon as you have specified a minimum set of metadata. You can supplement or modify the metadata while listening to music, and any changes that you make to the metadata are immediately reflected in the display.

Wax was designed to run on a Raspberry Pi 4 and to take advantage of its architectural features. The Raspberry Pi has four cores. Wax uses one core to run the user interface, one for playing, one for ripping, and the fourth for time-consuming tasks like fetching metadata from the cloud (MusicBrainz and Cover Art Archive). Many audiophiles worry (needlessly) that burdening a processor involved in playing a sound file can impair the quality of the sound it produces. The multi-processing architecture of Wax obviates this concern as the core responsible for playing the music is not simultaneously performing any other tasks. The last sections of this article describe how to install the software and assemble the hardware for a complete system based on Wax using off-the-shelf components.

To explore the salient features of Wax, we will examine a single recording as it appears in the three operational modes: Select, Play, and Edit. I selected a classical recording because classical music presents the greatest cataloging challenges. However, the capabilities you will see are applicable to recordings in all genres.

Select mode


The Symphonic genre has four keys: subgenre, composer, work, and conductor. Notice how multiple works by the same composer are listed together. Likewise, multiple versions of each work are listed together. This hierarchical sorting makes it easy to survey the collection for the desired recording – possibly one that you forgot you had. Wax also provides incremental search if you already have a specific work in mind. After selecting the desired recording, a panel appears with a listing of its tracks. By default they are all selected, but you can select a subset if you prefer. Once you have selected the work and the tracks, you drag the selection to the play queue list on the right and then activate the play button.

There are two other features worth noticing. It is possible to group tracks. In this work, each section of the Requiem is a track group. For works in the Opera or Show genres, you can group the tracks for each act. Track groups make it easy to highlight relationships among tracks and also to select the specific tracks that you want to hear. The other interesting feature is that the values in any column can alternatively be represented as a filter button. In this case, I converted the “subgenre” field to a filter button (by dragging the column header to the filter button area). Selecting a value with the filter button removes works from the list that do not match that value.

Play mode


In Play mode we see all the metadata associated with the work. Values that appeared in their short form in Select mode (e.g., “Verdi”) are presented here in their long form (“Giuseppe Verdi”). For music lovers who want to dig deeper, Wax provides the Wikipedia page, which has a browser that you can use to view information at Wikipedia related to the recording, and the Docs page, which is for viewing the liner notes.

Edit mode


Edit mode is where you create new works or revise existing ones. The “primary” fields on the left (only the last two are visible in the screenshot) are where you specify the metadata. Each key has two value fields, one for the short form used in Select mode and the other for the long form used in Play mode. Secondary metadata appear only in Play mode, so they have only a long form. The “chorus” and “soloists” fields are “nonce” metadata – metadata fields that you create for additional information about individual works. The right arrows open additional fields for keys with multiple values. You can see how the right arrow opened additional fields for the soloists.

The panel on the right displays metadata that Wax downloaded from MusicBrainz. You can drag any of these values to fields on the left. In addition, Wax will automatically copy familiar names to the appropriate field on the left. In this case, Wax recognized all three of the names under “artist”. If you ever specify an unfamiliar name as a value, Wax will offer to learn the name so that it knows how to map it automatically the next time Wax sees it. Wax also provides automatic completion for familiar names. For example, typing “Moz” in the composer field is sufficient for Wax to offer the completion “Wolfgang Amadeus Mozart”. These features make it easy and quick to specify metadata for a work.

You can manipulate track metadata on the Tracks page. In addition to editing the default track titles obtained automatically from MusicBrainz, you can form track groups and add metadata specific to a track (for example, the name of a guest artist on a particular song). Wax makes it easy to fix a common defect with automatic track metadata. For classical music, MusicBrainz recommends that track titles be in the form “Piano Sonata no. 32 in C minor, op. 111: Maestoso”. Specifying the work in every track title is necessary because tags are track-oriented. In Wax, the title of the work is in the work metadata, so it is not only pointless to provide it repeatedly in track metadata, but doing so also obscures the information that is unique to the track, in this case “Maestoso”. Wax can remove the redundant information from every track and move it to the work field in two clicks.

The import tab presents controls for importing sound, image, or document files. When importing sound files, Wax extracts metadata – including embedded images – from the tags. As for rips, Wax displays the metadata in the panel on the right and automatically populates as much of the left panels as possible.

Once you have specified all the metadata you want, you click the “Save new” button to create a new work. When you save a new work, Wax tags the sound files with values derived from as much of its rich metadata as possible in case you ever want to listen to the sound files on some other platform.

WaxConfig


WaxConfig is a separate program used for configuring Wax. Most importantly, this is where you specify genres, including their name and the primary and secondary keys. The Info page provides information about your collection, including the number of works in each genre, as shown in the screenshot.

Installing the software

Wax is free. To get a copy of the software, go to github.com/jeffbarish. There are four repositories. wax and wax-config contain the software for Wax and WaxConfig. The manual is in wax-manual. You can also view the manual on line at https://wax-manual.readthedocs.io/en/latest/introduction.html. Finally, there is an installer in wax-install.

Start up your Pi with Raspberry Pi OS and then review the README in wax-install which explains the steps for installing the software.

Hardware

I run Wax on a Raspberry Pi 4 Model B with 4 GB of RAM. I use the NanoSound One DAC with the Argon One M.2 case. The NanoSound One DAC uses the TI PCM5122 DAC for high-quality audio output (112 dB SNR). The Argon case makes it possible to integrate a 2TB SSD which I use for storing my sound archive. 2 TB is sufficient for all but the largest collections. My collection of 3600 recordings (mostly FLAC) consumes only about 750 GB.

The highest CPU load I have seen is 2.4 (with 4 cores, the processor is theoretically capable of sustaining a load of 4.0). To hit that load, I had Wax playing and ripping at the same time, and I was quickly paging through PDF liner notes. The highest processor temperature I have seen is about 45°C (throttling begins at a temperature of 80°C). Memory consumption is typically less than 1 GB, so even the 2 GB Raspberry Pi should be sufficient (and you can save a whopping $10!).

Note that the system does not have a fan – nor does it need one. Putting a fan in an audio component is perverse because fans produce noise. If the noise is audible, then you just obviated the low noise performance of your electronic components, including the DAC. The fan noise might not be audible at your listening position, but why risk audible degradation when better solutions exist?

Here is a table [with links] and approximate hardware prices as of this writing:

Raspberry Pi 4 Model B/4 GB      $55
NanoSound One Hi-Fi DAC Case     $80
Power supply                     $8
M.2 SATA SSD board               $20
  (can order w/ NanoSound One)
microSD card (minimum 2GB)       $10
Fikwot FN203 2TB M.2 SATA SSD    $100 
                        TOTAL:   $273
The following sequence of images shows the content of the case as I build up the components – no soldering or special tools required! First is the board for the M.2 SATA SSD. It connects to the Raspberry Pi using a USB jumper.
[Note the use of the SATA SSD here, not NVMe. This is probably wise in a fanless device like this because SATA drives typically run significantly cooler and use less power. Given the USB connection, it's unlikely that an NVME drive would meaningfully run faster.]

Next is the DAC which uses the TI PCM5122 DAC chip for high-quality audio output.


Next is the Raspberry Pi 4B with a turner board that positions the USB-C for power at the rear of the case along with all the other connectors.


Finally, here is what the completed system looks like in the enclosure:


Connect a power amp to the audio output, a CD drive for ripping CDs to one of the USB jacks, a keyboard and mouse to two others, a monitor, and a power supply. [For CD ripping, something like this LG GP65NB60 should work but you probably need an external powered USB hub, alternatively one like this with a separate USB connector for power.]

It boggles the mind that this tiny system can house an entire music collection (a wall of CDs and LPs in my case). With its hi-fi DAC and a processor, it gives you complete control – ripping, cataloging, and playing – over your collection and metadata that you own, not rent.

The network connection makes it possible to back up your sound files to a NAS. The system consumes only 2W when idle, so I leave it on all the time. I run x11vnc on the system so that I can connect from anywhere in my house using an iPad or a Chromebook to operate the system remotely. The small size makes it feasible to take the system to work, connect it to powered speakers, and use it to listen to your music there.

Considering its powerful software, conveniently small size, reasonable cost – with no recurring fees! – and excellent sound quality, this system truly punches above its weight.

--------------------

Wonderful work Jeffrey!

Indeed the little TI PCM5122 DAC (similar to the HiFiBerry DAC+ Pro measured awhile back) should be capable of great hi-res playback quality.

Given the necessary passion to get this done and the energy expended, this must have been a "labor of love" which all of us in the audiophile hobby can benefit from. In particular, that approach of looking at the "work" as a fundamental unit is an intriguing system of categorization.  Furthermore, incorporating the genre into how the software presents the library adds another layer of flexibility and power. Clearly, to implement all this took much thought, planning, and execution.

I hope audiophiles and music lovers give the system a try. It might shift the way we think about how to best manage music libraries in a potentially more convenient, accessible fashion; especially when we have large collections with multiple instances of classical "works" for example!

Time permitting, I'll look into building one of these boxes myself! ðŸ™‚

As usual, readers can discuss the software below in the comments section. Alternatively, there's also a thread on MusicBrainz. Given the potential of the software, I'm sure there are many bits and pieces to dig into well beyond this introduction. I'll update here if there are other links.

14 comments:

  1. Hey there Jeff, that's exactly the kind of thing I was planning to build to take to the office! Just ordered the case today. Thanks!

    ReplyDelete
  2. Very cool system. I love these single box builds. Elegant and terrific performance.

    ReplyDelete
  3. I'm not sure how WAX stores the data, I assume that it customises Tags.
    I use Musichi which uses a range of Tags data to include Composer, Work, Movement, Soloist, Conductor etc as well as unassigned Tags that I use for Opus, Catalogue and Key. It is a paid package and they no longer seem to update it but the ripper and editor are very powerful and it also addresses the problem of consistency with 'Works'. You can choose whether it's Beethoven Piano Concerto No.5 in C minor Op.73 'Emperor' or Beethoven Piano Concerto in C minor No.5 'Emperor' Op.73.

    ReplyDelete
  4. Good question, Mike A. Wax does not customize tags. It stores metadata in separate files. It is only by defining its own database that Wax is able to provide the unique features I described in my article – in particular, the work orientation, track groups, and per-genre metadata keys. It is a mystery to me why other solutions embrace tags considering their limitations, but perhaps you can enlighten me. The only rationale I see is that in principle tags preserve metadata when sound files move from one platform (and one player) to another – but only when the tags scrupulously adhere to standards. Even then there can be problems: ID3v2.4 was published 24 years ago, yet its support in music players is still problematic. Any virtues of MusiCHI are limited to users of Windows and, if MusicCHI uses custom tags, also to users of that program. Wax supports portability by embedding salient metadata in standard ID3v2.2 tags, so that sound files that I play on my smartphone display cover art and basic information such as album and track title. In order to support operations like search, tag-based systems usually (always?) “index” a collection of recordings to create a separate database. Why not just start with a separate database and design a solution that works for users rather than one that works for the ID3 standard?

    There is much more that I could say about the limitations of tag-based solutions, but the proof is in the pudding. Think about what the display of metadata looks like on your system compared to what I presented in the article for Wax. If you have multiple versions of Beethoven Piano Concerto No.5, how easy is it to choose the version with a particular soloist? You tout as a virtue of MusiCHI the ability to choose between “Beethoven Piano Concerto No.5 in C minor Op.73 'Emperor' or Beethoven Piano Concerto in C minor No.5 'Emperor' Op.73”. In my view, neither is desirable because “Beethoven” is the composer, not part of the title of the work. When I am selecting a work, I do not actually need to know the key of the work, the opus number, or the nickname. Wax reduces clutter by presenting that information only in play mode, when I am more likely to appreciate that level of detail. The CD with the Beethoven Piano Concerto No. 5 probably had at least one other work, perhaps Beethoven Piano Concerto No. 4. Is each work listed with other versions of the same work, or are they coupled to each other as they are on the CD? If you want to listen only to Act 1 of a musical, do you have to select each of the tracks individually? Does your player make it easy to identify the tracks for Act 1 without cluttering the display with “Act 1” in each track title? These are a few examples of ways that Wax presents metadata efficiently and naturally.

    If you are happy with MusiCHI, you should stick with it. I offer these comments only to clarify differences between legacy solutions and Wax.

    ReplyDelete
  5. Great job Jeffrey! My music collection is mostly classical, and I like Raspberry Pi, so this looks like something that could suit me. Though I haven't been very active in this area lately so my Pis are still 3 rather than 4/5. Also I'm really lazy with the tagging - perhaps that could be a good thing here because it seems to work in a different way.

    ReplyDelete
  6. I have not tried it, but most likely Wax would run fine on a Raspberry Pi 3. However, the beauty of the hardware that I presented is that the components all work together and they all fit in an attractive case. You can find DAC HATs that work with the Raspberry Pi 3 and SSD HATs that work with the Raspberry Pi 3, and you can find cases that accommodate a Raspberry Pi 3 and either a DAC HAT or an SSD HAT -- but not all three. Unless you are comfortable building a system with a stack of naked boards, you would be well-advised to splurge and get the Nanomesher kit. Also, I recommend avoiding the Raspberry Pi 5 because its performance comes at the cost of heat which adds a requirement for a fan -- anathema in an audio device.

    As for being lazy, you are in good company. I have little tolerance for tedious, repetitive tasks, so I designed Wax to make entering metadata as easy as possible -- even for classical recordings. With Wax, you do not need to master the MusicBrainz Classical Style Guide because Wax does not aggregate metadata the way other software does (see the example in the post by Mike A which aggregates the composer and the title of the work). Wax makes it clear that the name of the composer goes in the field labeled "composer" and the title of the work goes in the field labeled "work", so you do not need to know the correct format for aggregating distinct metadata values into one field.

    Moreover, Wax is able to populate many of the fields automatically from the metadata it obtains from MusicBrainz. Using Mike A's example again, the name "Beethoven" would appear somewhere in the MusicBrainz metadata. Wax would recognize that name as the name of a composer, so it would automatically copy it to the composer field. It would also recognize the name of the conductor and the name of the orchestra. Track titles in MusicBrainz are typically conglomerations like "Symphony No. 9 in D minor, Op. 125: I. Allegro ma non troppo, un poco maestoso". Every track title contains the string specifying the work. To excise this redundant information, you select all the tracks in the symphony and group them. Wax automatically deletes the work name from the track titles to the clipboard, leaving only the information unique to each track. You then paste the clipboard to the work field. Without typing a single character, Wax will have populated all the essential metadata fields. If Wax does not recognize a name, you copy and paste it to the correct field -- and Wax will offer to learn the name so that it will recognize it the next time it sees it. If you are interested in any other metadata -- the names of the singers in an opera, for example -- you are free to type them in, but Wax does not require that you do so. It is hard to appreciate from words the ease of operation, but -- dare I say? -- ripping is actually kinda fun.

    ReplyDelete
    Replies
    1. Thanks for responding so quickly Jeffrey! I will surely check it out. Hopefully now that winter is approaching where I live, there will be more time for indoor activities like this.

      Delete
  7. Very nice, but alas, not multichannel-friendly. Actually all I really'd like is a box like this with multichannel capability (therefore, HDMI output, which I know means licensing) and without a DAC (my AVR has one already, thanks). IOW, an audio data streamer with built-in storage, and music management software with a GUI (e.g. Wax). Preferably controllable from a tablet or phone. It would replace a laptop/HDMI + external drive setup, which is excess to purpose.

    ReplyDelete
    Replies
    1. Good point Steven,
      In general I don't think the Raspberry Pi HDMI output works well with multichannel; or at least not without hassles. I've never been able to get it working which was why I jumped over to the MiniPC side more than a year back.

      I see there's this message from a few years ago getting a Pi as multichannel Roon endpoint:
      https://community.roonlabs.com/t/a-quick-how-to-hdmi-multi-ch-w-linux-yes-pi-too/160640

      I wonder Jeffrey if you have any thoughts on the Pi 4's HDMI output. Ever tried using that with Wax, or getting multichannel out from that?

      Delete
  8. Just got my parts so hopefully will put the box together this weekend. Jeffrey, is there an audiophile forum you hang out at or other way to PM you if I have questions? A bit of a Linux newbie!

    ReplyDelete
  9. Seems like a nice project, thank you for presenting it.

    Does it need to run Raspi Os or will any Linux do?

    Does it need to use the Nanosound DAC or a hat type DAC at all or can it work with a USB type DAC or maybe do SPDIF out?

    Is there a way to patch the stereo stream to Camilla DSP for use as a digital crossover?

    ReplyDelete
  10. Gack. Suddenly I have a backlog of queries. I shouldn't have gone to sleep last night. I will provide some quick responses and possibly follow up later with more.

    StevenS: I have never tried to get audio over HDMI working on a Raspberry Pi. Same as Archimago: I once got it working with an Intel-based motherboard (but running Ubuntu in my case). I found a thread in StackOverflow describing a procedure using raspi-config for setting HDMI as the default audio output device. Alas, there is no good way to post a link here. See whether you can find the thread using the question number 70156072. As far as I know, Wax itself supports multichannel audio. It certainly did when I tested it on the Intel MB. Wax uses GStreamer for audio output -- playbin, to be precise. I found a thread that confirms support for multichannel using playbin.

    I use x11vnc to broadcast the interface and a VNC viewer on my tablet, phone, or Chromebook to interact with the interface remotely. It is possible to configure x11vnc to broadcast only the Wax window, which makes Wax look native on the remote display. I have a script I can share if you get to this point.

    JScull-65: There is already a thread at the MusicBrainz forum, so let's use that for now. See the link in the last comment by Archimago at the end of the article. You may be a bit of a Linux newbie, but I am a bit of a PM newbie. If the MusicBrainz thread proves unwieldy, maybe you can provide some advice on a better solution.

    Eric: Claiming support by "any Linux" would be a bold statement. I tried Ubuntu. I got Wax to run, but the cdrom drive did not work. Presumably that problem was fixable, but I did not pursue it. I tried Mate, but the installer stumbled over missing modules. Again, presumably fixable, but I did not pursue it. I do all development on a platform that runs Kubuntu, but I never tried Kubuntu on the Raspberry Pi. Wax uses GTK, so it would be wise to choose a Linux that comes with GTK unless you are bold. You also need GStreamer. Another module that can be a problem is webkit.

    You can use raspi-config to specify USB as the default audio output device. You will need an SPDIF HAT to do SPDIF out. Be aware that the case that comes with the NanoSound One DAC is designed for that DAC. Options that you are considering are feasible, but you would have to find a different case to accommodate whatever HATs you choose. And do not forget that your configuration will still need a way to connect an SSD. There are HATs for SSDs, but again finding a suitable case might be a challenge.

    Camilla DSP: Probably. Outside the scope of this article, though. There is a thread at DiyAudio by HenrikEnquist with relevant information.

    ReplyDelete
    Replies
    1. Thanks Jeffrey, will give it a go! Hope smooth install ;-)

      Delete
    2. Happy to help if you have problems. Use the thread over at MusicBrainz, though.

      Delete