Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How can I create a genre hierarchy? (Read 1452 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How can I create a genre hierarchy?

Hello there, i want to create a sort of genre tree which would contain a subgenre based hierarchy. Currently I’m using the genre database of rateyourmusic.com as a starting point. Roon is one option that has a hierarchical system for genres, but fiddling with it is convoluted, and unfortunately it doesn’t support multiple top level genres (for example, I would want EDM to be under both the Electronic and Dance genres, same situation with fusion genres like Pop Rock)

How would I achieve this? Thanks

Re: How can I create a genre hierarchy?

Reply #1
How about a tree pattern that begins with ...

Code: [Select]
%<genre>%|%<style>%|%<artist>% ...

(etc)

If using the default Album List (DUI), the tree patterns are in Preferences > Media Library > Album List. Using angled brackets < > here will show multi-value tags individually.

Then just a matter of tagging your files. Make sure both GENRE and STYLE tags (or whatever tag you use for "sub-genre") are correctly split for multi-values - you may have to right-click tracks > Properties > right-click field > Split Values...

^ You can also add your multi-value fields to Preferences > Advanced > Display > Properties Dialog > Multi-value Fields, so they would be split automatically when new values are added.

Re: How can I create a genre hierarchy?

Reply #2
Wonderful idea! However I would like to go several layers deep and not just one.

For example:
Electronic > Electronic Dance Music > Drum and Bass > Atmospheric Drum and Bass

As far as I know the styles tag only goes one layer deep. I’d love to be proven wrong on this tho!

Re: How can I create a genre hierarchy?

Reply #3
This is the method I use. Using CUI library tree (not the spm version) it looks like this:



It goes 5 levels deep. The arrows refer to tracks of the level above only without including sub levels.
The way it works for me is a bit complex and I doubt it would be useful to you but I'll explain just to give you some ideas.
First I use a non multivalue tag like this:

Synthwave/ Retrowave/ Synth Music/ Electronic/ Synthwave-Retrowave Group/ Standard Cluster

Using mass tagger this gets converted to a multivalue tag and becomes this:

Electronic; Synth Music; Retrowave; Synthwave; Synthwave; 510603358; 237321459; 515415001; 2231392115; 2231392115; Retrowave; 515415001; Synthwave; 2231392115; ‡; ‡; Synthwave-Retrowave Group; 997961717; Standard Cluster; 3138389246

The numbers are for sqlite database purposes, the ‡ are filler places not used. This is essentially like an array where each level has its own specific place even if not all levels are used (minimum is 2 levels).

Why have it two times with one multivalue one not multivalue? Because only non multivalue can be an autocomplete value, multivalue can't. So for consistency in tagging I would just start typing "Synthwa....." and the autocomplete would fill in all the rest.
The converted multivalue tag is used for 3 purposes. One I use it in an sqlite database so each value can be split up. The other reason is I can do specific quicksearch searches (search for same) for any specific level which is not possible with non multivalue.
And finally it's the multivalue tag that builds the tree. I mainly use rateyourmusic as a source for building my genre tree.

I prefer this method because It allows me to either search for example everything alt rock or just be specific to an alt rock subgenre like post-grunge. I can choose for any current song I listen to to search for similar very specifically or very broadly with a simple right click. Another convenient thing is I can simply build a genre tree with different structures and don't have to change any of my tagging methods. For example one top level with all beneath sublevels grouped as one under the same top level.


Components used:
foo_quicksearch
foo_uie_library_tree (CUI component)


BTW, your suggestion in your post has this:

Electronic > Electronic Dance Music > Drum and Bass > Atmospheric Drum and Bass

Don't do that, make it like this:

Atmospheric Drum and Bass > Drum and Bass > Electronic Dance Music > Electronic

If you want to use autocomplete and you start typing "Electronic....."  you'll get every suggestion starting with that. You'll be much faster finding your specific tag starting with "Atmosphe....". Use multivalue converted tag to build tree. If you don't think the autocomplete is necessary you'll run into inconsistencies the more genre types you add since I doubt you'd be able to remember every specific genre and it level structure. Mine has about 1200 different structures (some go 5 deep, which is rare and some go only 2 deep. But most are 3 deep).

Re: How can I create a genre hierarchy?

Reply #4
This seems perfect and looks like pretty much precisely what I want with my collection. However I don’t really understand how to tag my files to look like that, excuse my limited understanding.

Can I please get a more simplified explanation on how to prepare my tracks for this kind of hierarchy system?

Does the CUI library tree, which I haven’t used until now, support layers? I’ve until now used the default UI library tree so this is news to me. And I don’t quite understand what mass tagged does there. Thank you so much

Re: How can I create a genre hierarchy?

Reply #5
@jazzthieve wow, that's impressive, especially the nifty details for making autocomplete + flexible nesting depth work! How much hand-work is needed in practice to "round-trip" one tag change? Any helper scripts needed or is it just masstagger + foo_run and two keyboard shortcuts, I guess?

@Theboombringer1: Here are my 2cts, which are a bit less involved than the last poster. I - for some years - tried a two-levelled approach using Genre (10 broad categories, exactly 1 value per album/release) and Style (roughly subgenres, over 60 different values, from 1 to many values per release) with a collection of about 5000 releases. Problems: hard to keep a coherent collection of tagging standards, mixture of tag types (instruments, vocal, regional tags) bordering on a self-made folksonomy that got more and more tedious to maintain, while offering little benefits for discovery (at least for me). I used allmusic as my tag inspiration at the start, and converted to Discogs over the years, while adding mostly manual tagging in the end.

Fast forward to today: I am back to a single Genre tag, 1 value per release, but currently just over 70, hand-picked values which formed as I re-sorted (and slightly shrinked) my whole music collection. With the common %genre%/%artist%/%album% file pattern, this allows me to quickly browse through manageable amount of items (< 100) per directory level.

 

Re: How can I create a genre hierarchy?

Reply #6
First off, this is using a CUI component (library tree) so you need to be using a CUI (colums ui) config. You'd also need to familiarize yourself with using masstagger. There is a learning curve.

It's kinda useless to start explaining if you're not even using CUI. My post is to merely show you the idea and principles for you to work on. For what it's worth here are some basics:

In masstagger split the non-multivalue tag, lets call it genre_tree, up using "split field by separator". After this you'll you have a multivalue tag, lets call this genre_array. In library tree you can now build your tree using
Code: [Select]
$meta(genre_array,4)\$meta(genre_array,3)\$meta(genre_array,2)\$meta(genre_array,1)\$meta(genre_array,0)
This is an example for 5 levels deep. The tricky part is to have it be consistent even if it's not 5 levels deep but only 2 or 4.

Basically you'll have to count the amount of separate multivalues to see how deep the levels go and then construct for each depth their own structure in the tree. This requires titleformatting knowledge.
The function
Code: [Select]
$meta_num(X) 
will give you amount of multivalues within a tag so $meta_num(genre_array) with value Atmospheric Drum and Bass; Drum and Bass; Electronic Dance Music; Electronic will return 4.


Re: How can I create a genre hierarchy?

Reply #7
@ojdo no, far more easier.

first of course I put in my genre tag like this:



Then I delete a different tag called %foo_id%, in the background I have spm panel which launches a specific masstagger script when %foo_id% is no present anymore. This is the spm code:

Code: [Select]
function on_metadb_changed(handle_list){
   filtered_handle_list = fb.GetQueryItems(handle_list, "%foo_id% MISSING")
   if (filtered_handle_list.Count > 0) fb.RunContextCommandWithMetadb("Tagging/Scripts/FOO_IDs", filtered_handle_list , 8)
   }

courtesy of @davideleo for helping me out with this last year.
This masstagger script takes care of the genre splitting and building genre_array. It also does many other things, might as well use the opportunity to do several things in one go. It also of course rebuilds %foo_id%.

Re: How can I create a genre hierarchy?

Reply #8
My suggestion would be to forget rigid tree structures and start using filter-based UIs. That means Facets or Columns UI filter panels.

For tagging of music, think more in terms of creating a summary of notable elements. You mentioned EDM, so you would tag your song as "Electronic; Dance". If you need more details to differentiate between different EDM tracks, you can add Eurobeat, Dubstep or something else accordingly. You can even add country of origin (e.g. Japan) if you find that helps you personally. Maybe even tag if the music is good for casual listening or not.

Alway try starting with the broadest terms and hone in with each additional word added. E.g.: "Electronic; Dance; Drum and Bass; Atmospheric; Japan; Easy listening". The exact order and terminology is up to you. Use words that are meaningful to you. Remember that you can always add more detail later.

Then, you can easily retrieve any subset of tracks by simply adding up search terms. You want all your EDM tracks? Thats Electronic + Dance. You want dubstep only? Filter for dubstep. You want Metal with Electronic elements? Metal + Electronic. How about EDM from Japan thats good for casual listening? You get the idea.

If you end up with too many tags, you might find introducing a two-level structure to be beneficial. First level can be big umbrella genres likes Electronic, Rock or Classical (a track can still have any combination of these as a lot of bands dont fit neatly into one or the other). Then a second tag (like styles) containing details to narrow things even more (sub-genres, instruments, mood, whatever).

Re: How can I create a genre hierarchy?

Reply #9
 It's not rigid, it's flexible of applied the right titleformatting. From the array I could just each time select a specific level or can just select the last applicable level and mix it up without any specific ties to any above level.
The fun part is I can use the structure or totally not use it but it's there when I want to. I also use filters in the manner you describe, but I can use both a rigid tree structure or a flexible filter structure with the same system (plus added elements such as country, decade, mood,....)

When building the array with masstagger there's a specific part in the array that always looks at the most detailed applicable genre and assigns it a specific place in that array.

For example this: %gl_string%
Fado de Coimbra/ Fado/ Portugese Folk/ European Music/ Regional (5 levels)
Bluegrass Gospel/ Bluegrass/ Traditional Country/ Country (4 levels)
Glam Rock/ Rock (2 levels)

No matter if it's 2,3,4 or 5 levels. The first value will always be put in the same place in the array %gl_array% which means I can just mix up all genres to its most and less detailed designation and drop that into a filer If I want to. Not rigid, flexible.

Re: How can I create a genre hierarchy?

Reply #10
Wonderful idea! However I would like to go several layers deep and not just one.

Obviously jazzthieve' method is on the advanced end of scale, though some brilliant tricks there.

However we might suppose some of that could be difficult for most users, so just to follow up my original line of thought... Album List (and probably any other tree library viewer) can show conditional branches.

Suppose your tags are like this (multi-value) -

GENRE: Electronic; Dance
STYLE: Electronic Dance Music; Drum and Bass; Atmospheric Drum and Bass

Your tree pattern / structure could be like this -

Code: [Select]
%<genre>%[| · $meta(style,0)][| · $meta(style,1)][| · $meta(style,2)]|[%album artist% - ]%album%|[[%discnumber%.]%tracknumber%. ][%track artist% - ]%title%

^ Tags inside the square brackets [ ] are only shown if the tag/value exists. Placing the tree branch character | inside square brackets as well, does the same for each tree level or "sub-genre", creating the hierarchy only where tagged. (This example goes three levels deep, you can add more if needed with continued $meta numbers)

Placing a space and/or other character, like a bullet point, in front of each style in the tree pattern above, ensures they are sorted at the top of the level. Followed by artist names (etc) under the level they are tagged. (Spaces are sorted before alpha-numeric)

Now the caveats are exactly what ojdo said above: the tag structure needs to be consistent across same STYLE albums. If one album has the STYLE tags in a different order, it would not show up in the same hierarchy. Perhaps if you are detail oriented enough person to want to tag hundreds of sub-genres, you could make it work. ;)

