1.0 What is MAXV?
For reasons that needn’t detain us, loudness (measured in “decibels”, abbreviated as “dB”) in music recordings is usually worked on a negative scale, where 0 dB is the loudest and -1 dB is a little bit quieter and -11dB is considerably quieter than that and so on.
In theory, a CD recording should have its loudest music recorded at 0dB. That would be the theoretical maximum volume an audio signal could get without introducing ‘clipping’ or other distortion.
Quite often, however, and usually for various technical reasons to do with the need to prevent complex digital recording and processing equipment introducing audible artefacts into a music signal, CD recordings are sometimes mastered at levels much lower than 0dB.
Famously, for example, SACD recordings are generally recorded with an absolute reduction in volume of around -6dB. The result is that an SACD recording ripped to a hard drive will sound considerably fainter than it really ought to.
You will also sometimes find ordinary CDs which have two or more works supplied on the one disc -and the same volume constraint has been applied to all of them, disc-wide, instead of different volume levels being applied to each work individually. Imagine a CD containing a large symphony and a spinet sonata: if you applied the same volume setting to the entire disk, the loudest parts of the symphony might well come in at near 0dB, but the quietest parts of the spinet sonata might then be coming in at -20dB, making it practically inaudible!
Fortunately, such mastering horrors on ordinary CDs are fairly rare these days, in my experience -but they do still exist, especially if you are in the habit of buying second-hand CDs from charity shops: they will often be fairly old, and so date from early on in the CD era, when digital techniques were not quite so well mastered as they are nowadays!
So I wanted a tool that could simply boost the volume levels of all tracks in a folder in a consistent way that wouldn’t introduce new distortion or audible artefacts.
That tool is MAXV.
MAXV first analyses all music files located in a folder. It determines the absolute peak volume of the loudest of those tracks. If that volume level is considerably less than 0dB, it will then boost the volume of the audio signal in all tracks by whatever fixed amount is needed to get the loudest track to nearly 0dB. (For safety reasons and out of an abundance of caution, MAXV seeks to get the loudest tracks to -0.5dB, not actually 0, but it’s close enough!)
2.0 Obtaining and Installing MAXV
MAXV is a simple Bash script. You can download it by clicking this link. Once downloaded (and I shall assume you download to a folder called ‘Downloads’ within your $HOME folder), issue these three commands at a new terminal session:
sudo mv $HOME/Downloads/maxv.sh /usr/bin sudo chmod +x /usr/bin/maxv.sh sudo ln -s /usr/bin/maxv.sh /usr/bin/maxv
That is, as root, you move the downloaded file into the /usr/bin folder; you make it executable; and finally you create a link to the executable that lacks the ‘.sh’ extension, so that you can invoke the program just by typing ‘maxv’ rather than ‘maxv.sh’.
Since MAXV is simply a Bash shell script, you are encouraged to open the downloaded file in the text editor of your choice and inspect it, to satisfy yourself that it does what it says it will do and nothing more.
2.1 First Run
Once installed, MAXV needs to be run (by typing maxv) in a folder containing FLAC music files. It won’t work outside such a folder, nor will it work in a folder containing, say, MP3 or APE music files: only FLAC files need apply! If you try running the utility in a folder that lacks FLACs, you’ll see this:
Assuming there are some FLACs present when first run, MAXV will begin by analysing your system to determine if necessary prerequisite software is present:
That’s an example from a system running Fedora -so, MAXV knows to prompt you to install missing packages with the ‘sudo dnf install’ command. On Ubuntu, it will tell you to use ‘sudo apt install’ and on OpenSuse, it will tell you to use ‘sudo zypper in’… and so on. It’s main-distro-aware, in other words, and will provide distro-appropriate prompts whenever it can.
Notice, too, in this specific example, that MAXV knows the ffmpeg package it needs can only be installed on Fedora if the RPM Fusion repository has been enabled. You can do that with these two commands:
sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
On OpenSuse, you will receive a similar extra message telling you to install the Packman repository (for the same sorts of reasons that Fedora needs the RPM Fusion one!). That’s done with the following one-liner:
sudo zypper ar -cfp 90 http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Leap_15.2/ packman
With that repository enabled, you can re-run MAXV and again see the ‘you are missing software’ warning -but the command to install it all will now be capable of completing successfully!
2.2 Subsequent Runs
If you have installed the prerequisite software and are running MAXV in a folder full of FLAC files, you’ll see the program do its work something like this:
The program doesn’t prompt you or anything like that: it simply gets straight to work analysing each of the FLAC files found. You’ll notice that as it checks each track, it displays a number at the end of each line of output: that number is the peak decibel level of the track in question. Though the numbers are displayed without negative signs in front of them, they are actually negative values, where 0 represents the loudest a track could possibly be and a value of 9 being a very quiet track and a value of 19 being practically inaudible.
In the example shown here, therefore, we see that track 1 is already at volume 0: it’s as loud as it can possibly be, so no volume boost can be applied to it without distorting the audio signal. So even though track 2 is significantly quieter than track 1 (having a peak volume of 3.6dB below 0), it can’t be volume-boosted without altering the relative loudness between tracks 1 and 2. Similarly, whilst all the other tracks could be volume boosted by various amounts, to do so would be to change the relative loudness of the four tracks of this symphony’s recording, and MAXV will never do that. Accordingly, you get a message that because 1 track is already as loud as it can be, no tracks can be volume-boosted: the overall loudness for all tracks is already optimised.
2.3 A Volume-Boosting Example
In a different run of the MAXV utility, using a different symphony’s recording, I get this output:
Again, the utility simply gets down to analysing each track’s loudness without prompting. In this case, it notices that all four tracks are quite a bit off the theoretical maximum of zero decibels. The loudest track is actually track 3 -a 0.9dB level is quite close to zero, but still quite a bit away from it.
MAXV therefore offers to boost the audio in all tracks (so as to maintain inter-track relative loudness) by whatever it takes to get track 3 to its maximum possible loudness.
You get to choose whether you want this volume boost applied or not.
If you don’t want it applied, just type ‘n’ and press [Enter]. The default is ‘Y’, yes, please apply the volume boost, so you can just press [Enter] on its own to accept that (or type ‘y’ and [Enter] if you prefer). If you choose to volume-boost, this happens:
Firstly, MAXV re-computes the volume boost amount. Though it knows that a 0.9dB boost would get track 3 to the ‘ideal’ zero level, it is more cautious than that and knocks 0.5dB off that possible boost to be on the safe side. It thus goes ahead and applies a 0.4dB boost instead, to every track in the folder. That is enough to lift track 3 from -0.9dB to -0.5dB, getting it closer to the zero mark; but it uplifts the other tracks too, by the same amount (so track 1 would go from being -2.2dB to -1.8dB, for example).
Because of this 0.5dB ‘safety cushion’, MAXV won’t bother to offer a volume boost if it ever discovers the loudest track in a folder is already within 0.5dB of zero. If peak volume is, for example, discovered to be 0.3, it will just say ‘the volume levels are already optimised’, because it can’t apply a meaningful boost to a track that’s already within 0.5dB of zero.
After a volume boost has been applied to music tracks in a folder, this is the result:
Notice that the four original tracks of the symphony (here called ‘split-track-<something>) have been joined by four new tracks called ‘-.4-dB-<something>’.
That is, the non-volume-boosted original files remain, unaltered, just as they were originally ripped or supplied. But four additional files now exist, with filename prefixes that match the volume-boost that MAXV has just applied (so, in this case, given that a +0.4dB volume boost was applied, all the files have .4-dB prefixes.
MAXV never destroys the original files, in other words.
The original files are always left behind so that you can listen to the new files and compare them to the originals and satisfy yourself that a meaningful volume boost has taken place without introducing audible distortion or artefacts.
If you were to re-run MAXV at this point, it will only notice the existence of the original files: it is blind to any file whose name contains a ‘-dB-‘ string in it, anywhere. Therefore, a second run of MAXV in the same folder will detect exactly the same volume levels in the still-present original files as before and will thus create a new set of volume-adjusted files with precisely the same names as before. The newly-boosted files will therefore simply over-write the previously-boosted ones.
If you dislike the effect of the volume boost, just use your file manager to select-and-delete the ‘+dB’ prefixed files. If you prefer the volume-boosted ones, use your file manager to delete the non-prefixed originals. In every case, you delete the files you no longer want to retain. MAXV never deletes anything for you -making it entirely safe to run at all times.
(Incidentally, if you dislike the look of the volume-boosted file names, you could use CCDT option 7 to alter the names to be whatever the track’s ALBUM tag is, as would be normal practice; or use CCDT to assign an ALBUM tag to a file in the first place. In either case, CCDT will get the physical file names looking normal again).
3.0 General Usage Notes
MAXV takes no run-time arguments, parameters or switches. Simply type ‘maxv’ in a folder full of FLACs, and it will do its work.
MAXV only works on FLACs, not on any other type of audio format (so, no APE, MP3, OGG or other formats are supported).
If you ask it to do a volume boost, MAXV always outputs 16-bit, 44.1KHz sample rate 2-channel FLAC files (the same sort as you’d get if you ripped an ordinary CD).
MAXV never destroys, deletes or alters original input files. Those are always preserved, even if a volume boost is applied to copies of them, which are made dynamically. Thus, if a volume-boost is applied, two sets of FLAC files will result: the originals and the volume-boosted copies. Deciding which of the two sets to keep is entirely down to you and requires manual file deletion of the unwanted set, using whatever file management tools you’re comfortable with.
MAXV will compute a volume boost amount that will make the loudest file in a folder get to -0.5dB, which is just shy of the absolute loudest non-distorted volume theoretically possible of 0dB. Any folder that contains a file with a pre-existing maximum volume of 0 to -0.5dB cannot therefore be volume-boosted further, and MAXV will declare such a folder to be already volume-optimised.
MAXV never adjusts relative volumes. Since it applies a fixed volume-boost to all tracks equally, whilst the absolute volume of all tracks will increase, their relative differences are retained. That is, if you had tracks at -7, -3 and -2dB, you will end up with tracks at -5.5, -1.5, -0.5dB. There was a 1dB difference between the last two tracks before the volume boost: there remains a 1dB difference between those same tracks after the volume boost. The original 4dB difference between tracks 1 and 2 is similarly preserved after boosting.
Common sense dictates that you should use MAXV after you have separated the compositions contained on a single CD into separate folders. If a CD contains a loud symphony and a quiet sonata, then having all files in one folder will mean that the sonata can only be volume boosted by whatever small volume-boost that the already-loud symphony can take. Split the two works into separate folders, however, and the loud symphony can get a small MAXV boost, and the quiet sonata can get a much bigger MAXV boost. This of course changes the relative loudness between the two works -but since they are entirely independent compositions, this seems quite a reasonable thing to do!
4.0 Housekeeping and Legal Stuff
MAXV was devised and written by Howard Rogers ([email protected]).
MAXV is copyright © Howard Rogers 2020, but is made available freely under the GPL v2.0 only. That license may be downloaded here.
Bugs Tracking, Feature Requests, Comments
There is no formal mechanism for reporting and tracking bugs, feature requests or general comments. But you are very welcome to email your comments to [email protected]