{"id":561,"date":"2024-03-14T17:32:27","date_gmt":"2024-03-14T17:32:27","guid":{"rendered":"https:\/\/jazzgraphs.com\/wp2\/?p=561"},"modified":"2024-03-14T17:32:29","modified_gmt":"2024-03-14T17:32:29","slug":"musical-genres-via-musicbrainz-data","status":"publish","type":"post","link":"https:\/\/jazzgraphs.com\/wp2\/2024\/03\/14\/musical-genres-via-musicbrainz-data\/","title":{"rendered":"Musical Genres via MusicBrainz Data"},"content":{"rendered":"\n<p>Once again I have pulled the core MusicBrainz tables into my local version of PostgreSQL, where I can start exploring all sorts of musical data &#8211; recordings, releases, places, artists, and much, much more. The database is large, totaling nearly 17 gigabytes of data across 171 tables, so there is no shortage of potential topics to explore.<\/p>\n\n\n\n<p>One of the areas that intrigues me the most is an exploration of musical genres, created in MusicBrainz for contributors to categorize recordings. While the genres don&#8217;t currently tie in to individual recordings or releases in the database, I hope to use them with my own collection of music to create some potentially interesting visualizations. For now, let&#8217;s undertake an exploration of the raw data on genres, using the DBeaver database tool.<\/p>\n\n\n\n<p>Our first table is simply named <strong>genre<\/strong>; let&#8217;s look at a screenshot of some of the data:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"866\" src=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1024x866.png\" alt=\"\" class=\"wp-image-564\" srcset=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1024x866.png 1024w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-300x254.png 300w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-768x649.png 768w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1536x1299.png 1536w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2048x1731.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Data from the MusicBrainz genre table<\/figcaption><\/figure>\n\n\n\n<p>Each genre has a unique id and gid value linked to a distinct genre name such as <em>acid house<\/em>, <em>arena rock<\/em>, or <em>bebop<\/em>. As you can tell, we&#8217;re going to a very specific level here, not simple classifications like pop, rock, or jazz. This should make it quite interesting (but not so easy!) when I start tagging my own music collection.<\/p>\n\n\n\n<p>A second table is named <strong>genre_alias<\/strong>; here we find some examples where distinct names are rolled up to a single genre id to join to the genre table we just saw. For instance, have a look at some of the entries below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"249\" src=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1-1024x249.png\" alt=\"\" class=\"wp-image-566\" srcset=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1-1024x249.png 1024w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1-300x73.png 300w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1-768x187.png 768w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1-1536x373.png 1536w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-1.png 1966w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Data from the MusicBrainz genre_alias table<\/figcaption><\/figure>\n\n\n\n<p>We see multiple rows pointing to a single genre id (the <em>genre<\/em> column), largely based on alternative spellings or differing punctuation. The last three rows display one such case &#8211; <em>alternative rap<\/em>, <em>alternative hip-hop<\/em>, and <em>alternative hiphop<\/em> all have a genre value of 10; in the genre table this classifies all three as <em>alternative hip hop<\/em>. In other words, these entries are three possible variations on the original <em>alternative hip hop<\/em> genre; they all represent the same musical genre. In a sense, this is some data cleansing that I won&#8217;t need to perform.<\/p>\n\n\n\n<p>A third table is named <strong>l_genre_genre<\/strong>; it ties together sub-genres with a higher level &#8216;umbrella&#8217; genre. Using the alternative hip hop example from above, let&#8217;s dive into this table, where we can see the 10 value in the <em>entity1 <\/em>field:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"308\" src=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2-1024x308.png\" alt=\"\" class=\"wp-image-569\" srcset=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2-1024x308.png 1024w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2-300x90.png 300w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2-768x231.png 768w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-2.png 1438w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Alternative hip hop id in the entity1 column<\/figcaption><\/figure>\n\n\n\n<p>Note the 199 value in the <em>entity0<\/em> column; if we refer back to the genre table, here&#8217;s what we see:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"231\" src=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4-1024x231.png\" alt=\"\" class=\"wp-image-571\" srcset=\"https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4-1024x231.png 1024w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4-300x68.png 300w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4-768x173.png 768w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4-1536x346.png 1536w, https:\/\/jazzgraphs.com\/wp2\/wp-content\/uploads\/2024\/03\/image-4.png 1743w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Top level hip hop id in the genre table<\/figcaption><\/figure>\n\n\n\n<p>The 199 id value corresponds to <em>hip hop<\/em>, which contains the <em>alternative hip hop<\/em> genre, as well as any other sub-genres related to hip hop. So <em>entity0 <\/em>represents the higher level grouping, with <em>entity1<\/em> representing the next level down (a sub-genre). In terms of classifying music, we can now use two levels, which may prove useful when it comes to building visualizations.<\/p>\n\n\n\n<p>Is there anything we can visualize at this early stage? How about a very simple sunburst chart? These will become far more interesting when I can tag my own collection with genre info, but for now, here&#8217;s a conceptual look using Flourish. You can use the filter or click on a genre to focus the display.<\/p>\n\n\n\n<div class=\"flourish-embed flourish-hierarchy\" data-src=\"visualisation\/17159091\"><script src=\"https:\/\/public.flourish.studio\/resources\/embed.js\"><\/script><\/div>\n\n\n\n<p>I hope you can see the potential here; ultimately each genre and sub-genre will be sized based on the number of albums (vinyl &amp; CD) in a collection. This will provide a quick visual indication for where someone&#8217;s musical preferences lie. There may even be the possibility to take it down to the single recording level, but we&#8217;ll have to test that idea.<\/p>\n\n\n\n<p>That&#8217;s it for now; looking forward to doing some more fun stuff with the MusicBrainz data. Thanks for reading!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Once again I have pulled the core MusicBrainz tables into my local version of PostgreSQL, where I can start exploring all sorts of musical data &#8211; recordings, releases, places, artists, and much, much more. The database is large, totaling nearly 17 gigabytes of data across 171 tables, so there is no shortage of potential topics [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[32,25,41,26,27],"class_list":["post-561","post","type-post","status-publish","format-standard","hentry","category-music","tag-dbeaver","tag-flourish","tag-musical-genres","tag-musicbrainz","tag-sunburst-chart"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/posts\/561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/comments?post=561"}],"version-history":[{"count":9,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":575,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/posts\/561\/revisions\/575"}],"wp:attachment":[{"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/media?parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/categories?post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jazzgraphs.com\/wp2\/wp-json\/wp\/v2\/tags?post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}