How I Organize and Play My Music

I’m an avid music enjoyer, so, in response to Mir’s guide on managing music, I’m going to share how I do it at scale.

I. Format

I am an audiophile, no two ways about it. I have to study music, and streaming does not cut it where dynamic range is concerned. Spotify actually maintains a good bit of fidelity and stereo width, but it does not maintain dynamic contrast, which is the thing music is supposed to do. Where silence is ordinary, music occupies the space silence once took, and so contrast between total quiet and maximum loudness is the thing music does.

This is why, for me, .flac and 320kbps mp3 are the only formats for me. mp3’s are growing on me! They’re compact and portable and don’t skimp on quality, width, or dynamacism. For archival purposes, I keep my own music in .flac format, because it is lossless. It is still compressed, but the full quality version can be reconstructed from it, where 320’s cannot fully recreate the original file.

II. Listening

I carry a .mp3 player on me at all times. It’s a Sansa Sandisk Fuze+, running Rockbox. If you haven’t heard of Rockbox, now you have. Need you know more than it runs Doom out of the box? It supports “sideloaded” content, basically anything format you can get your hands on will play (including more obscure audiobook formats). And the themes rock.

III. Getting files

I won’t condone piracy… oh, who am I kidding, yes I will! Soulseek is awesome. I host a ton of files on there (you can find me @julia420). I download a ton of files on there. It’s great. Be sure to share what you download. Don’t be a leech.

IV. Library Management

This has been my biggest roadblock. At first, I was streaming everything from my Jellyfin server, which conveniently organizes my library using the Musicbrainz API. So, I mostly had a stack of albums loosely organized into genres at random, including some 300 jazz albums. This has gotten unweildy, and I have to organize my library beyond this. Don’t be stupid like me. Organize your albums by artist -> album. I also have a stack of DJ mixes I like to throw on, which go in the mixes folder. It’s nice.

Now, here’s the really annoying part. Since I keep flacs, I want a portable version of my library for the mp3 player. So, I had to write a little bit of python to convert my library to mp3. Sounds annoying, and that’s because it is. It’s total spaghetti:

def main(path):
    filetypes = [".mp3", ".flac", ".wav", ".jpg", ".png"]
    commands = []
    for root, dirs, files in os.walk(path):
        for n in files:
            fp = os.path.join(root, n)
            if list_element_subarray(fp, filetypes):
                filename, extension = os.path.splitext(fp)
                match extension:
                    case ".mp3":
                        copy_file(fp)
                    case ".flac":
                        commands.append(convert_file(fp))
                    case ".wav":
                        commands.append(convert_file(fp))
                    case ".jpg" | ".png":
                        copy_file(fp)

    max_workers = 25
    with ThreadPoolExecutor(max_workers=max_workers) as executor:
        futures = [executor.submit(subprocess.run, cmd) for cmd in commands]
        for f in futures:
            f.result() 

Here, I use ThreadPoolExecutor to run 25 parallel threads that convert files.


def convert_file(path):
    filename, extension = os.path.splitext(path)
    # get the name of the file w/extension

    # of the form ../music/[etc]
    # to the form ../music-mp3/[etc]
    input_file = path.split("/")
    output_file = input_file.copy()
    output_file[1] = "music-mp3"

    # lmao this is so sloppy but it works
    final_output = ""

    for i in output_file:
        final_output += i
        final_output += "/"

    final_output = final_output[:-1]

    final_output = os.path.splitext(final_output)[0] + ".mp3"
    p = Path(final_output)
    if not p.exists():
        final_dir = ""
        for i in final_output.split("/")[:-1]:
            final_dir = final_dir + i + "/"
        
        newpath = Path(final_dir)
        os.makedirs(newpath, exist_ok=True)
        command = ["ffmpeg", "-n", "-i", path, "-b:a", "320k", final_output]
        print(command)
        return command
    else:
        print(["echo", '"File "', final_output, '" already exists."'])
        return ["echo", '"File "', final_output, '" already exists."']

Here, I mirror my music directory’s structure with an equivalent folder for mp3. If the file doesn’t exist, I return a string array containing a bash script for an ffmpeg command that I run with py’s subprocess library. Yes, this is injectible. No, I don’t care. Yes, this is sloppy, yes I could have used Pathlib. No, I don’t care!

V. Conclusion

There you have it. That’s how I escaped the Spotify matrix. Hopefully you can too. Spotify is evil. I will probably write an article on this too, except that Benn Jordan already said everything I could ever say. Bye <3

2 Comments

  • woag this is cool! i may have to start doing some of this stuff (mostly for the principle since i dont super care about quality)

    • yeah, I care about quality because I’m like, a professional, you know? so do what works for you! but, I highly recommend you try a high quality version of an album you really like, especially stuff native to vinyl. hearing pink floyd uncompressed was lifechanging when i was a kid

Leave a Reply to nerdmusicdotnet Cancel reply

Your email address will not be published. Required fields are marked *