<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Music on stdin</title><link>https://stdin.org/tags/music/</link><description>Recent content in Music on stdin</description><generator>Hugo -- 0.161.1</generator><language>en</language><copyright>Isaac Kunen</copyright><lastBuildDate>Sun, 21 Jan 2018 00:00:00 +0000</lastBuildDate><atom:link href="https://stdin.org/tags/music/index.xml" rel="self" type="application/rss+xml"/><item><title>A Dozen Notes, Give or Take</title><link>https://stdin.org/a-dozen-notes-give-or-take/</link><pubDate>Sun, 21 Jan 2018 00:00:00 +0000</pubDate><author>Isaac</author><guid>https://stdin.org/a-dozen-notes-give-or-take/</guid><description>&amp;lt;no value&amp;gt;</description><content type="text/html" mode="escaped"><![CDATA[<h2 id="introduction">Introduction<a href="#introduction" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>Western classical music typically uses twelve distinct notes: C, C#, D, D#, E, F, F#, G, G#, A, A#, B. After this, you hit an octave and repeat.</p>
<p>It always bugged me: why twelve?</p>
<p>Here I try to provide <em>an</em> answer with a few rules and a few graphs. This is a little hand wavy, I&rsquo;m sure that it&rsquo;s not original, and I know someone who knows more could make this more convincing and more rigorous.</p>
<p>But this is the internet. Who cares?</p>
<h2 id="exposition">Exposition<a href="#exposition" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>We&rsquo;re going to examine systems with various numbers of notes, but first we&rsquo;re going to set a few ground rules for our exploration:</p>
<ol>
<li>We want our notes to form an even progression. To be precise, we want the ratio between two consecutive notes to be constant. This is called an  _<a href="https://en.wikipedia.org/wiki/Equal_temperament">equal temperament</a>, _and will mean that our set of notes won&rsquo;t favor any particular key.</li>
<li>With our set of notes, we want to be able to represent the <a href="https://en.wikipedia.org/wiki/Harmonic">harmonics</a> of any given fundamental tone <em>as closely as possible</em>. When a tone is played on an instrument, the harmonics of that tone are usually present in some mixture—the exact mixture has a lot to do with the instrument&rsquo;s <a href="https://en.wikipedia.org/wiki/Timbre">timbre</a>. It turns out that rule (1) makes it impossible to be perfect, but since harmonics show up naturally, we want to be close.</li>
<li>We&rsquo;ll treat one class of harmonics with extra care: octaves. We&rsquo;ll insist that that we evenly divide the octave. Together with (1), this means that every time we reach an octave our notes will repeat with double the frequency.</li>
</ol>
<p>None of these ground rules mandate 12 notes; we want that to emerge.</p>
<p>To drive this, I wrote a <a href="https://stdinorg.files.wordpress.com/2018/01/generatescales.zip" title="generateScales">simple python script</a> that produces some working data for middle C (261.626 Hz). Basically, this pre-computes the best-fit notes for each harmonic of middle C given different numbers of notes in the scale. The choice of C is arbitrary: picking a different fundamental would leave all of the relations intact, and would just shift the frequencies up or down a bit.</p>
<p>To get our feet wet with the data, let&rsquo;s look at the 12-tone scale we&rsquo;re used to, and see how its best-fit notes line up against the harmonic progression starting with middle C:</p>
<p><img src="scales13.png" alt="scales1"></p>
<p>Ideally, these points would all lie on a line, since the best-fit note would exactly match its corresponding harmonic. It should be pretty clear from the plot that these  <em>don&rsquo;t</em> quite lie on a line, although the lowest notes look pretty close. We can better see what&rsquo;s going on if we simply subtract each harmonic out from the best-fit note:</p>
<p><img src="scales2.png" alt="scales2"></p>
<p>The first thing you&rsquo;ll notice from this plot is that the octaves (all those Cs) have no error; this is simply by design. You can also see that the third tone (G, which corresponds to a perfect fifth) is slightly flat, whereas the fifth tone (E, which corresponds to a major third) is a bit sharp. Both of these are well-known byproducts of an equal-tempered twelve-tone scale.</p>
<p>Beyond these notes, things seem to get pretty bad. But we&rsquo;re looking at the raw deviation. Instead, we&rsquo;re going to weight the errors, decaying them exponentially as the harmonics increase. It&rsquo;s a little hand wavy, but we&rsquo;ll defend this on the simple grounds that we expect the lower harmonics to be more important.</p>
<p><img src="scales3.png" alt="scales3"></p>
<p>If we look at this weighted error, things look rather worse for our low-numbered harmonics, but this is just emphasizing what we think is important.</p>
<h2 id="development">Development<a href="#development" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>Now that we&rsquo;ve seen how well (or poorly) twelve notes perform, we can ask how well other divisions would work. For starters, let&rsquo;s take a look at twelve&rsquo;s neighbors: eleven and thirteen:</p>
<p><img src="scales41.png" alt="scales4"></p>
<p>Compared to its neighbors, twelve divisions is starting to look pretty good.</p>
<p>To get the full picture, we&rsquo;ll sum the absolute value of all of the errors for each note. By plotting this total weighted error against the number of notes, we can see the overall pattern:</p>
<p><img src="scales5.png" alt="scales5"></p>
<p>Here I&rsquo;ve highlighted twelve just so we can see it. Two things seem immediately evident from this plot:</p>
<ol>
<li>Although the error jumps around a bit, there is a clear downward trend. This shouldn&rsquo;t be surprising: as we add more notes, we&rsquo;re more likely to get one close to any given harmonic. In particular, <em>doubling</em> the number of notes  <em>must</em> make things better, since the new collection is a superset of the old.</li>
<li>Twelve really does have a low error. In fact, with our error measure, you don&rsquo;t do better until you get to 22—and that&rsquo;s a lot of notes.</li>
</ol>
<p>We can emphasize just how well twelve does by multiplying the number of notes by the error. We&rsquo;ll call this the efficiency of the set; roughly speaking, a set of notes is more efficient if it achieves less error with fewer notes.</p>
<p><img src="scales6.png" alt="scales6"></p>
<p>I hope it&rsquo;s not just for show, but twelve really does look good now.</p>
<h2 id="recapitulation">Recapitulation<a href="#recapitulation" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>What have we learned?</p>
<p>It&rsquo;s certainly not definitive, but if harmonics of notes sound good, and we&rsquo;re looking for a simple set of evenly-spaced notes that approximates them well, it&rsquo;s hard to pick a better number of divisions than 12.</p>
<p>I don&rsquo;t know when exactly the twelve-tone scale was developed, but whoever developed it certainly didn&rsquo;t do this kind of analysis. We can, however, assume is that its evolution was guided by what sounded right, and I think this analysis helps shine some light on why this arrangement might be the product of that evolution.</p>
<h2 id="coda">Coda<a href="#coda" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
      stroke-linecap="round" stroke-linejoin="round" class="feather">
      <path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path>
      <line x1="8" y1="12" x2="16" y2="12"></line>
   </svg></a></h2>
