A Million Little Pieces Of My Mind

Applications

How Music Minder Works

By: Paul S Cilwa Posted: 9/6/2026 Page Views: 28
Hashtags: #Software #Music #ReplayGain #rsgain #ffmpeg #Loudness #EBUR128 #FLAC #MP3
What Music Minder actually does to your files, in what order, and what it leans on to do it.
Estimated reading time: 8 minute(s) (1719 words)

Music Minder is mostly a conductor. The measuring is done by a program called rsgain and the audio surgery by ffmpeg; Music Minder decides what an 'album' is, what to do to it, in what order, and shows you what's happening, while it's happening. This page is for anyone who wants to know exactly what that means for their files.

What an Album Is

A folder with audio files directly in it. Anything else in the folder—cover art, cue sheets, the ripper's log—is ignored. With Treat Disc 1, Disc 2… folders as one album on, a folder whose subfolders are named CD1, Disc 2, Disk 03 and so on is one album made of all of them, so a box set shares a single album gain. Folders reached through links or junctions are skipped, so the walk can't go round in circles; folders OneDrive is syncing are ordinary folders and are walked normally.

The Order of Work

For each album, in this order:

  1. Trim and fold, if either is on. Each track is analysed, and rewritten only if there is something to do. Any track that was rewritten has its ReplayGain tags deleted, because the figures were for the old audio.
  2. Tags. With Normalize chosen, an album whose tracks all carry a ReplayGain track gain is skipped (unless you've turned that off), otherwise it's measured and tagged. With Remove all ReplayGain tags, the tags are deleted. With Do not normalize, nothing more is done.

Skipping is decided by reading each track's tags, one file open per track, before anything heavier happens—on a network share every file opened costs real time, and a library on its second pass is mostly albums that are already done.

Measuring

Loudness is measured to the EBU R128 standard—the same one broadcasters use to keep adverts from being louder than the programme—by rsgain, which is open source (BSD-2-Clause) and carries FFmpeg for decoding, libebur128 for the measurement and TagLib for the tag writing. Reproducing that in my own code would have meant re-validating all three against the originals; running a 2 MB program per album is the better deal by a very long way.

Music Minder runs rsgain in its "custom" mode with an explicit list of tracks rather than letting it decide what an album is, which is what allows the disc merging and the compilation handling. For an album it asks for album gain, and rsgain writes both album and track tags; for a compilation it asks for track gain only, and no album tag is written—so a player set to album mode finds nothing to use on those tracks and falls back to track gain by itself, without being told anything.

A copy of rsgain ships inside the installer, so it always works. Once a day, the program also asks GitHub whether there's a newer release, and if there is, downloads it into your profile folder, checks that it runs, and uses that instead. If GitHub is down or the download fails, it says so in the status line and carries on with what it has.

Where the Progress Bar Comes From

An oddity worth recording: rsgain prints nothing useful while it works. It reports every track as it starts, all in a rush at the beginning, and then measures in silence; and when its output is going to another program rather than a terminal, it holds all of it back and delivers it in one lump as it exits. So there's no signal in its output to move a progress bar with.

What Windows does keep is a running count of the bytes each process has read from disk. rsgain reads the tracks in the order it's given them, and Music Minder knows the size of every track from the walk it did earlier. So it samples that count a few times a second, and that gives both how far through the album it is and which track it's on. When the count passes the album's total, what's being read is the tags being written, and the label says so.

Trimming

Each track is decoded once by ffmpeg with a silence detector listening: anything under −60 dBFS for at least 0.3 s at the very start or very end counts. That floor is well below where anyone can hear a fade finish. Silence in the middle of a track—the gap before a hidden track, say—is never touched, because it isn't at an end.

The start is cut clean. The end is cut back to the pad you set on the slider, and only if there's at least a quarter-second beyond the pad to remove; rewriting a file to shave a tenth of a second isn't worth the write. A track already cut tight is left alone, and silence is never added: from the file alone, "abrupt because it flows into the next track" and "abrupt because it was trimmed too tight" look identical, so any rule that added silence would put a seam into every crossfade to fix a problem that may not exist.

Albums filed under a classical folder, or whose genre tag says classical, opera, choral and the like, aren't trimmed at all. A rock record's three seconds of dead air after the last chord is dead air; a symphony's three seconds between movements is the composer's.

How the cut is made depends on the format:

  • Lossless (FLAC, WAV, AIFF, Apple Lossless)—decoded, cut to the exact sample, and encoded again in the same format at the same bit depth. The result is bit-for-bit what the original would have been had it been mastered shorter. Tags and embedded cover art come across untouched.
  • Lossy (MP3, AAC, Ogg, Opus, WMA)—cut at frame boundaries with no decoding at all, so there is no second generation of loss. Frames are a few hundredths of a second long, which is precision enough for silence.

Folding

A stereo track is "really mono" when the two channels are the same, and the test is to subtract one from the other and listen to what's left. If that difference averages at least 40 dB below the mix and never rises above −40 dBFS, the channels are the same and the track is folded to one. Genuine stereo, however narrow, fails that test immediately, and stays as it is. Only lossless formats are folded; folding an MP3 would mean encoding it a second time, so those are reported and left alone.

Artist Credits

The rules, in the order they're applied. An artist field is first split on the marks that always separate names—a semicolon, a vertical bar, a backslash, a null character (how some taggers store several values, which one popular editor draws as "//"), and a slash that is spaced or doubled—and then on the bare guest words feat., featuring, ft. and w/. A bracketed clause, in an artist field or a title, may also begin with or duet with: "(with Guest)" is unmistakable. A bare "with" is never a guest—Sleeping With Sirens is a band and "Dancing With Myself" is a song—so "Prince with The NPG" is left for you to decide. A title gives up any bracketed guest clause, wherever it sits, and an unbracketed feat. or ft. clause at its end. Inside a guest clause, commas, ampersands and "and" separate people; outside one they don't, so Earth, Wind & Fire is one act. The names are joined with "; ", each once, and written back as a single value only if the result differs from what was there. The album artist gets the delimiter tidying but never a guest from a title.

Grading

Each track is graded by its bitrate: under 128 kbps is LQ, up to 360 is SQ, up to 1000 is HQ—which is where ordinary CD-rate FLAC lands—and above that is XQ, for genuine hi-res material. The bitrate is read from the file's own header by the same look at its tags that decides whether the album can be skipped, so grading costs no extra trip to the disk; and it is read after any trimming or folding, since folding halves a bitrate and can move a grade.

Each folder that holds tracks is stamped with a Folder.ico—a pie of the four grades at every size Explorer asks for, with the album's cover standing in at 256 pixels—and a desktop.ini that points at the icon, carries the percentages as the tooltip, and records the raw counts under a [NamtiraAudio] section. Both are hidden, and the folder is given the System attribute, which is what makes Explorer read its desktop.ini at all.

Once every album is done, the run walks back up: every folder between an album and the folder you dropped, deepest first, has its subfolders' counts added together and gets an icon of its own. A folder with tracks of its own and albums beneath it—most of the classical composers—gets both. A folder with nothing tallied below it is left alone, so a Photos folder beside the music stays as it was. The grading, the chart and the icon writer live in NamtiraLib, where Analyze Audio now finds them too.

Safety

Every rewrite goes to a temporary file beside the original. The new file is checked for a sensible size and made to play through before it replaces the old one; if anything fails, the temporary file is deleted and the original is exactly as it was. Cancelling in the middle of a track loses nothing. Tags are written by rsgain only after a whole album is measured, so a cancelled album is simply left untagged and picked up next time.

Every run writes a log to %LocalAppData%\Namtira\Music Minder\Logs, with a line for each album and each track that was changed, the reason any compilation or classical decision was made, and anything that went wrong. It opens from the Open log button when a run finishes.

Credits

Loudness measurement by rsgain (complexlogic; BSD-2-Clause), which carries FFmpeg (LGPL), libebur128 (MIT) and TagLib (LGPL). Audio trimming and folding by ffmpeg (GPL). Tags are read with TagLib# (LGPL). The rest is VB.NET on .NET 10 and my own NamtiraLib.