{"id":483,"date":"2018-09-22T13:38:05","date_gmt":"2018-09-22T13:38:05","guid":{"rendered":"http:\/\/andrew-may.com\/blog\/?p=483"},"modified":"2018-09-22T13:38:05","modified_gmt":"2018-09-22T13:38:05","slug":"algorithmic-beatles","status":"publish","type":"post","link":"https:\/\/andrew-may.com\/blog\/2018\/09\/algorithmic-beatles\/","title":{"rendered":"Algorithmic Beatles"},"content":{"rendered":"<p><a href=\"http:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-485 size-large\" src=\"http:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix-1024x468.png\" alt=\"Markov music matrix\" width=\"525\" height=\"240\" srcset=\"https:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix-1024x468.png 1024w, https:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix-300x137.png 300w, https:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix-768x351.png 768w, https:\/\/andrew-may.com\/blog\/wp-content\/uploads\/2018\/09\/markov-music-matrix.png 1441w\" sizes=\"auto, (max-width: 525px) 100vw, 525px\" \/><\/a><\/p>\n<p>When Eric Morecambe mangled Grieg\u2019s Piano Concerto on a TV special in 1971, he insisted he was \u201cplaying all the right notes, but not necessarily in the right order\u201d. That\u2019s a valid point, because there aren\u2019t that many different notes on a piano and the only thing that distinguishes one tune from another is the order in which you play them.<\/p>\n<p>To a mathematician or computer programmer the situation is crying out for quantitative analysis. The diagram above shows the \u201ctransition matrix\u201d for one specific Beatles tune (using the MIDI standard where middle C is C5). It\u2019s clear there\u2019s a lot of order here. One thing that jumps out is that there\u2019s only one \u201cblack\u201d note, G#5, and it\u2019s always followed by A5. In fact A5 is a very popular note, cropping up after no fewer than 8 different pitches. On the other hand, G#5 itself is very rare, only ever coming after D6, and then only 6% of the time.<\/p>\n<p>As well as analysing the original tune, this allows us to write a new tune of our own using the same transition matrix. The result (as the aforementioned mathematicians and computer programmers will recognize) is a first-order Markov chain. Producing an algorithm of this type from scratch would be rather tedious (as indeed the initial analysis would be), but fortunately there\u2019s some free software called <a href=\"https:\/\/en.wikipedia.org\/wiki\/OpenMusic\" target=\"_blank\" rel=\"noopener\">OpenMusic<\/a> which includes built-in Markov functions that make the process much simpler.<\/p>\n<p>Of course, there\u2019s more to a tune than the pitch of the notes \u2013 there\u2019s the duration of a note too. But that can be analysed and reproduced by exactly the same method. I experimented with an algorithmic composition of my own, based on the Beatles song analysed above. As a first step, I used the OpenMusic Markov functions to generate a series of tune-fragments for both the \u201cright hand\u201d and \u201cleft hand\u201d of the piano. Then, to give the composition some structure, I arranged the fragments in a rough approximation to classical sonata form.<\/p>\n<p>I won\u2019t say what the original song was, because I want to see if anyone can guess it. As a hint, I\u2019ve inserted a brief quotation from the original at the mid-point of the piece. Here it is on YouTube:<\/p>\n<p><iframe loading=\"lazy\" title=\"First-order Markov Beatles Sonata\" width=\"525\" height=\"295\" src=\"https:\/\/www.youtube.com\/embed\/VfHZpU1Ktpk?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>When Eric Morecambe mangled Grieg\u2019s Piano Concerto on a TV special in 1971, he insisted he was \u201cplaying all the right notes, but not necessarily in the right order\u201d. That\u2019s a valid point, because there aren\u2019t that many different notes on a piano and the only thing that distinguishes one tune from another is the &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/andrew-may.com\/blog\/2018\/09\/algorithmic-beatles\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Algorithmic Beatles&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[61,60,56,54],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-algorithmic-composition","tag-mathematics","tag-music-theory","tag-youtube"],"_links":{"self":[{"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/comments?post=483"}],"version-history":[{"count":4,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":493,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/posts\/483\/revisions\/493"}],"wp:attachment":[{"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/media?parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/categories?post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/andrew-may.com\/blog\/wp-json\/wp\/v2\/tags?post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}