reddit / emacs

EMMS: Sort by `albumartist` in Browser?

MrP3rf3c7 · 2022-04-23 01:58
I’m trying EMMS with `mpd` as a backend and it’s pretty great so far. However, not being able to sort by `albumartist` is a deal breaker for me. I’ve found a [7 year old “answer”](https://www.reddit.com/r/emacs/comments/30u2nj/comment/cpx9vth/?utm_source=share&utm_medium=web2x&context=3) that instead uses the directory names which is both unrobust and does not actually use the tag metadata. I also read a [comment from several years ago](https://www.reddit.com/r/emacs/comments/7mw7ky/comment/dx5fh9h/?utm_source=share&utm_medium=web2x&context=3) in which the poster described setting the default browser view sorting method to albums. This suggested to me that I might be able to use `'info-albumartist` (instead of `'info-album`) from [the EMMS manual](https://www.gnu.org/software/emms/manual/#Defining-Info-Methods) but using the former resulted in `Invalid function: "Can’t sort unknown mapping!"`. It surprises me that no one appears to have solved this by now! Have I missed something? Any help is appreciated. Thank you!
solaryeti · 2022-04-23 08:33
It used to be the case that it indeed took a bit of customisation to get emms to sort by album artist but since release 4.4 (about 4 years ago) emms has defaulted the browser view to album artist (https://git.savannah.gnu.org/cgit/emms.git/tree/NEWS#n145). You can customise it with `emms-browser-get-track-field-function`. Before emms 4.4 I used to use a custom function based on one mentioned on the mailing list: https://lists.gnu.org/archive/html/emms-help/2017-10/msg00025.html However, that has no longer been necessary since 4.4 and, at least for me, the browser mode sorts by album artist without needing any special configuration. I have only used the `mpv` and `vlc` backends but have not used the `mpd` backend so am not sure if it is something specific to that backend? What does your configuration look like? Edit: adjusted wording for clarity
MrP3rf3c7 · 2022-04-23 21:18
Thank you. `emms-browser-get-track-field-function` sounds like what I’m looking for but it didn’t change anything unfortunately. This is my config right now: (use-package emms :config (require 'emms-setup) (require 'emms-player-mpd) (emms-all) ;; (setq emms-browser-default-browse-type 'info-albumartist) (setq emms-browser-get-track-field-function 'emms-browser-get-track-field-albumartist) (setq emms-info-functions '(emms-info-mpd)) (setq emms-player-list '(emms-player-mpd))) I don’t get any errors in the `*Messages*` buffer with this but after running `M-x emms-player-mpd-connect`, `M-x emms-cache-set-from-mpd-all`, and `M-x emms-start-browse`, the browser continues to sort by artist. I don’t know why the `mpd` backend would be different but I suppose it’s a possibility. I use it every day with `ncmpcpp` (sorting by `albumartist`) so it’s likely not issue with the dæmon itself but possibly the way Emacs interfaces with it?
solaryeti · 2022-04-23 21:47
I did a little digging but because I don't use mpd please take this with a grain of salt. I wonder if emms is not getting the albumartist from mpd? It seems that there are a few cases where this might occur. I found this entry on the mailing list that, while fairly old, describes an issue if mpd returns multiple albumartist fields: [https://www.mail-archive.com/emms-help@gnu.org/msg01647.html](https://www.mail-archive.com/emms-help@gnu.org/msg01647.html). I'm not sure if that is still an issue but could be something to check. I also checked the `emms-info-mpd` function and it seems that in some cases, if the `INFO` is specified then it will use that instead of getting it from mpd. But when that `INFO` is specified the function that reads it does not check for the album artist: [https://git.savannah.gnu.org/cgit/emms.git/tree/emms-player-mpd.el#n1126](https://git.savannah.gnu.org/cgit/emms.git/tree/emms-player-mpd.el#n1126) One way we can check if emms is getting the info correctly is to see if the albumartist is listed in the emms cache. Usually that would be found in `emms/cache` which would be located under your emacs directory. Here is an example from my cache where you can see the `info-artist` and `info-albumartist`. They differ but emms browser sorts this for me under the albumartist: (puthash "/home/steven/music/flac/ben_abraham/sirens/09_this_is_on_me.flac" '(*track* (type . file) (name . "/home/steven/music/flac/ben_abraham/sirens/09_this_is_on_me.flac") (info-album . "Sirens") (info-albumartist . "Ben Abraham") (info-artist . "Ben Abraham feat. Sara Bareilles") (info-date . "2016") (info-genre . "Pop") (info-title . "This Is on Me") (info-tracknumber . "9") (info-discnumber . "1") (info-playing-time . 247) (info-mtime 24270 46481 52577 0)) emms-cache-db) If the `info-albumartist` is missing then my guess is that something is going wrong in retrieving that from mpd but if it is there then it something weird is going on with the browser since it should be using that to sort the albums for you.
MrP3rf3c7 · 2022-04-23 22:10
Aha, in my `var/emms/cache`, there is, as you guessed, no `info-albumartist` value. > If the `INFO` is specified then it will use that instead of getting it from mpd. Where would that specified? The only line I have with that function is `(setq emms-info-functions '(emms-info-mpd))`.
solaryeti · 2022-04-24 12:52
The `INFO` would be passed to the function based on how it is called. It's not something you would specify in your config. Are you able to see what metadata mpd returns for the tracks? I wonder if the issue isn't something similar to the one in [https://www.mail-archive.com/emms-help@gnu.org/msg01647.html](https://www.mail-archive.com/emms-help@gnu.org/msg01647.html).
MrP3rf3c7 · 2022-04-24 23:34
I’ve been looking into this a lot over the past couple hours (and broke my config a couple times too :P). The person in that e-mail chain’s problem was because of a double `AlbumArtist` tag on some song(s) but I don’t have those in my `mpd` database. Everything looks fine on that side of things but the generated EMMS cache still doesn’t pull in the `AlbumArtist` data. Also, looking at [this commit](https://git.savannah.gnu.org/cgit/emms.git/commit/?id=2bc4236bb1b1cf1605ea155fb8d22c6b2ab06283), I may not actually need this definition: (setq emms-browser-get-track-field-function 'emms-browser-get-track-field-albumartist) I guess that doesn’t help though considering that there aren’t `info-albumartist` values by which to organize anyway. Edit: I also switched to the ELPA version of EMMS to be sure I’m using a sufficient version.