Possibly jazzthieve' auto-complete trick could be used here as well - keeping a non multi-value tag in reverse order (so auto-complete works, to help remember tag structure for you), and run a masstagger script to set STYLE tag in correct order afterwards. (?)

Secondly, all genre/style tags would have to be album wide - the same values for ALL tracks per album. Otherwise an album could end up split across different tree levels. This would probably be standard requirement for such tagging anyway.

(Unfortunately my STYLE tags are exactly the opposite of that - I use per album GENRE and per track STYLE tags (with various track specific values besides style, such as 'Instrumental', 'Remix', etc), so I cannot really show you a nice screenshot of how the above tree would look. Which also I should point out is entirely in theory; there may well be issues. Consider with the correct tagging it should look similar to that jazz screenshot above, I think...)

Re: How can I create a genre hierarchy?

Reply #11
This seems perfect and looks like pretty much precisely what I want with my collection.
More a conceptual as opposed to mechanics post, but before 'style' became a widely used tag, for those who wanted more specific aural grouping would link genre and style as one tag w/a separator (like so below). Given the fact most every style is related to one specific (parent) genre, I've yet to see much in the way of benefit by splitting parent genre and subgenres (styles) into two different tags. (But am always open to reconsidering that position)
A foobar enthusiast who's neither an audiophile, nor an album snob...Ever notice whenever there is a thread mentioning track ratings, someone will inevitably come in to post that they don't use ratings or believe in rating music?