<p>But that&rsquo;s not all!</p>
<p>If you want to go down the rabbit hole, here are two bunnies to follow:</p>
<ul>
<li>You can relax our ground rule number 1: that notes need to follow an even progression. Equal temperament is actually relatively modern, and there are a slew of systems that don&rsquo;t satisfy this rule: <a href="https://en.wikipedia.org/wiki/Just_intonation">just intonation</a>, <a href="https://en.wikipedia.org/wiki/Meantone_temperament">meantone temperament</a>, <a href="https://en.wikipedia.org/wiki/Pythagorean_tuning">Pythagorean tuning</a>, etc. Bach&rsquo;s  _<a href="https://www.youtube.com/watch?v=RNCuPAgG9eo">Well-Tempered Clavier</a> _was meant to be played with a <a href="https://en.wikipedia.org/wiki/Well_temperament">well temperament</a>, and string players will often deviate from equal temperament to better hit the overtones discussed here.</li>
<li>And while twelve works out pretty well, <a href="https://en.wikipedia.org/wiki/Microtonal_music">microtonal music</a>—dividing the octave more finely than twelve—has a history, even within the western classical domain. I haven&rsquo;t heard too many recordings of classical microtonal music, but I did find <a href="https://www.youtube.com/watch?v=izFgt2tZ0Oc">this recording</a> of some of Ives&rsquo; pieces for quarter-tone (24-tone) piano.</li>
</ul>
<p>If you have a favorite recording that bends these rules, please share! And if you&rsquo;re interested, all the vizzes I used here are available on <a href="https://public.tableau.com/profile/isaac3034#!/vizhome/Scales_0/ADozenNotesGiveorTake">Tableau Public</a>.</p>
]]></content></item></channel></rss>