Sunday, May 19, 2013

Get Aeolian

I've been listening to Major Lazer's song Get Free a lot recently. If you haven't heard it before, here's the music video:

After playing the song a dozen or so times in a couple days, I figured it might be worth learning how to actually play it. I've only just started trying to play along to it by ear, but it's already becoming pretty clear that there's some interesting stuff going on.

For one thing, this song has one of the simplest chord progressions imaginable: G-A-Bm-G. That's three chords for the whole song (and they're easy enough chords that I could actually play them on a guitar, if I had a guitar).

So if there are only three chords, what makes the song interesting? As with a lot of electronic music, the timbre of sounds is important: the echoing, bouncy, electronic part contrasts with the vocal cries. It's also strong lyrically (at least I think so, "feeling like a battery hen" is a great simile). However, I think that even when you only consider the pitch of notes in the song it's still interesting, so the question is: how does that work?

It turns out that "Get Free" is a textbook example of the Aeolian mode (on B) [I started writing this post because I initially thought it was in Dorian, which would have been neat, because I don't know any popular Dorian mode songs; Aeolian is a bit less exciting, but oh well]. That means it's melody is formed from the notes B, C#, D, E, F#, G, and A. This mode is also known as the natural minor scale, since it's a minor scale without the raised sixth or seventh you'd get in the harmonic and melodic minor scales.

Because the natural minor scale is the exact same as the harmonic and melodic minor scales when the sixth and seventh are avoided, the melody simply sounds minor as long as these notes are avoided. However, the chord progression begins and ends on a G major chord and G is the sixth. The second chord in the progression is an A major chord and A is the seventh. Three quarters of the chords in the song are thus major, but they always lead up to the B minor chord before falling back to the G major. Note that in the G-A-Bm-G progression, the root of the chord rises by a whole tone between each of the first three chords which conveys a feeling of growing excitement or momentum, but that momentum is stopped by the minor third chord and we return to the familiar G chord which is repeated once before the chords rise again (and again, for the entire song). The result is sort of an optimistic sound that has been infused with melancholy. The chord progression is constantly rising; constantly retreating.

While the chords progress by rising a tone at a time and falling back, the melody consists primarily of downward runs. At one level, this provides a contrary motion to the bass line since the bass follows the rise of the chord progression. The rise and fall of a melody line also shapes the emotion conveyed by the line; although this isn't as straightforward as up=happy/down=sad. Loosely speaking, the downward parts deflate tension, while the upward ones increase it. My interpretation of the effect this has on the song is that the downward runs convey the sensation of lowering expectations or accepting circumstances, while the upward movements ramp up tension and express a desire to fight back.

Getting back to the use of the Aeolian mode in the song, the seventh (the A) is particularly important for the melody. Normally, you'd expect the melody to resolve to the tonic (B) after hitting the seventh (A), but that usually doesn't happen here. There are quite a few lines that end on an A at the same time as the G major chord is being played ...and that too is unusual. The G major chord contains a G and B: since the A falls between these two notes, the result is highly dissonant and strongly suggests that the melody should resolve to the B. This is often what's happening when the vocal part does its howling thing (for example, when the word "friend" is said in "how long, how long 'til we have a friend"). Not all of the "howls" use this technique ("dreams" in "what will I do without my dreams" is actually sung on a B, but the layered vocals add surrounding notes to create the same dissonance).

The upshot of all this is that it is technically a very simple song, but the techniques it does use are used brilliantly. The simpler a song can be while still remaining distinctive and evocative, the more likely it is to be memorable.

PS. Yes, this is the same Major Lazer that created "Pon de Floor", which is known for its absurd music video featuring daggering. Before you go Googling that, note that Wikipedia quotes some guy as saying "'Pon de Floor' seems equally as offensive as watching porn on hallucinogenic substances" so it might not be the sort of thing to watch at work or around your grandparents.

Saturday, March 2, 2013


If you ever find yourself wondering what the smallest positive integer value is that you cannot represent exactly in a single precision floating point number (using a standard binary32 representation as defined in IEEE 754-2008), the answer is the title of this post.

This little bit of trivia is something I discovered while playing with the tutorial I wrote for the data structures class I'm TA'ing (that tutorial again, in case you missed the plug in my previous post, is available here). The reason it happens is that the exponent of 16777216 is 24, but only 23 bits are used to represent the mantissa (non-exponent part) of the number.

For a double-precision floating-point number, 52 bits are used to represent the mantissa, so the integers from -9007199254740992 to 9007199254740992 can be exactly represented. This is more integers than you can represent with an integer! At least, it's more bits than you can represent with a normal 32-bit integer, which in retrospect is kind of obvious since the number 32 is smaller than 52.

Here's another equally nerdy bit of trivia: you can toggle between lowercase and capital letters that are represented as ASCII characters by toggling the 5th least-significant bit of the character. This works because the value of each lowercase letter is exactly 32 plus the value of the uppercase letter. Since the alphabet contains 26 letters, I assume that this spacing was designed deliberately to make case transformations easier. It's hard to imagine a situation in which switching the case of a letter would be so important that it would require this level of optimization, but the ASCII table was defined a long time ago and perhaps it was necessary for Ye Olde Computers.

In summary, I now know far more about data types than I've ever found necessary before. This is what happens when I try to teach stuff.

PS. If you're about to say "the exponent of 16777216 isn't 24, it's 7, dummy" that's because you are thinking in base ten:
16777216 = 1.6777216  * 10^7
when it's actually calculated in base two:
16777216 = 1.0000000 * 2^24

PPS. If you're thinking "52 bits can't represent the integers from -9007199254740992 to 9007199254740992" then you're right. The sign bit isn't counted in the mantissa and the number zero is represented when all 64 bits in the double are off (aside from the sign bit, which can be either on or off). Zero is a special case; we're basically rounding two values that are really close to zero to exactly zero. These notes go into more detail.

PPPS. For anyone who writes code in JavaScript, one of its quirks is that it stores all numbers as doubles. This means that JavaScript has full coverage of integers in the range -9007199254740992 to 9007199254740992. There are larger and smaller integers that can be exactly represented in JavaScript, but you need to start counting in twos (and once you hit 2^54, you'll need to count in fours, and so on).

Friday, February 22, 2013

Data and websites

I really need to redesign this website at some point.

In the meantime, if anyone wants a rudimentary C tutorial, check this out:

It's been a really long time since I've done any website development. It's not quite as painful as I remember it being (although that's mostly because I only bothered with compatibility for the most recent generation of web browsers).