{"id":1472,"date":"2020-12-22T14:12:28","date_gmt":"2020-12-22T21:12:28","guid":{"rendered":"http:\/\/www.timsummers.org\/?p=1472"},"modified":"2020-12-30T02:19:37","modified_gmt":"2020-12-30T09:19:37","slug":"midi-harmony","status":"publish","type":"post","link":"http:\/\/www.timsummers.org\/?p=1472","title":{"rendered":"midi => harmony"},"content":{"rendered":"\n<p><em>harmonypartition<\/em> works simply and cleanly with MIDI files.<\/p>\n\n\n\n<p>Using the <a href=\"http:\/\/web.mit.edu\/music21\/\"><em>music2<\/em>1<\/a> package, <em>harmonypartition<\/em> is able to analyze a MIDI file in exactly the same way it analyzes an audio file.<\/p>\n\n\n\n<p>Results from MIDI are cleaner than those from audio \u2013 though not necessarily <em>better<\/em>, since resonance and continuity play such a key role in analysis, performance, and understanding. But MIDI is an important and stable reference in music notation, and provides invaluable information on many levels.<\/p>\n\n\n\n<h2>analysing a MIDI file<\/h2>\n\n\n\n<p>Below is an analysis of the same progression as on the previous pages: vi-ii-V-I in C Major, from a MIDI file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bin_a, kpdve_a = pt_analyzeMIDI.analyze_notation_file(\"vi_ii_V_I.mid\", beats_per_slice=2)<\/code><\/pre>\n\n\n\n<p>This analysis (like all analyses in <em>harmonypartition<\/em> yields two crucial pieces of information. The first is a binary &#8216;punch card&#8217; of pitches. The second is an analysis of probable function. These can be seen below. First, in binary (with analysis given below):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"201\" src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-1024x201.png\" alt=\"\" class=\"wp-image-1523\" srcset=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-1024x201.png 1024w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-300x59.png 300w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-768x151.png 768w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-1536x301.png 1536w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin-1200x235.png 1200w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_bin.png 1972w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Second, coded by proximity and most probable (or, more to the point, laziest possible) harmonic function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"100\" src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-1024x100.png\" alt=\"\" class=\"wp-image-1524\" srcset=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-1024x100.png 1024w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-300x29.png 300w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-768x75.png 768w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-1536x150.png 1536w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI-1200x118.png 1200w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/6251_MIDI.png 1756w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption><em>harmonypartition<\/em> analysis, with  chords (large blocks) in C Major (bottom stripe)<\/figcaption><\/figure>\n\n\n\n<p>This analysis is very close to what derives from the Fourier analysis of a live performance of the same music, here played on a lightly out-of-tune piano:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"184\" src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-1024x184.png\" alt=\"\" class=\"wp-image-1484\" srcset=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-1024x184.png 1024w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-300x54.png 300w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-768x138.png 768w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-1536x276.png 1536w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live-1200x216.png 1200w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live.png 1756w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-audio\"><audio controls src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/C_6251_live.mp3\"><\/audio><figcaption>vi-ii-V-I live on funky piano<\/figcaption><\/figure>\n\n\n\n<h2>further examples: MAESTRO dataset<\/h2>\n\n\n\n<p>Then, to take a leap away from the vi-ii-V-I, here is a somewhat more sophisticated examples: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach), from the <a href=\"https:\/\/magenta.tensorflow.org\/datasets\/maestro\">MAESTRO<\/a> dataset. First an analysis of the audio recording:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"184\" src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-1024x184.png\" alt=\"\" class=\"wp-image-1530\" srcset=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-1024x184.png 1024w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-300x54.png 300w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-768x138.png 768w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-1536x276.png 1536w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav-1200x216.png 1200w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_wav.png 1756w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>Audio\/Harmony analysis: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach) &#8212; using <em>librosa<\/em> stft<\/figcaption><\/figure>\n\n\n\n<p>And here an analysis of the MIDI version of the same performance:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" width=\"1024\" height=\"100\" src=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-1024x100.png\" alt=\"\" class=\"wp-image-1531\" srcset=\"http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-1024x100.png 1024w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-300x29.png 300w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-768x75.png 768w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-1536x150.png 1536w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid-1200x118.png 1200w, http:\/\/www.timsummers.org\/wp-content\/uploads\/2020\/12\/bach_WTC_am_mid.png 1756w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><figcaption>MIDI\/Harmony analysis: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach) &#8212; using <em>music21<\/em> for chord extraction.<\/figcaption><\/figure>\n\n\n\n<p>These analyses could use some smoothing and statistical comparison, but all in all, it&#8217;s not bad for pure binary logic \u2013 which seems like a good, rooted place to have a meeting point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>harmonypartition works simply and cleanly with MIDI files. Using the music21 package, harmonypartition is able to analyze a MIDI file in exactly the same way it analyzes an audio file. Results from MIDI are cleaner than those from audio \u2013 though not necessarily better, since resonance and continuity play such a key role in analysis, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[60],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/posts\/1472"}],"collection":[{"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1472"}],"version-history":[{"count":13,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/posts\/1472\/revisions"}],"predecessor-version":[{"id":1621,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=\/wp\/v2\/posts\/1472\/revisions\/1621"}],"wp:attachment":[{"href":"http:\/\/www.timsummers.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1472"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.timsummers.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}