djcev.com

//

Music File Management 3: Playback with CMUS

Posted by Cameron Vanderzanden on in articles. Source file.
Tags: , , , , , .

CMUS on my computer in Library View playing a song by Aural Float

The C* Music Player (AKA CMUS) is my preferred music player and library program. It's lightweight, highly configurable, and is controlled via the keyboard (all things I like). It works well with my directory structure and standardized tags. And it supports a wide variety of formats & seems to handle large collections well.

This short post will go over my CMUS configuration, including how I have it set up to edit tags from the library views. This is the final part of a three part series, the first part covered how I organize my music files and the second how I manage their tag metadata.

Typical Use & Interface

My typical usage pattern with CMUS is pretty basic. Most of the time I just use it to play music. Occasionally I'll edit tags (usually BPM). When working on mixes I'll flip through a large number of songs and take notes on tracks that I think would combine well.

CMUS on my computer in Sorted Library View playing a song by Aural Float

At the top of this page there's an image of the "Library View", and immediately above this paragraph there's an example image of the "Sorted Library View". Visible in these views are track number, artist name, track title, BPM, key, duration, and more.

In the two-pane Library View you can see a list of artists on the left and a sublist of albums by that artist on the right. In the simpler Sorted Library View you can see a flat list with albumartist and release year visible. This is close to the default config; I have reworked the sort order and the display formats, adding BPM and key, and shortening / truncating some fields to save screen space.

My control and navigation keys are mostly the CMUS default: Vi-style hjkl to move the cursor, number keys to change view, "c"/enter to play the highlighted track, "v" to stop playback, "/" to search, and so on. The default keys are well documented in the CMUS tutorial and CMUS manual.

Editing Tags From CMUS

CMUS allows you to bind keys to run external commands on selected files, passing the filename to the command specified. My tagging script tag_audio.sh has an interactive mode (-e tag) that will prompt the user for a value to set the given tag. These two features combined allow for the convenient editing of tags from CMUS. The relevant commands in my config/cmus/rc look like this:

# tagging keybinds
bind -f common ! run alacritty -e /home/cev/bin/tag_audio.sh -e artist {}
bind -f common @ run alacritty -e /home/cev/bin/tag_audio.sh -e tracktitle {}
bind -f common # run alacritty -e /home/cev/bin/tag_audio.sh -e albumtitle {}
bind -f common $ run alacritty -e /home/cev/bin/tag_audio.sh -e date {}
# ...and so on. "alacritty" is my terminal emulator.
# {} is replaced by the filename(s) of selected tracks.
# See the full list of keybinds in the config/cmus/rc file in my dotfiles.

This means, for example, that pressing "@" in CMUS will open a new terminal window running my tagging script and allow me to edit the "tracktitle" field of the highlighted song. CMUS helpfully rescans the highlighted track and updates its view when the tagging script closes.

This is useful for making small adjustments like correcting spelling mistakes; it's much less useful for mass changes to files (that's a job for the shell). Most of the time I use this to set BPM - I play the track in CMUS, tap out the tempo in another window, hit "^" in CMUS to edit the BPM, punch in the value and hit enter.

Generating & Viewing Spectrograms

Another key bind I have set up is "+" to run a simple shell script that generates and then displays a spectrogram for the selected track. The script is sox_spectrogram.sh and is, as the name suggests, a simple frontend for SoX. (The spectrogram images I use for mixes are generated the same way). The entry for this in config/cmus/rc looks like:

# a simple, direct call to the shell script does fine.
bind -f common + run /home/cev/bin/sox_spectrogram.sh {}

Future Improvements & Closing

One feature I haven't explored but could be useful is playlist editing. CMUS has a nice playlist editor built into it & I believe my DVS system xwax would be able to read the resulting playlists as "crates". That could be the start of a convenient way to take a set of music with me for performances - build a playlist, run a script that copies that playlist and all referenced files onto a flash storage drive, then read that flash storage drive with xwax later.

Anyway, you can find my CMUS configuration file and theme file in my dotfiles repo. I hope they might be useful to someone, if nothing else then as an example of what's possible with this program.

And this third labored explanation concludes the (poorly named) Music File Management series. File layouts, naming conventions, tagging schemes, some convenience scripts, and some opensource tools that I use to accomplish the same work as much larger programs.

Responses

If you've written a response to this post then please let me know the URL:

You can also submit a "comment" webmention by pressing the button below. It may take a day or two for your comment to appear here and a copy of your comment will be stored at commentpara.de.