FS#9613 - Allow formatting of track names for the default <All Tracks> database menus
Opened by Justin Gan (jgrg1) - Monday, 08 December 2008, 12:50 GMT
Last edited by sideral (sideral) - Monday, 01 August 2011, 15:31 GMT
By default, whenever you choose the <All Tracks> option from the database menu, the list of results returned defaults to the standard track name format, i.e. "%02d. %s" tracknum title. What I wanted was to be able to define the format that gets applied to the <All Tracks> option, dependent on the current menu level. So for example, if I had browsed to genre->artist-><All Tracks> it would return the list of all tracks for all artists for the given genre and I wanted the track names to be formated with:
"%s %s %02d. %s" artist album tracknum title
and then sorted into order, since I already know what genre the tracks are for.
Similarly, if I simply browsed to genre->artist->album-><All Tracks>, it would return the list of all tracks for the selected genre and artist, but I want the track names to be formated with:
"%s %02d. %s" album tracknum title
so when it's sorted, I get the tracks grouped only by album and tracknumber, since I already know what artist the tracks are for.
This patch attempts to address this issue by allowing users to define custom <All Tracks> formats in the tagnavi_custom.config file. Thus, sort order can be controlled by how you format the track names, just as it works in base Rockbox.
The premise behind the code is that if the <All Tracks> menu option is chosen, Rockbox will look for formats with a certain naming convention defined by concatenating the tag names of the parent menu levels with "." characters and finally appending an ".All" identifier. So in the first example above where we had browsed to genre->artist-><All Tracks>, Rockbox will look for all formats called:
and then cycle through them to see if the appropriate clauses defined on the format are met. Similarly, for the second example where we had browsed to genre->artist->album-><All Tracks>, Rockbox will look for the format called:
As in base Rockbox, it will cycle through all applicable formats and apply the first format it comes across that meets all the clauses defined on the format. One minor change I had to make to get the relevant tags loaded for the search results was to add the tags defined in the clauses of all matching format names to the tagcache search, but not add the clauses themselves.
So now, in the tagnavi_custom.config file to illustrate the first example, I have defined 4 formats called "genre.artist.All" to format the final display name based on whether the artist/album tags are actually defined on the mp3's in the database.
%format "genre.artist.All" "%s - %s - %02d. %s" artist album tracknum title ? artist !~ "<Untagged>" album !~ "<Untagged>" tracknum > "0"
%format "genre.artist.All" "%s - %02d. %s" album tracknum title ? album !~ "<Untagged>" tracknum > "0"
%format "genre.artist.All" "%s - %02d. %s" artist tracknum title ? artist !~ "<Untagged>" tracknum > "0"
%format "genre.artist.All" "%02d. %s" tracknum title ? tracknum > "0"
The downside of this approach is that in order to have this style of functionality for every <All Tracks> menu option, I defined a lot of formats. As such, I had to increase the maximum number of formats from 32 to 96 in order to cope with my formatting schemes. I also increased the maximum number of tag filters from 4 to 8. Now this obviously increases the amount of memory allocated for formats, which will have an impact on available audio buffer size. The attached tagnavi_custom.config file shows the various "All" formats I've added and it's pretty comprehensive in the way it handles missing tags, so technically, if your music library is properly tagged, you should never need all of the formats so you could easily reduce the maximum number of formats.
My principal concern with this patch is in terms of the memory usage of increasing the maximum number of formats and number of tag filters allowed. I'm not aware of a memory profiler for cygwin, but then I hadn't used cygwin before playing with Rockbox - so any pointers would be helpful.
The second piece of functionality I wanted was in the handling of the "strip" functionality. Base Rockbox has an all or nothing approach; if the global format found for the list of tracks contains a strip modifier, then it applies the strip to ALL track names, even if the subsequent formatting of the track does not contain a strip modifier. I wanted Rockbox to only strip tracknames if a strip modifier was defined on the format that is applied to the track. This patch fixes this problem.
This works fine on my Sansa e280 with a full 8Gb drive and a full 2Gb micro-SD card. It's formatted close to 1000 tracks with no noticeable difference in processing time, and I've not come across any out of memory errors on my e280, but I haven't tested it on any other mp3 player so I would recommend you test this first using the appropriate simulator.
Note that this patch incorporates the year album patch