gdritter repos when-computer / d674c01
Added explicit time, to avoid using file mtime Getty Ritter 7 years ago
12 changed file(s) with 317 addition(s) and 202 deletion(s). Collapse all Expand all
1 \meta{( "early-algebraic-data-types" "early algebraic data types" ("programming"))}
1 \meta{( "early-algebraic-data-types" "early algebraic data types" ("programming") 1451674812)}
22 Algebraic data types are a very convenient and expressive way
33 of modeling data. You're familiar with them if you've ever
44 used any ML-like language: you have \em{products},
178178 DEC-10 ML versions. Later versions did end up drawing on Cardelli's
179179 named products to create records, with a change in notation
180180 from \tt{(\| ... \|)} to \tt{ \{ ... \} }, and thus we get the
181 algebraic data types we all know and love.
181 algebraic data types we all know and love.
1 \meta{("dijkstra-comprehensions" "dijkstra and set comprehensions" ("notation"))}
1 \meta{("dijkstra-comprehensions" "dijkstra and set comprehensions" ("notation") 1455720663)}
22
33 Edsger Dijkstra had notably strong opinions about a lot of things, so it
44 shouldn't be surprising that he had strong opinions about his mathematical
11 \meta{("some-hypertext-features"
22 "beyond wikis: hypertext stuff"
3 ("hypertext"))}
3 ("hypertext"))}
44
5 For many people, the word 'hypertext' brings to mind HTML and
6 wikis. Hypertext encompasses a wide range of systems, artifacts,
7 and approaches, from choose-your-own-adventure books to experimental
8 literature, from Twine games to HyperCard, and so forth. But—for
9 very good reason—HTML has become ubiquitous, and with it, its
10 approach to hypertext.
5 For many people, the word 'hypertext' brings to mind HTML and wikis. Hypertext encompasses a wide range of systems, artifacts, and approaches, from choose-your-own-adventure books to experimental literature, from Twine games to HyperCard, and so forth. But—for good reason!—HTML has become ubiquitous, and with it, its approach to hypertext.
116
12 On the other hand: previous decades included a lot of experimental
13 hypertext systems which pushed out into interesting different
14 directions that aren't as common in modern hypertext systems.
7 On the other hand: previous decades included a lot of experimental hypertext systems which pushed out into interesting different directions that aren't as common in modern hypertext systems.
158
16 Here are just a handful of features of older hypertext systems:
9 What follows are just a handful of interesting features of older hypertext systems that are mostly or completely lacking in modern HTML.
1710
1811 \h2{Typed Nodes}
1912
20 In HTML, every page is a soup of information. Pages are structured
21 from the point of view of the \em{markup}, but not really from
22 the hypertext-level view of the page: an HTML page can be edited
23 to include more information or less information, and there isn't
24 really a way of distinguishing them.
13 In raw HTML, pages are, for the most part, amorphous, unstructured information soup. Pages are structured in the sense of having \em{markup}, but that markup is for people. Web designers often try to structure HTML in a way that's more meaningful to a computer—for example, with structure-indicating tags like \tt{<header>}, or with efforts like the \link{https://www.w3.org/standards/semanticweb/|Semantic Web} or \link{http://microformats.org/wiki/Main_Page|Microformats}—but that's not obligatory, and a given page in an HTML system could have a structure understood by machines, or it could be nothing but markup and links.
2514
26 Some other systems distinguish nodes based on what "type" of node
27 they are, which often gives them more structure: for example,
28 we could build up a hypertext system for describing places
29 in which there is a specific sort of node that describes a "city".
30 Instead of \em{just} being a mass of formatted text and links, it
31 would have a set of specific fields: the name of the city,
32 the population, its area, its location, and so forth.
15 In contrast, some other hypertext systems distinguish nodes based on what "type" of node they are, which can have ramifications for the structure of the node: for example, we could build up a hypertext system for describing places in which there is a specific "type" of node for describing city. Instead of \em{just} being a mass of formatted text and links, like an HTML page, it would have a set of specific fields: the name of the city, the population, its area, its location, and so forth.
3316
34 Some values of these fields could be links, but those links
35 could also stipulate the sort of thing they link to: a city
36 might have a field telling us what country it is in, and our
37 system could prevent us from accidentally filling in that field
38 with anything other than a country.
17 Some values of these fields could be links, but those links could also stipulate the sort of thing they link to: a city might have a field telling us what country it is in, and our system could prevent us from accidentally filling in that field with anything other than a country.
3918
40 Certain historical hypertext systems used nodes of this type:
41 for example,
42 \link{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.438.8515&rep=rep1&type=pdf|Aquanet}
43 took its node descriptions directly from Common Lisp descriptions
44 of objects, so that each field corresponded to an instance
45 variable (or \em{slot}, in Common Lisp parlance) of an object.
19 Certain historical hypertext systems used nodes of this type: for example, \link{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.438.8515&rep=rep1&type=pdf|Aquanet} took its node "types" directly from Common Lisp class definitions, so that each field of a page corresponded to an instance variable (or \em{slot}, in Common Lisp parlance) of an object.
4620
4721 \h2{Typed Links}
4822
49 In HTML, a hyperlink usually doesn't mean anything in particular
50 to a computer. It usually means something to a \em{reader}, but
51 the semantics aren't necessarily conveyed in a machine-readable
52 way.
23 In HTML, a hyperlink usually doesn't \em{mean} something to a computer beyond providing an affordance to . It usually means something to a \em{reader}, but the semantics aren't necessarily conveyed in a machine-readable way.
5324
54 This isn't always true: for example, some hyperlinks are annotated
55 to let the computer know that \em{this} link is to the next page
56 in a sequence, while \em{this} link is to the previous, or other
57 roles. But some other hypertext systems took that notion even
58 further, allowing for documents that conveyed more
59 precise information about their hypertext structure.
25 This isn't always true: for example, some HTML hyperlinks are annotated to let the computer know that \em{this} link is to the next page in a sequence, while \em{this} link is to the previous, or other roles. But some other hypertext systems took that notion even further, allowing for documents that conveyed more precise information about their hypertext structure.
6026
61 For example, you can imagine a hypertext system which describes
62 places, and has links with specific geographical and spatial
63 connotations: a link could specify in a machine-readable way
64 that a given place \em{contains} another place, and use
65 this link to link the \em{Italy} node to the \em{Rome} node,
66 and in turn the \em{Rome} node to the \em{Coliseum} node.
27 For example, you can imagine a hypertext system which describes places, and has links with specific geographical and spatial connotations: a link could specify in a machine-readable way that a given place \em{contains} another place, and use this link to link the \em{Italy} node to the \em{Rome} node, and in turn the \em{Rome} node to the \em{Coliseum} node.
6728
68 In doing so, you not only build up a hypertext structure with
69 richer affordances for navigation, but also with richer affordances
70 for \em{automated reasoning}. I could, for example, query my
71 hypertext system by asking, "What are other places that are
72 contained within the same place that contains the Coliseum?"
29 In doing so, you not only build up a hypertext structure with richer affordances for navigation, but also with richer affordances for \em{automated reasoning}. I could, for example, query my hypertext system by asking, "What are other places that are contained within the same place that contains the Coliseum?"
7330
74 Numerous old papers on hypertext systems consider the problem of
75 attempting to build and reason about arguments, and usually
76 start from the
77 \link{https://en.wikipedia.org/wiki/Toulmin_method|Toulmin model of reasoning}.
78 Systems that include typed links could represent relationships
79 like \em{is-a-fact-that-supports} directly as links, so a user
80 could query the system by asking, "What are all the nodes that
81 are supporting facts for this thesis?"
31 Numerous old papers on hypertext systems consider the problem of attempting to build and reason about arguments, and usually start from the \link{https://en.wikipedia.org/wiki/Toulmin_method|Toulmin model of reasoning}. Systems that include typed links could represent relationships like \em{is-a-fact-that-supports} directly as links, so a user could query the system by asking, "What are all the nodes that are supporting facts for this thesis?"
8232
8333 \h2{Link Arity And Direction}
8434
85 In HTML, a link is one-way: if I include a link in document A which
86 leads to document B, I won't necessarily have a link back. There
87 are various ways of synthesizing backward edges: by including
88 smarts in the browser (e.g. the 'back' button) or in particular
89 applications (e.g. a wiki's 'what links here' feature) or by
90 cross-application mechanisms (e.g. 'pingbacks' in WordPress or
91 other CMS systems), but none of these are inherent in the HTML
35 In HTML, a link is one-way: if I include a link in document A which leads to document B, I won't necessarily have a link back. There are various ways of synthesizing backward edges: by including smarts in the browser (e.g. the 'back' button) or in particular applications (e.g. a wiki's 'what links here' feature) or by cross-application mechanisms (e.g. 'pingbacks' in WordPress or other CMS systems), but none of these are inherent in the HTML
9236 mode.
9337
94 Some other hypertext systems include links that are \em{inherently}
95 two-directional. These systems build up stronger interconnectedness
96 between nodes, because there are no "dead-end" paths: you can always
97 at least move back the way you came, and creating a new node
98 also creates a backwards path. In a system with typed links, this
99 also means you can have links with swapped semantics: creating
100 a \em{contains} link from \em{Italy} to \em{Rome} is the same
101 operation as creating a \em{is-contained-in} link from \em{Rome} to
102 \em{Italy}.
38 Some other hypertext systems include links that are \em{inherently} two-directional. These systems build up stronger interconnectedness between nodes, because there are no "dead-end" paths: you can always at least move back the way you came, and creating a new node also creates a backwards path. In a system with typed links, this also means you can have links with swapped semantics: creating a \em{contains} link from \em{Italy} to \em{Rome} is the same operation as creating a \em{is-contained-in} link from \em{Rome} to \em{Italy}.
10339
104 Even more extreme, some hypertext systems include links that
105 join together more than two nodes. This doesn't make a whole lot
106 of sense in something like HTML, where a link doesn't necessarily
107 connote any particular "meaning", but in a system with typed
108 links, we can imagine a link that brings together multiple nodes
109 with a different denotation for each: in our hypothetical
110 geographic system, we could have a ternary link that represents
111 \em{is directly between x and y}.
40 Even more extreme, some hypertext systems include links that join together more than two nodes. This doesn't make a whole lot of sense in something like HTML, where a link doesn't necessarily connote any particular "meaning", but in a system with typed links, we can imagine a link that brings together multiple nodes with a different denotation for each: in our hypothetical geographic system, we could have a ternary link that represents \em{is directly between x and y}.
11241
113 In the most extreme, you could imagine a system that treats
114 n-ary links as n-ary predicates.
42 In the most extreme, you could imagine a system that treats n-ary links as n-ary predicates.
11543
116 The aforementioned Aquanet system contained not just typed nodes but
117 also typed n-ary links, which were there called \em{relations}.
44 The aforementioned Aquanet system contained not just typed nodes but also typed n-ary links, which were there called \em{relations}.
11845
11946 \h2{Spatial Hypertext}
12047
121 In HTML, pages are identified by names. Organization is largely
122 done by creating other pages that name things together. For
123 example, I could create a web site in which I build up index
124 pages that describe how I structure my site. URLs originally
125 also mapped to hierarchical folder structures, and it's common
126 for people to treat them in a similar way today, but by no
127 means is that obligatory on the modern web.
48 In HTML, pages are identified by names. Organization is largely done by creating other pages that name things together. For example, I could create a web site in which I build up index pages that describe how I structure my site. URLs originally also mapped to hierarchical folder structures, and it's common for people to treat them in a similar way today, but by no means is that obligatory on the modern web.
12849
129 Some historical hypertext systems took a different approach: each
130 node was identified with a location in a spatial field, so navigating
131 a piece of hypertext could involve not just links that 'took you'
132 to other nodes, but also following spatial paths which connected
133 nodes positioned on or along those paths.
50 Some historical hypertext systems took a different approach: each node was identified with a location in a spatial field, so navigating a piece of hypertext could involve not just links that 'took you' to other nodes, but also following spatial paths which connected nodes positioned on or along those paths.
13451
135 Different spatial hypertext systems took different approaches to
136 this: some of them allowed the user to move nodes around, which
137 could be useful in editing the document. Others took the conceptual
138 relationship between nodes as expressed in the hypertext and
139 extracted a spatial system from that, building up 'maps' to
140 help a reader navigate an otherwise abstract structure.
52 Different spatial hypertext systems took different approaches to this: some of them allowed the user to move nodes around, which could be useful in editing the document. Others took the conceptual relationship between nodes as expressed in the hypertext and extracted a spatial system from that, building up 'maps' to help a reader navigate an otherwise abstract structure.
14153
142 Some
143 systems would even work in the opposite way: allowing the users
144 to position nodes spatially, and then inferring information
145 about the conceptual structure of those nodes from the common
146 spatial patterns produced by users. This was the approach
147 of the
148 \link{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.76.5062&rep=rep1&type=pdf|Viki}
149 system.
54 Some systems would even work in the opposite way: allowing the users to position nodes spatially, and then inferring information about the conceptual structure of those nodes from the common spatial patterns produced by users. This was the approach of the \link{http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.76.5062&rep=rep1&type=pdf|Viki} system.
15055
151 There's actually a very good example of a modern spatial hypertext
152 editing system: \link{|Twine}
56 There's actually a very good example of a modern spatial hypertext editing system: \link{|Twine}
15357
15458 \hr{}
15559
156 Many of the features I've described are structural, and it's pretty
157 obvious in retrospect that HTML and Wikis impose far less structure
158 than many other hypertext systems. In many ways, this is to their
159 advantage: an HTML page can mean anything you want it to, and an
160 HTML link can also be used for any purpose.
60 Many of the features I've described are structural, and it's pretty obvious in retrospect that HTML and Wikis impose far less structure than many other hypertext systems. In many ways, this is to their advantage: an HTML page can mean anything you want it to, and an HTML link can also be used for any purpose.
16161
162 On the other hand, this also makes certain operations infeasible or
163 even nonsensical: a more structured hypertext system can perform
164 operations by looking at the shape or structure of a collection of
165 nodes or links, and can perform computer-aided reasoning. This is
166 one of the reason why the Toulmin method showed up so often in
167 past hypertext research: you were building up relationships between
168 data in ways that you \em{and your system} could both reason about.
169
62 On the other hand, this also makes certain operations infeasible or even nonsensical: a more structured hypertext system can perform operations by looking at the shape or structure of a collection of nodes or links, and can perform computer-aided reasoning. This is one of the reason why the Toulmin method showed up so often in past hypertext research: you were building up relationships between data in ways that you \em{and your system} could both reason about.
1 \meta{ ( "intro" "an introduction" ("meta") ) }
1 \meta{ ( "intro" "an introduction" ("meta") 1446577204) }
22 There are three reasons I'm starting this blog.
33
44 Number one: I want to force myself to write in a concerted, focused
1 \meta{( "io-basics" "the io programming language" ("programming"))}
1 \meta{( "io-basics" "the io programming language" ("programming") 1448061082)}
22 The Io language is a small, very cool object-oriented language.
33
44 There's a broad consensus among the programming-language
1 \meta{( "lojban-basics" "the basics of lojban" ("language") )}
1 \meta{( "lojban-basics" "the basics of lojban" ("language") 1446919370)}
22 Lojban is almost certainly one of the dorkiest things in existence. It's
33 nevertheless pretty interesting.
44
1 \meta{("microtonal-music"
2 "microtonal music"
3 ("music"))}
4
5 There was a recent, very good blog post by
6 \link{https://eev.ee/|Eevee} about
7 \link{https://eev.ee/blog/2016/09/15/music-theory-for-nerds/|Music Theory For Nerds},
8 which is a very good introduction.
9 That blog post inspired me to write about a
10 particular niche interest of mine, which is the slightly dauntingly-named
11 field of \em{microtonal music}. I'll rehash the important details from that
12 post here, but one way or another, you should do yourself a favor and read
13 that post, too.
14
15 Let's start by dipping way down into very basic sounds!
1 \meta{("pythagorean-tuning-and-equal-temperament"
2 "pythagorean tuning and equal temperament"
3 ("music") 1476776339)}
4
5 There was a recent blog post by \link{https://eev.ee/|Eevee} called \link{https://eev.ee/blog/2016/09/15/music-theory-for-nerds/|Music Theory For Nerds}, which is an excellent whirlwind introduction to a vast swath of music theory. It's very good, and you should go read it.
6
7 When I first read it, it reminded me that one topic I've wanted to write about on this blog was microtonal music. As it turns out, writing about the motivation and theory behind microtonal music involves delving into some of the more esoteric foundations of Western music, to the degree that this post doesn't even get to microtonal tunings. Eevee at one point remarks, on the topic of our twelve-note octave:
8
9 \blockquote{
10 I don’t know why twelve in particular has this effect, or if other roots do as well, but it’s probably why Western music settled on twelve.
11 }
12
13 This blog post is a post about how we settled on twelve.
1614
1715 \h1{Consonance and Dissonance}
1816
19 It helps us to think of sounds as abstract \em{waves}, which correspond to the
20 vibrations of air or other ambient material that create or carry sound. For
21 our purposes, we can think in terms of simple repeating waves like
22 \em{sine waves}, which sound like this:
23
24 [insert sound here]
25
26 We can visualize this sound like this:
27
28 [insert image here]
29
30 When we talk about the \em{frequency} of this sound, we're talking about how
31 often those peaks show up. Frequency is measured in hertz (abbreviated as Hz),
32 which just means "number per second".\ref{hertz}
17 It helps us to think of sounds as \em{waves}, which correspond to the vibrations sound-carrying materials like air. For demonstration here, I'll be using basic \em{sine waves}, which sound like this:
18
19 \audio{static/tuning/sinewave.mp3}
20
21 We can visualize a sine wave as looking more or less\ref{ink} like this:
22 \sidenote{I drew this in Inkscape and not a graphing tool, so it's not totally accurate, but it doesn't need to be a perfect sine wave to be an okay teaching tool.}
23
24 \img{static/tuning/sin.svg}
25
26 When we talk about the \em{frequency} of this sound, we're talking about the time between peaks in the wave. Frequency is measured in \em{hertz} (abbreviated as \em{Hz}),
27 which in this context just means "peaks of the wave per second".\ref{hertz}
3328 \sidenote{It's also my least favorite kind of donut.}
34 Two sounds that have the same number of peaks per second are perceived as
35 "the same" by human beings.
36
37 Additionally, sounds whose frequencies are simple ratios are perceived as
38 somehow "pleasing", and the less simple the ratio is, the less pleasant the
39 sound. For example, a \tt{2:1} ratio of sounds is still pleasant:
40
41 [insert sound here]
42
43 However, a ratio of [INSERT RATIO HERE] sounds awkward and harsh:
44
45 [insert sound here]
46
47 In music and music theory, sounds which sound pleasant together are
48 \em{consonant} and sounds which sound unpleasant together are called
49 \em{dissonant}. These two terms aren't separated by a strict line:
50 some pairs of sounds are clearly consonant (such as the \tt{2:1} ratio)
51 and some are clearly dissonant, but there is no well-defined cutoff
52 point where sounds stop being consonant and start being dissonant. It's best
53 to think of them as relative terms: a pair of sounds can be
54 \em{more consonant} or \em{more dissonant} than another.\ref{condis}
55 \sidenote{It's also important to note that the terms \em{consonant} and
56 \em{dissonant} are old, but have been informally and sometimes
57 contradictorily defined for centuries: some people define them in terms of
58 frequencies, some in terms of perception, some in terms of both. Defining
59 them as \em{pleasant} and \em{unpleasant} is pretty reductive, but
60 not completely wrong.}
61
62 So, when we
29 Two sounds that have the same number of peaks per second are perceived by human being as being the same sound.
30
31 Additionally, sounds whose frequencies are simple ratios are perceived as somehow "pleasing", while sounds whose frequencies are related by more complicated ratios are perceived as "less pleasing". For example, this will play two frequencies in sequence and then together, one at 300 Hz, and one at 600 Hz, which are related by a \tt{2:1} ratio. The two sounds will sound appropriate to one another:
32
33 \audio{static/tuning/consonant.mp3}
34
35 In comparison, a less simple ratio—here, 300 Hz and 573 Hz, related by a \tt{100:191} ratio—will sound somewhat less pleasant when played together:
36
37 \audio{static/tuning/dissonant.mp3}
38
39 In music and music theory, sounds which "go together" are said to be \em{consonant} and sounds which "don't go together" are called \em{dissonant}. There isn't a strictly-defined separation between the two: some pairs of sounds are clearly consonant (such as the \tt{2:1} ratio) and some are clearly dissonant, but there is no well-defined cutoff point where sounds stop being consonant and start being dissonant. It's best to think of them as relative to one another: a pair of sounds can be \em{more consonant} or \em{more dissonant} than another pair, rather than being \em{consonant} or \em{dissonant} on an absolute scale.\ref{condis} \sidenote{Also note that the terms \em{consonant} and \em{dissonant} are old, and have been informally and sometimes contradictorily defined for centuries: some people define them in terms of frequencies, some in terms of perception, some in terms of both. Defining them as \em{pleasant} and \em{unpleasant} is reductive, but not necessarily a bad intuition.}
40
41 \h1{Picking Points in Sound-Space}
42
43 When we write music, we generally want to put pleasant sounds together, which suggests that we'd like to take the space of all possible sounds—many of which are not going to sound pleasant together at all—and carve it up so that we can have a nice grab-bag of consonant frequencies to work with while omitting dissonant ones. Let's start in a very simple way: we know that intervals composed of simple ratios of frequences are consonant, so let's start with two of the simplest possible ratios—the \tt{2:1} ratio and the \tt{3:2} ratio—and use them to build up a set of "compatible" sounds, a bunch of sounds we can pull from that are guaranteed to have some consonant neighbors in the same set.
44
45 Let's start with 400 Hz as our first tone:
46
47 \svgimg{static/tuning/s1.svg}
48
49 Let's stipulate that every frequency which can be generated from 400 Hz using the \tt{2:1} ratio—that is, frequencies like 100 Hz, 200 Hz, 800 Hz, 1600 Hz—are also included, because all of those frequencies are always going to be consonant with each other. Whenever we add a new frequency \\(f\\) to our scale, we are also going to add \\(2^n \\times f\\) for every integer \\(n\\).
50
51 \svgimg{static/tuning/s1-5.svg}
52
53 Now, let's generate another sound using by the \tt{3:2} ratio. \\(400 \\times \\frac\{3\}\{2\}\\) produces \\(600\\). So, let's add 600 Hz (again including every frequency of the form \\(2^n \\times 600\\), outside the range of our graphic.)
54
55 \svgimg{static/tuning/s2.svg}
56
57 Next, \\(600 \\times \\frac\{3\}\{2\}\\) produces \\(900\\). That's outside the range I've chosen to display here: but, like before, we're going to be including not just 900 Hz, but also all the doubled and halved frequencies we can reach from 900 Hz, and one of those—450 Hz—is within the range of our graphic. Luckily, no matter which new tone we choose add, we're going to also be adding one corresponding tone in the 400 Hz to 800 Hz range, so whenever the new tone generated by application of the \tt{3:2} ratio is outside this range, I'll go ahead and halve it, so every new set of frequencies we generate will be in this range.
58
59 \svgimg{static/tuning/s3.svg}
60
61 Okay, let's keep going: \\(450 \\times \\frac\{3\}\{2\}\\) is 675:
62
63 \svgimg{static/tuning/s4.svg}
64
65 You know the drill now, so I'm just going to list a bunch more:
66 \ul{
67 \li{ \\(675.00 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} = 506.25\\) }
68 \li{ \\(506.25 \\times \\frac\{3\}\{2\}\\ \\ \\ \\ \\ \\ \\ \\ \\approx 759.37\\) }
69 \li{ \\(759.37 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} \\approx 569.53\\) }
70 \li{ \\(569.53 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} \\approx 427.14\\) }
71 \li{ \\(427.14 \\times \\frac\{3\}\{2\}\\ \\ \\ \\ \\ \\ \\ \\ \\approx 640.72\\) }
72 \li{ \\(640.72 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} \\approx 480.54\\) }
73 \li{ \\(480.54 \\times \\frac\{3\}\{2\}\\ \\ \\ \\ \\ \\ \\ \\ \\approx 720.81\\) }
74 \li{ \\(720.81 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} \\approx 540.61\\) }
75 }
76
77 I'm going to stop there—I'll explain why in a moment—but here's what
78 all the tones we've created so far look like:
79
80 \img{static/tuning/all.svg}
81
82 If you play them in the order we created them, they sound like this:
83
84 \audio{static/tuning/circle.mp3}
85
86 If you play them from left to right, they sound like this:
87
88 \audio{static/tuning/scale.mp3}
89
90 These tones might seem familiar if you've played on (or with) a piano before: we've recreated the tones on a piano keyboard! …or, well, we've gotten \em{very close}.
91
92 \h1{Pythagorean Comma}
93
94 I've been avoiding lumping in too much new jargon, but I might as well do a few reveals: the set of notes I've been building up is generally called \em{Pythagorean Tuning}; an interval with a \tt{2:1} ratio is called an \em{octave}; an interval with a \tt{3:2} ratio is generally called a \em{perfect fifth}, due to a note-numbering system I'm going to gloss over here.
95
96 You'll recall I stopped generating notes after we accumulated twelve of them. We could try to keep going, but something funny thing happens after we add the next note, which is that we get \em{almost but not quite} back to where we started: \\(540.61 \\times \\frac\{3\}\{2\} \\times \\frac\{1\}\{2\} \\approx 405.45\\).
97
98 \svgimg{static/tuning/wolf.svg}
99
100 If you play 405.45 Hz and 400 Hz together, they sound close but not \em{quite} the same. They're certainly a lot closer together than any other pair of notes we've produced so far! If you play them next to each other, you can barely hear the difference:
101
102 \audio{static/tuning/almost.mp3}
103
104 It turns out that if you keep using the \tt{3:2} ratio to generate tones, you'll never \em{exactly} get back to where you started: instead, you'll start generating tones that differ just slightly from the ones you already generated. You can keep going, and you'll keep generating more frequencies that will all be slightly different than the ones you generated before, and get back to yet another note that's a bit above 405.45 Hz, and so forth. The closest we'll get to the original 400 Hz will be after we've applied the \tt{3:2} ratio \em{53 times}, but even then, we're not going to hit 400 Hz exactly.
105
106 The difference between that original root frequency (400 Hz) and the almost-but-not-quite-the-root frequency (405.45 Hz) is referred to as \em{Pythagorean comma}\ref{comma}.
107 \sidenote{The word \em{comma} derives from a Greek word for 'cutting': in typography, it originally referred to the part of the sentence after a punctuation mark, which was 'cut off' from the beginning of the sentence, and gradually came to signify the mark itself. In this musical sense, it was originally used because the Pythagorean comma is a 'cut-off portion' of the musical scale.}
108 It's not really very useful to measure Pythagorean comma in hertz, because the difference between the root value and the not-quite-the-root value depends on which frequency we choose as the root, i.e. if we were working in the range of 300 Hz to 600 Hz, then it would be smaller (the difference between 304.09 Hz and 300 Hz), but if we were working in the range of 500 Hz to 1000 Hz, then it would be larger (the difference between 506.82 Hz and 500 Hz.) So let's move away from hertz and start using a different unit of measurement, one where we cancel out the logarithmic nature of frequencies: the \em{cent}.
109
110 The cent is a unit defined in terms of ratios of frequencies, so that the space of an octave—that is, a frequency and its double or half—is always expressed as exactly 1200 cents. Cents turn out to be wonderful for expressing tunings. I'm going to gloss over the conversion formulae between frequencies and cents—you can find them \link{https://en.wikipedia.org/wiki/Cent_(music)#Use|on Wikipedia, of course}—and convert all the frequencies we've generated into cents. I'll include the not-quite-the-root frequency at the end of the table:
111
112 \table{
113 \tr{ \th{ frequency } \th{ cents } }
114 \tr{\td{400.00 Hz} \td{0.00 cents}}
115 \tr{\td{427.14 Hz} \td{113.68 cents}}
116 \tr{\td{450.00 Hz} \td{203.91 cents}}
117 \tr{\td{480.54 Hz} \td{317.59 cents}}
118 \tr{\td{506.25 Hz} \td{407.82 cents}}
119 \tr{\td{540.60 Hz} \td{521.50 cents}}
120 \tr{\td{569.53 Hz} \td{611.73 cents}}
121 \tr{\td{600.00 Hz} \td{701.95 cents}}
122 \tr{\td{640.72 Hz} \td{815.64 cents}}
123 \tr{\td{675.00 Hz} \td{905.86 cents}}
124 \tr{\td{720.81 Hz} \td{1019.55 cents}}
125 \tr{\td{759.37 Hz} \td{1109.77 cents}}
126 \tr{\td{\red{405.45 Hz}} \td{\red{23.46 cents}} }
127 }
128
129
130 Okay, now we have a value for Pythagorean comma: it will always be approximately 23.46 cents, regardless of which base frequency we choose to work with.\ref{pycom}
131 \sidenote{Cents are a more convenient way of expressing ratios of frequencies, but if we wanted to express Pythagorean comma as a ratio, it would be \tt{531441:524288}.}
132
133 Now, let's also try graphing all our cent amounts, including the close-to-the-root note. We end up with something that looks like this:
134
135 \svgimg{static/tuning/cents.svg}
136
137 See those two dots near each other, all the way on the left? The difference between them is what we mean by \em{Pythagorean comma}.
138
139 As an interesting aside: the existence of Pythagorean comma is also the reason for one of the odd vestigial features of musical notation: namely, the existence of \em{enharmonically equivalent notes}. When learning modern music notation, you quickly learn that there are some odd redundancies in staff notation, including the fact that some notes can be expressed more than one way: for example, A♭ and G♯ are two ways of writing the same note. That's true with modern tunings and notation, but one reason for having both notations is that they \em{did} used to connote different notes in tunings like the Pythagorean tuning: if we use A♭ as our root note, then we'd write our close-to-the-root-but-not-quite note as G♯, and the two would differ from each other by the Pythagorean comma. This distinction is no longer made, but we're still stuck with the notation.
140
141 Back to the scale we're generating, where we have have to decide what to do with the not-quite-the-root note: we could include our it in the scale we're creating, and maybe even continue generating new frequencies from our \tt{3:2} generator. This would build a scale that includes more and more notes, but in addition to requiring some a physically unwieldy keyboards, our scales are already getting diminishing returns from including these new notes: our goal was to choose a set of notes that sounded good together. Already, we've confused would-be composers to including two very-nearly-the-same notes when all the other notes are nicely distinct, and that new root isn't going to sound nearly as nice when played with some of the notes we generated earlier. Anyway, since we our new note is \em{almost} just the original root note, we could just leave it off, stop the scale with only twelve notes. Sure, that means that one of our intervals is gonna be a \em{teeny} bit less consonant than the others, but most of them sound great, right?
142
143 As it turns out, that's exactly what Western music did for about two thousand years.
144
145 \h1{What Are The Problems with Pythagorean Tuning?}
146
147 The tuning I've described here was originally described by Pythagoras\ref{pyth}
148 \sidenote{Surprising, I know.}
149 in the 6th century BCE, and was historically quite popular in Western music up until about the 16th century. It has a nice basis in mathematics, and features the \tt{2:3} ratio throughout, which means it has a lot of nice consonances between its various notes. However, the West has stopped using this tuning nearly as much as it once did. What are the problems with it? Why would we want something else?
150
151 Well, for one, there are a lot of ratios other than \tt{2:3} that \em{also} sound nice: for example, the \tt{4:5} ratio, being small and simple, is also a consonant interval. If we apply that ratio to our root note from before of 400 Hz, then we get \\(400 * \\frac\{5\}\{4\} = 500\\). This frequency isn't in the scale we created. The closest we have is 506.25 Hz, which corresponds a ratio of \tt{81:64}—close, but not really as pleasant as a real \tt{4:5} ratio. Take a listen: the following clip alternates back and forth between a perfect \tt{3:4} interval and the less-pleasing \tt{81:64} interval we get from Pythagorean tuning:
152
153 \audio{static/tuning/ditone.mp3}
154
155 That meant that music composed with Pythagorean tuning in mind tended to avoid that interval—what we now call a \em{major third}—because it just didn't sound as nice as it does in other tuning systems.
156
157 Another big problem was \em{the wolf}, which is a wonderfully evocative name for a musical phenomenon. In Pythagorean tuning, once we've arranged every tone in ascending order of frequency, the fifth—that is, the tone that's related to the root tone by the \tt{2:3} ratio—is seven steps up from the root, as you can see here:
158
159 \svgimg{static/tuning/fifth.svg}
160
161 If we move our focus to the next note up from each of those—the second and the eight frequency in our list, respectively—we discover that they are \em{also} related to each other by the \tt{2:3} ratio! If we look at every note and its partner seven steps above it—looping around when necessary—we find that each of those pairs is related to each by a simple, pleasing ratio, either \tt{2:3} or \tt{3:4}. …well, all of those pairs them except one.
162
163 \table{
164 \tr{ \th {Tone\sub{i}} \th {Tone\sub{i+7}} \th {Ratio} }
165 \tr{ \td {400.00 Hz} \td {600.00 Hz} \td {1.500}}
166 \tr{ \td {427.15 Hz} \td {640.72 Hz} \td {1.500}}
167 \tr{ \td {450.00 Hz} \td {675.00 Hz} \td {1.500}}
168 \tr{ \td {480.54 Hz} \td {720.81 Hz} \td {1.500}}
169 \tr{ \td {506.25 Hz} \td {759.38 Hz} \td {1.500}}
170 \tr{ \td {540.61 Hz} \td {400.00 Hz} \td {\red{1.352}}}
171 \tr{ \td {569.53 Hz} \td {427.15 Hz} \td {1.333}}
172 \tr{ \td {600.00 Hz} \td {450.00 Hz} \td {1.333}}
173 \tr{ \td {640.72 Hz} \td {480.54 Hz} \td {1.333}}
174 \tr{ \td {675.00 Hz} \td {506.25 Hz} \td {1.333}}
175 \tr{ \td {720.81 Hz} \td {540.61 Hz} \td {1.333}}
176 \tr{ \td {759.38 Hz} \td {569.53 Hz} \td {1.333}}
177 }
178
179 There's an odd one out in this tuning, and it's because of the Pythagorean comma: a perfect fifth up from 540.61 Hz is 810.92 Hz, but that frequency corresponds to the not-quite-the-root note that we chose to omit from our scale. Instead, we kept the \em{actual} root, 400 Hz (or the corresponding note an octave higher, at 800 Hz) which, when taken with 540.61 Hz, produces an interval that doesn't really sound like a fifth, and instead produces a kind of dissonant "beating" when you listen to it.
180
181 This interval was said to "howl" when played, so it was avoided by composers, who referred to it as \em{the wolf}. It's also sometimes called a \em{Procrustean fifth}, because of the way \link{https://en.wikipedia.org/wiki/Procrustes|it doesn't really fit}. Similar not-quite-right intervals will arise in other alternate tuning systems, so the phrase \em{wolf interval} also refers to any these kinds of intervals in other systems. When Pythagorean tuning was in widespread use, composers had to be aware of wolf intervals when composing, and would write compositions that didn't ever use that particular interval.
182
183 Here is a sound clip which first plays a 540.61 Hz tone paired with a perfect fifth (at 810.92 Hz), and then plays the same tone paired with 800 Hz, which is the interval referred to as "the wolf".
184
185 \audio{static/tuning/wolf.mp3}
186
187 What else could we do if we wanted to build a musical system that didn't have problems like the wolf? In the sixteenth and seventeenth centuries, Western music in general moved to a different system called \em{quarter-comma meantone}—which was a different tuning system that actually had an even more acute wolf interval\ref{wlf}—but \sidenote{In Pythagorean tuning, the wolf interval is about 23 cents flat, while in quarter-comma meantone, it's 35 cents sharp.} I'm going to skip over that one as well as a handful of other systems, and move straight to the system we picked up in the 19th century without looking back: \em{equal temperament}\ref{edo}.
188 \sidenote{
189 This is also sometimes more specifically called \em{12-TET}, for '12-Tone Equal Temperament', or \em{12-EDO}, for '12 Equal Divions of the Octave'.
190 }
191
192 \h1{Equal Temperament}
193
194 Let's look again at the chart that shows the frequencies of a Pythagorean tuning, as well as how many cents each one is from the root:
195
196 \table{
197 \tr{ \th{ frequency } \th{ cents } }
198 \tr{\td{400.00 Hz} \td{0.00 cents}}
199 \tr{\td{427.14 Hz} \td{113.68 cents}}
200 \tr{\td{450.00 Hz} \td{203.91 cents}}
201 \tr{\td{480.54 Hz} \td{317.59 cents}}
202 \tr{\td{506.25 Hz} \td{407.82 cents}}
203 \tr{\td{540.60 Hz} \td{521.50 cents}}
204 \tr{\td{569.53 Hz} \td{611.73 cents}}
205 \tr{\td{600.00 Hz} \td{701.95 cents}}
206 \tr{\td{640.72 Hz} \td{815.64 cents}}
207 \tr{\td{675.00 Hz} \td{905.86 cents}}
208 \tr{\td{720.81 Hz} \td{1019.55 cents}}
209 \tr{\td{759.37 Hz} \td{1109.77 cents}}
210 }
211
212 Notice how the stride between each pair of adjacent tones is roughly similar, but with some bit of wiggle room. Let's look at the sizes of the gaps between each adjacent pair of frequencies, calculated in cents:
213
214 \table{
215 \tr{ \th{ frequency } \th{ cents } \th { change in cents } }
216 \tr{ \td{400.00 Hz} \td{0.00 cents} \td{+90.23 cents} }
217 \tr{ \td{427.14 Hz} \td{113.68 cents} \td{+113.68 cents} }
218 \tr{ \td{450.00 Hz} \td{203.91 cents} \td{+90.22 cents} }
219 \tr{ \td{480.54 Hz} \td{317.59 cents} \td{+113.68 cents } }
220 \tr{ \td{506.25 Hz} \td{407.82 cents} \td{+90.22 cents } }
221 \tr{ \td{540.60 Hz} \td{521.50 cents} \td{+113.68 cents } }
222 \tr{ \td{569.53 Hz} \td{611.73 cents} \td{+90.22 cents } }
223 \tr{ \td{600.00 Hz} \td{701.95 cents} \td{+90.22 cents } }
224 \tr{ \td{640.72 Hz} \td{815.64 cents} \td{+113.68 cents } }
225 \tr{ \td{675.00 Hz} \td{905.86 cents} \td{+90.22 cents } }
226 \tr{ \td{720.81 Hz} \td{1019.55 cents} \td{+113.68 cents } }
227 \tr{ \td{759.37 Hz} \td{1109.77 cents} \td{+90.22 cents } }
228 }
229
230 We can see that every note is either 90 or 113 cents above the previous note. This hints at one approach we can take to avoid dissonant intervals like the wolf: given that they're all more or less similar already, we could just fudge all the intervals so they're all exactly equal. That means each interval might not sound \em{quite} perfect—no two of them will be related by a perfect simple ratio—but to most untrained ears, they'll be close enough. Now, instead of doing some elaborate set of frequency multiplications to choose our notes as in Pythagorean tuning, we just split the octave into twelve equal steps of 100 cents each, and convert those back to get our frequencies:
231
232 \table{
233 \tr{ \th{ frequency } \th{ cents } \th { change in cents } }
234 \tr{ \td{ 400.00 Hz } \td{ 0.00 cents } \td{ } }
235 \tr{ \td{ 423.78 Hz } \td{ 100.00 cents } \td{ +100 cents } }
236 \tr{ \td{ 448.98 Hz } \td{ 200.00 cents } \td{ +100 cents } }
237 \tr{ \td{ 475.68 Hz } \td{ 300.00 cents } \td{ +100 cents } }
238 \tr{ \td{ 503.96 Hz } \td{ 400.00 cents } \td{ +100 cents } }
239 \tr{ \td{ 533.93 Hz } \td{ 500.00 cents } \td{ +100 cents } }
240 \tr{ \td{ 565.68 Hz } \td{ 600.00 cents } \td{ +100 cents } }
241 \tr{ \td{ 599.32 Hz } \td{ 700.00 cents } \td{ +100 cents } }
242 \tr{ \td{ 634.96 Hz } \td{ 800.00 cents } \td{ +100 cents } }
243 \tr{ \td{ 672.71 Hz } \td{ 900.00 cents } \td{ +100 cents } }
244 \tr{ \td{ 712.71 Hz } \td{ 1000.00 cents } \td{ +100 cents } }
245 \tr{ \td{ 755.09 Hz } \td{ 1100.00 cents } \td{ +100 cents } }
246 }
247
248 It turns out that this is, broadly speaking, a pretty good approximation! We're within \em{two cents} of a perfect fifth, and most of the other ratios are at least workable. Because our "fifths" are ever-so-slightly less than a perfect \tt{2:1} ratio, we can loop around and get back to \em{exactly} the root note, and consequently our wolf intervals disappear, as well.
249
250 Of course, we did this by fudging things, so none of these ratios are going to sound \em{exactly} as nice. We still don't approximate the \tt{5:4} ratio very well—we're about fourteen cents too high—but again, an untrained ear probably won't really notice. And it turns out that we do approximate a perfect fifth to within two cents, which is a pretty good approximation!
251
252 It's a pretty convenient system, and it's in pretty wide use today: at the very least, it's how a lot of people think about tuning. In practice, a number of instruments can't use equal temperament \em{exactly} because of physical limitations on the instrument itself, and singers tend to use something closer to the Pythagorean tuning (because it's easier to make your voice go up a perfect fifth than an ever-so-slightly-imperfect fifth) but we tend to treat equal temperament as the ideal tuning for most modern instruments.
253
254 I have more things to say, but this post is already a bit long, so I'm going to split the rest of this material into a separate post. Next time: \em{microtonal music}!
1 \meta{( "structural-res" "structural regular expressions" ("programming") )}
1 \meta{( "structural-res" "structural regular expressions" ("programming") 1472578805)}
22 One of the biggest tragedies of computer science is how we so often forget our field has a history. It's not at all hard to read papers from a decade or two ago and find \link{/2016-03-15/subjects-and-entities/|amazing ideas that never got popular}, or even ideas which are currently being popularized in blog posts and tweets without any idea that there's prior art. As Ron Minnich once said:
33
44 \blockquote
1 \meta{("subjects-and-entities" "subjects and entities" ("programming"))}
1 \meta{("subjects-and-entities" "subjects and entities" ("programming") 1458077247)}
2
23
34 Object-oriented programming is very bad for high-performance programs
45 like graphics- and simulation-intensive video games. Or, at least,
150150 (let* ((page-source (translate-file file))
151151 (telml (telml-content page-source))
152152 (meta (telml-meta page-source))
153 (date (localtime (stat:mtime (stat file))))
153 (date (localtime
154 (or (and meta
155 (meta-date meta))
156 (stat:mtime (stat file)))))
154157 (ndate (date->string date))
155158 (title (if meta (meta-title meta) pg))
156159 (target (outfile (if out out
1010 (content telml-content))
1111
1212 (define-record-type <meta>
13 (make-meta slug title tags)
13 (make-meta-record slug title tags date)
1414 meta?
1515 (slug meta-slug)
1616 (title meta-title)
17 (tags meta-tags))
17 (tags meta-tags)
18 (date meta-date))
19
20 (define (make-meta slug title tags . args)
21 (if (null? args)
22 (make-meta-record slug title tags 0)
23 (make-meta-record slug title tags (car args))))
1824
1925 ;; This builds a stream abstraction, where a stream is a stream of
2026 ;; characters. This makes writing a parser a _lot_ easier.
133139 (simple-tag 'h1)
134140 (simple-tag 'h2)
135141 (simple-tag 'table)
142 (simple-tag 'th)
136143 (simple-tag 'tr)
137144 (simple-tag 'td)
138145 (cons 'header (lambda args `(th ,@(map (lambda (x) (list 'td x)) args))))
146153 (cons 'ttkw (lambda (n) `(span (@ (class keyword)) ,n)))
147154 (cons 'ttcn (lambda (n) `(span (@ (class constr)) ,n)))
148155 (cons 'ttstr (lambda (n) `(span (@ (class string)) ,n)))
156 (cons 'red (lambda (n) `(span (@ (style "color: red;")) ,n)))
149157 (cons 'tt (lambda (n) (list 'code n)))
150158 (cons 'br (lambda _ `(br)))
151159 (cons 'hr (lambda _ `(hr)))
155163 `(a (@ (href ,(apply string-append url))) ,name)))
156164 (cons 'img (lambda (src)
157165 `(img (@ (src ,(apply string-append src))))))
166 (cons 'svgimg (lambda (src)
167 `(img (@ (class "svgimage")
168 (src ,(apply string-append src))))))
169 (cons 'audio (lambda (src)
170 `(audio
171 (@ (controls "controls"))
172 (source (@ (src ,(apply string-append src))
173 (type "audio/mp3"))))))
158174 (cons 'center (lambda (arg)
159175 `(div (@ (align "center")) ,arg))))))
160176
5757 (border "1px solid black")
5858 (border-collapse collapse))
5959
60 (table (width 100%))
61
62 (td (padding 6px))
63
6064 ((= class all)
61 (width 800px)
65 (width 1000px)
6266 (margin-left auto)
6367 (margin-right auto)
6468 (text-align center))
106110
107111 ((// (= class tags) ul)
108112 (display inline))
113
114 ((= class svgimage)
115 (display float)
116 (width 100%)
117 (margin-left auto)
118 (margin-right auto))
109119
110120 ((= class para)
111121 (padding-top 20px))