Installing CUETools 2.2.4 on Linux via WINE

If you want to accurately rip an audio CD on Linux, you should use fre:ac. It's fast, simple, and checks its results against the AccurateRip database1, so you'll know right away which tracks copied perfectly, and which ones didn't.

Unfortunately there isn't much fre:ac can do about imperfect rips, other than draw your attention to them. You could try again with different settings, but if nothing changes, that's that.

The track might sound fine, but somewhere, somehow, it's wrong.

And you know that. fre:ac told you as much.

But where? How? It'll eat away at you. You'll grow to despise that damn song every time it turns up in a playlist, its every beat a calculated insult, mocking you with imperceptible perversions…

It's the sort of thing that can keep a person up at night. Haha.

Thankfully, the descent into madness is optional.

Suite, Software, Database

CUETools is a suite of CD-ripping, management, and conversion software for Windows, the name of a program within that suite, and an online verification database.1

Got all that? Haha.

The suite is, by and large, unimpressive. The user interfaces are pretty clunky. The settings and documentation are confusing. Plenty of other programs do the same things, but better.

So why install it?

CUETools — the program — is uniquely capable of verifying and repairing CD rips after-the-fact, thanks to its tight integeration with CUETools — the database.

Like AccurateRip, the CTDB stores track and album checksums from redundant rips 'round the world, providing an independent reference that can be used for verification.2

But unlike AccurateRip, it also stores parity data that can be used to detect and correct minor corruption within a rip.3

And that's incredibly useful.

So useful, in fact, it is worth the hassle of using WINE to get it up and running on Linux.

Installation

The runtime requirements for CUETools change often, so we're going to stick with the latest release as of publication time: 2.2.4.

It is packaged as a zip that can simply be downloaded and extracted. I like keeping things like this in the /opt folder so that's what we'll do here, but feel free to put it anywhere you like.

# Download the package.
wget \
    -O cuetools.zip \
    https://github.com/gchudov/cuetools.net/releases/download/v2.2.4/CUETools_2.2.4.zip

# Extract and move it to /opt.
# Note: the "user_profiles_enabled" file acts like a flag; excluding
# it will cause the software to store its settings in a portable manner.
unzip cuetools.zip -x CUETools_2.2.4/user_profiles_enabled
sudo mv CUETools_2.2.4 /opt/cuetools

We'll also need WINE and a few runtime dependencies, but rather than install it through your distribution — risking compatibility and/or security issues — this article will suggest you download the latest stable AppImage copy instead.

You'll have to download said AppImage from your browser manually because the actual file URL will change — damn continuous releases! — but once you do that, you can return to the terminal:

# Move the file to the folder containing all the CUETools stuff
# and give it a more predictable name:
mv ~/Downloads/wine-*.AppImage /opt/cuetools/wine.AppImage

# Make it executable.
chmod +x /opt/cuetools/wine.AppImage

The following wrapper script will handle the tedious business of setting up and running CUETools.exe correctly. Just copy-and-paste this script to somewhere like ~/.local/bin/cuetools:

#!/usr/bin/env bash

# Save some typing.
ctDir=/opt/cuetools
ctWine="${ctDir}/wine.AppImage"
export WINEPREFIX="${ctDir}/.wine"

# Set up the prefix if missing.
if [ ! -d "${ctDir}/.wine" ]; then
    echo "Setting up a prefix for CUETools. Stand by!"
    WINEDLLOVERRIDES="mscoree=" WINEARCH=win64 "${ctWine}" wineboot
    "${ctWine}" winetricks -q dotnet48 vcrun2019
fi

# Handle the optional cue sheet path argument, if any.
ctCue=""
if [ -n "$1" ] && [ -f "$1" ]; then
    ctCue="$( "${ctWine}" "winepath.exe" -w "$1" )"
fi

# Run the program!
"${ctWine}" "${ctDir}/CUETools.exe" "${ctCue}"

Just don't forget to make the script executable afterward:

chmod +x ~/.local/bin/cuetools

Assuming ~/.local/bin is in your $PATH — it usually is — you should now be able to run CUETools from the terminal like:

# Just run the program.
cuetools

# Or optionally provide a cue sheet path as the second argument
# to have it automatically set as the initial "Input" source.
cuetools /path/to/album.cue

That's it!

Gotchas

As with anything run via WINE, some quirks are to be expected.

I am currently unable to arbitrarily resize the program window, for example. Luckily, it resizes itself to fit the content, but only just. (It's pretty small.)

It can also have mild freakouts if it remembers a cue sheet path from a previous session that no longer exists. In such cases, close the program, then relaunch it with a new path specified as the second argument.

Other than that, you'll probably want to stick with the basic wav encoder and handle any re-conversion separately (using actual Linux software).4

Verification and Repair

You can play around with the CUETools "Settings" if you want to, but everything needed to initiate a verify/repair operation is toggled from the main screen:

And that's it. Hit "Go" when you're ready.

You'll probably be prompted to confirm the album metadata. I wouldn't waste any time tweaking that data here; just accept the first suggestion that pops up.

In cases where one or more track(s) are inaccurate but can be repaired, CUETools with either handle it automatically or ask you to choose a specific changeset to apply. If prompted, just pick whichever one has the highest confidence.

A summary will appear at the bottom of the main program window once the operation has finished, listing the verification statuses for each track at various offsets.

Confusingly, verification might apply to your original files, or newly-repaired versions produced by CUETools.

The easiest way to figure out which is which is to simply open the "Output" folder.

If there are a bunch of wav files in there, CUETools made repairs. Convert those files to your preferred format and replace your originals.

If there aren't any wav files in there, repair was either unnecessary or impossible. Your originals are what they are.

Closing Thoughts

CUETools' repair won't be able to fix everything.

It can feel a little arbitrary — and it kinda is — but in general, the more accurate your initial data is, and the more popular the album is, the better your chance of success.

But when it does work, it feels like magic. And it's really handy being able to experience that magic from Linux, even with all the WINE nonsense. Haha.

---

1. I have no idea why so many of these sites lack SSL certificates in 2023. Haha.

2. The idea is simple. All CDs from a given pressing begin life identical to one another, but the wear and tear they earn is truly their own. The chances of any two being damaged in exactly the same way are so astronomically remote as to be all but impossible. Therefore, if any two people, let alone hundreds, independently wind up with identical rips, they must be perfect.6

3. Audio CDs essentially do the same thing natively, just not as well.

4. This is partly WINE's fault and partly CUETools's. It handles wav conversion directly, but outsources more complicated processing to separate programs, which may or may not work with WINE, or even be included with CUETools.

5. fre:ac can generate a cue sheet for you automatically as part of the ripping process. Just make sure the corresponding checkbox on the main Joblist screen is checked.

6. That said, both CTDB and AccurateRip must necessarily ignore a few leading and trailing data frames — a tiny fraction of a second — to account for differences in optical drive tolerances, so if there happen to be errors within those margins and nowhere else, the track would still verify.

Josh Stoik
5 July 2023
Previous Disabling Snap, and Keeping It Disabled
Next Introducing Rip Rip Hooray!