Music theory for programmers

18 points by thev


rprospero

My father always wanted to be a composer, but was stymied by a lack of mathematical ability. When I proved to have some mathematical talent, he was so excited for me to get into music, but I proved to have zero musical talent and have always been vastly confused by the most elementary parts of the topic. The use of the word "elementary" is literal - by the second half of first grade, I was completely lost at what was going on in music class.

My first confusion that even this article commits is the claim that, when you double the frequency, you get the same note. This is always presented as so obvious to not need explanation, but, while I'm well versed in the harmonics explanation, I've never actually heard a sameness between the two sounds. Alternately, I may have completely misunderstood what a note is supposed to be?

My second confusion was at least slightly addressed by this article. At forty-four years old, this is the first time that I've ever heard that the first beat of a measure was supposed to be played louder. I was always just given the tautological definition that, in 4/4 time, a beat was defined as a fourth of a measure and a measure was defined as four beats. By that definition, I could merge ever pair of measures, declare the time signature is 8/4, and get back the exact same song. I was always told that was wrong, but the only explanation I ever got was that 8/4 wasn't 4/4 time.

munificent

I think music theory teaching that just says "the only reason we do it this way is because people got used to it and it sounds familiar so we like" does students a disserve because it makes everything in music sound arbitrary, which it's not.

I also think posts like this which say "it's all just math and logic under the hood and makes perfect sense" in some CS also do students a deep disservice. It sucks the human element out and encourages students to think about music as simply playing a game where you have to follow the rules to get a correct answer.

The truth is that music is a mixture of both. There is real math behind acoustics and psychoacoustics. The sounds, pitches, intervals, and chords we like are not completely random. But as music listeners, we are also not simply listening to discriminate whether the composer followed the math rules right. We want tension and release, a mixture of the familiar and unfamiliar.

If you follow all the rules, your music won't sound wrong, but it will sound boring. You need enough of a foundation of theory to not waste too much time trying to brute force good chords from scratch, but you also need to know when to jam a weird note in because that spiciness perks up the listener's ear in just the right way.

And, as a listener, you are already doing that. The sounds that catch your ear are the ones that have enough familiarity and consistency with rules and tradition that you can aurally parse them, but that have enough novelty and originality to be worth listening to.

brehaut

I’m a little cautious that using perfect synthesis to explain music theory and to then make some pretty universal claims about music across all cultures is maybe not accurate? Most physical instruments are not perfect (a great example of this is the frets on a regular guitar compared to the wobbly frets on a “true temperament” guitar), there’s more that goes into even something as simple as a scale than just the harmonic series in a vacuum.

Even if we limit ourselves to western music, 12 tone equal temperament was adopted in the 18th century, which moved further away from the harmonic series based tuning system that preceded it (Just intonation) because there are organisational properties that make it more useful most of the time.

(Edit: Corrected the proceeding paragraph which I initially wrote entirely backwards from what i meant)

snej

This is good stuff! I really wish I’d had something like this in my early 20s when I first got a keyboard and nothing made sense — “Why do they divide the octave in 12 but then have seven note names? Seven doesn’t go into twelve!” It was also confusing that sometimes they talk about intervals in terms of numbers of semitones and sometimes in scale steps. Being a nerd, I couldn’t work with something whose structure didn’t make sense to me.

It wasn’t until my 40s that I got back into music and gradually figured this shit out. I made a bunch of spreadsheets of scales and chords and stuff as learning aids.

Oh, and add me to the list of people for whom octaves don’t sound like “the same note”. Very similar, yes, but I still have to think a moment to tell an octave interval from a fifth.

rs86

Just the last week I was writing groups for drum rudiments. I was working with paradiddles and shift, reverse and flip operations, turns out it gives a few different groups, mostly related to the cycle groups and their quotients. Also playing with free monoids / generating new rudiments from smaller cells gives different strings and it's nice to play with, e.g, instead of combining L and R strokes combining LL, LR, RR, RL, not too complicated or fancy, but certainly fun to play with

Also, its interesting to work with representations of sheet music, with parallel/sequential composition on the one hand and dividing the whole of the song into fractions on the other, and mapping between both, with some anciliary data

Still, haven't found a simple one-liner that outputs say the first page of stick control using just a few primitives and combinators