Re: How can I create a genre hierarchy?

Reply #12
My suggestion would be to forget rigid tree structures and start using filter-based UIs. That means Facets or Columns UI filter panels.

For tagging of music, think more in terms of creating a summary of notable elements. You mentioned EDM, so you would tag your song as "Electronic; Dance". If you need more details to differentiate between different EDM tracks, you can add Eurobeat, Dubstep or something else accordingly. You can even add country of origin (e.g. Japan) if you find that helps you personally. Maybe even tag if the music is good for casual listening or not.

Alway try starting with the broadest terms and hone in with each additional word added. E.g.: "Electronic; Dance; Drum and Bass; Atmospheric; Japan; Easy listening". The exact order and terminology is up to you. Use words that are meaningful to you. Remember that you can always add more detail later.

Then, you can easily retrieve any subset of tracks by simply adding up search terms. You want all your EDM tracks? Thats Electronic + Dance. You want dubstep only? Filter for dubstep. You want Metal with Electronic elements? Metal + Electronic. How about EDM from Japan thats good for casual listening? You get the idea.

If you end up with too many tags, you might find introducing a two-level structure to be beneficial. First level can be big umbrella genres likes Electronic, Rock or Classical (a track can still have any combination of these as a lot of bands dont fit neatly into one or the other). Then a second tag (like styles) containing details to narrow things even more (sub-genres, instruments, mood, whatever).

To show how that works, here are some screenshots:
Spoiler (click to show/hide)
- Tracks have multivalued "genre" and "style" tags.
- Note the facets/filter approach allows "styles" to be present in multiple genres at the same time.
- Thare are no "levels". Column placement indicates filtering precedence. i.e. when Genre is first, then that's the top level... but the other columns may all be set to "style".
- Levels are replaced with multi-tags. You can select an style at the second column and then the third one shows all remaining styles which are also tagged along the first one. You could tag "techno" only to "electronic" tracks, so that becomes effectively a level, but if you add such tag to a rock track too it works the same without having to rewrite the entire tree format.
- Works the same on TF panels, where you can automatically create a tree with genre/styles without a pre-defined structure. Note a style may be in multiple top level genres at the same time.
Code: [Select]
%<genre>%$if(%<style>%,|%<style>%,|-----)|%<artist>% - %date% - %album%|[%tracknumber%.] %title%
- You loose on style nesting, but you win on genre/style definition. A track may have multiple genres at the same time (for ex. blues and rock), so styles belong in fact to multiple genres in some occasions. This allows to better define a track just by adding more and more metadata instead of trying to classify it with 1 - 2 limited keys. This is a more realistic approach to music than strict categorization.
- The reverse tree, where you can see styles first and then all genres containing them can also be created in TF easily.
Code: [Select]
%<style>%$if(%<genre>%,|%<genre>%,|-----)|%<artist>% - %date% - %album%|[%tracknumber%.] %title%
- This approach can be used with complex queries (like combinatorics: "Select a track matching any 2 genres and 3 styles from current track" ) or graph linking ("Select styles considered to be similar to Blues rock"). See Playlist Tools on my sig.
- A third tag could theoretically be used to store additional sub-styles, or characteristics: cultural grouping, etc. I simply add that to genre and have set Playlist Tools script to make good use of those.
- You loose auto-completion. But there are other plugins and tools to work around that. You got full native query compatibility though.
- I prefer to create more complex genre/style structures and links via SMP scripts, since that reflects better real music instead of nesting (more appropiate to "find" things). For ex I integrated something like that (https://musicmap.info/) via scripts:  https://regorxxx.github.io/Music-Graph/Draw%20Graph.html
- In case you have to change something on your structure or tagging, you don't have to rewrite the entire tag logic on your files.... since the logic is on the scripts. For ex. adding All music genre and styles support is just a matter of creating a file with replacements.
https://github.com/regorxxx/Search-by-Distance-SMP/blob/main/helpers/music_graph_descriptors_xxx_allmusic.js

Re: How can I create a genre hierarchy?

Reply #13
Can I please get a more simplified explanation on how to prepare my tracks for this kind of hierarchy system?
As much as I like foobar for many things, playlist management and genre hierarchy browser aren't the ones, or rather, why I added a second media player side by side with foobar.
i.e. choose the best tool for what you want to do - and Musicbee does offer a GenreHierarchy browser, and a user is maintaining RateYourMusic genre lists, as well as discogs & musicbrainz I believe:
https://getmusicbee.com/forum/index.php?topic=35266.0
and you can nest as deep as you want to, all derived from just teh genre field... only caveat is that a child can only have 1 parent (i.e. let's say 'Ambient Rock' can't sit under Ambient and Rock at the same time... but you need to pick one in your main hierarchy formatting file... ). Also worth noting, parents' accumulate their childrens' content too...

Just my 2 cents; running another player might not be suitable, but thought I'd mention it since it's 'just' there...
c.

Re: How can I create a genre hierarchy?

Reply #14
Can I please get a more simplified explanation on how to prepare my tracks for this kind of hierarchy system?
As much as I like foobar for many things, playlist management and genre hierarchy browser aren't the ones, or rather, why I added a second media player side by side with foobar.
i.e. choose the best tool for what you want to do - and Musicbee does offer a GenreHierarchy browser, and a user is maintaining RateYourMusic genre lists, as well as discogs & musicbrainz I believe:
https://getmusicbee.com/forum/index.php?topic=35266.0
and you can nest as deep as you want to, all derived from just teh genre field... only caveat is that a child can only have 1 parent (i.e. let's say 'Ambient Rock' can't sit under Ambient and Rock at the same time... but you need to pick one in your main hierarchy formatting file... ). Also worth noting, parents' accumulate their childrens' content too...

Just my 2 cents; running another player might not be suitable, but thought I'd mention it since it's 'just' there...
c.
Playlist management is pretty solved with my SMP script though. Check my sig.

Genre hierarchy... I agree. BUT musicbee (really impressive software btw) has that because someone cared to do something with it, nothing stop us to create a GenreHierarchy browser with SMP. In fact it would be more or less trivial, using just 2 tags (genre/style) and creating the list with a json preset file for ex. It could also be used for quick tagging.

The "problem" is sticking to an standard. For ex. musicBrainz is pretty limited and AllMusic has tons of genres which make no sense.

I could work on it at some point, but right now I have more interest on what to do with those genres and how they are related (Playlist Tools) and playlist management. The TF approach is good enough for me right now.

Re: How can I create a genre hierarchy?

Reply #15
Playlist management is pretty solved with my SMP script though. Check my sig.
Lovely that that exists now! <3
I switched to MB in ~2015, for Playlist management (and its' itunes .xml export for traktor/serato/rekordbox consumption of the resulting xml) as these have been a painpoint for me in foobar for a while, and am not programmer enough to tackle them in Foobar meself.
Props to you for adding this!
As for the MB hierarchy browser - I also use this for a multitude - i.e. each (switchable) hierarchy file can derive from whichever tag field; means I can switch between the genres I maintain (primarily, my own definition, and discogs secondarily through foobars discogs component) as well as different instrument taxonomy definitions (populated by an 'instrument' field I maintain where needed/wanted ;)

c.

Re: How can I create a genre hierarchy?

Reply #16
First off, this is using a CUI component (library tree) so you need to be using a CUI (colums ui) config. You'd also need to familiarize yourself with using masstagger. There is a learning curve.

It's kinda useless to start explaining if you're not even using CUI. My post is to merely show you the idea and principles for you to work on.

Hello, I'm now gradually starting to learn mass tagger. But I wanted to ask you one thing just to be sure:

In Default UI I used Spider Monkey Panel to add the advanced Library Tree plugin, and it's really helpful, as far as I have tested it has all the features that the Columns UI version has. Do I really need to switch to Columns UI to start implementing your genre tagging techniques? Maybe I'm overlooking something here, I'd really appreciate your help.

Thanks

Re: How can I create a genre hierarchy?

Reply #17
I don't use the SPM version of Library Tree so I can't say for sure If it will also work on that version but I don't see a particular reason on why it wouldn't work.