Music Theory for Programmers

runjs.app

120 points by birdculture 4 days ago


seanhunter - 2 hours ago

This is (mostly) not music theory and what is music theory is mostly wrong or incomplete to the point of being wildly misleading. Source: have degree and postgrad in music, was a professional musician until RSI put paid to that career, wife is a professional musician and teaches to postgrad level at 2 conservertoires, most of our friends are professional musicians, have a house full of scores and music books.

If you actually want to learn music theory for the purposes of playing I strongly recommend you just follow whatever tutorials for your instrument and style and if you get to the point where feel you want to learn more and take it seriously in and of itself, buy “The Jazz Theory Book” by Mark Levine[1]. In spite of what it says, there really isn’t any such thing as Jazz theory - it’s just music theory, and this book is a great presentation with lots of good examples. If you like jazz (or the western popular music tradition including rock, pop, funk, etc) you’ll come out understanding how that music works better than most people. If you’re doing a music degree, there will be books recommended by your music programme, but honestly, Levine will cover most of what you need if you’re not doing a straight classical course in which case you’ll want to augment with a more conventional source so you understand the “rules” they want you to follow when writing pastiche counterpoint etc.

If you want to get big into composition and/or want to understand late romantic and 20th century music, get Harmonielehre and “Structural Functions of Harmony” by Schoenberg. Together they are by far the best harmony books I have ever seen and go super-deep into why the western classical tradition works the way it does. If you compose there’s a decent chance they will change your life forever as his approach is to not take anything for granted but exhibit everything with examples from masterworks of the western tradition. Amazing books both of them. Harmony is not a spectator sport though - to get full benefit you have to get the books and work through stuff on the piano. It will reward you immensely.

If you want something else that will blow your mind, read “The technique of my musical language” by Messiaen. If you read Levine first this will have the additional benefit of showing you where the “diminished” and “augmented” scales and the whole “harmonic major” thing come from.

[1] https://www.shermusic.com/products/the-jazz-theory-book

larodi - 7 minutes ago

https://news.ycombinator.com/item?id=49376704 - 17 days ago https://news.ycombinator.com/item?id=49346025 - 19 days ago

and there's one more 15 days ago, but really - it seems a link needs to be posted several times to take off.

@dang

polotics - 3 hours ago

Let us try an experiment shall we: listen to any music you like and try and match the information the article provided to the complexity of what you are hearing. How much do you see a path from A(rticle) to S(ound in your ear).

This article is trivializing music down to a few not-so-important facts and mistaking some math for anything that would help `programmers` (?) understand music.

Maybe start by rewatching "This is Spinal Tap" instead, and consider that https://www.reddit.com/r/musictheory/comments/59n3pg/remembe...

maybewhenthesun - 2 hours ago

> Which is a strange way to teach a system that essentially comes out of physics and arithmetic. There are twelve notes for a reason.

There is of course a lot of physics involved. But there is at least as much convention at play. So imho this is a very one sided way of looking at it.

There is a physical reason the 12 notes are those 12 notes (though the exact frequencies assigned are influenced by culture as well), but lots of different cultures use less notes, or more, or extra notes inbetween.

So 'Because that is the convention.' is imho at least a good an explanation as the physics one.

yvdriess - 15 minutes ago

I enjoyed the programmer's approach to build it up from first principles. I chuckled at rythm being the binary encoding of the duration's mantissa.

Now dispell the "this is just the western tradition": do Klingon music theory https://youtu.be/1LjcBv-OWtQ

ergonaught - 3 hours ago

I want to read it, because it’s interesting. And yet.

https://bcantrill.dtrace.org/2026/09/05/the-revolt-of-the-re...

pianopatrick - an hour ago

For all the programmers reading this who think music theory is complex, just realize that is how programming seems to most people.

bachbeethovench - 32 minutes ago

Musical traditions, of which the western is only one, are cultural conventions based on a subset of physical facts about sound. There is also a psychological and psycho-social component involved. This is all to say, while i like the post, i find the approach technocratic and one sided, as it will give a false feeling of truth and an illusion of having ultimately understood music. It's a quest for absolute scientific truth in a realm where no such truth exists. I have observed similar understanding problems like the ones the post writer reports with other people, esp. those of a more skeptical, inquisitive and scientifically curious nature. For them, it's esp. hard that, while there is a scientific backing to music, there are also cultural conventions on top that you just have to accept. And these conventions are for example different between western and traditional indian, arabic or chinese music.

theanonymousone - 3 hours ago

How come the same article has been posted four times in the past 18 days? https://news.ycombinator.com/from?site=runjs.app

Doesn't HN have a temporal deduplication system?

WindyTree - 2 hours ago

Pretty good, could use more on the tonic, how it’s defined for a diatonic set of 7 notes. The chosen I IV V primary chords are key for that, but a precious tidbit I learned is any of the notes can be set as tonic, but the I IV V chords are only for major and minor. Like for the notes in C major, it becomes A minor with I IV V chords starting off A, but to set the tonic to F, it becomes F Lydian mode with primary chords I, II, and VII. (Fmag, Gmaj, Emin) The rule for the primary chords of the modes is you find the note that differentiates it from the major or minor scale, and pick the chords that have it avoiding the diminished. Playing the notes of c major starting at f, it’s the sharp fourth b that is different, so the primary triads are f-a-c e-g-b and g-b-d.

Oh, and rhythm is just the same as consonance. Most are octave based, beats on wave peaks of overlaid octaves getting quieter. The 3 based on times like 6/8 are the same but for 5ths and 17ths. (The bottom number 8 is just a BPM hint from old days.) beyond those the intervals get unstable feeling, like 7/4 in Money by Pink Floyd has that cut off feeling, someone took a few from each measure, but maps to a minor 7th interval.

_kb - 2 hours ago

If this is the sort of thing that interests you, I highly recommend setting aside 90 minutes and strapping yourself in for a listen to https://malwebb.com/notnoi.html.

lefra - 3 hours ago

I should not have to install a browser plug-in to opt out of Google analytics (that's what's proposed as an opt-out option in the privacy policy).

Where's the "reject non-essential cookies" button?

euroderf - 2 hours ago

If tasked with this, I would start with an image of a piano keyboard and ask: Why the hell does it look so weird ? Black and white keys in some infernally strange layout ? WHY ?

Which takes you very quickly to equal temperament and perfect fourths and perfect fifths. This tells us where the notes C and F and G are located on the chromatic scale, but then the rest are pretty arbitrary eh. Semitones from C to C go 2-2-1-2-2-2-1, but there is nothing heavenly ordained by this particular arrangement. E-to-F and B-to-C are a collective choice.

If I had been presented with this kind of explanation fifty years ago, I might have been less skeptical of the entire enterprise.

nialv7 - 35 minutes ago

For programmers and written by AI and mostly wrong... What a combo

kmoser - 3 hours ago

This article is quite well done, especially from a programmer's perspective, but falls flat (no pun intended) for me because of my terrible ear for pitch.

> Here are five notes. Every one is double the frequency of the one before it. [...] They are different pitches, and yet they sound like the same note.

Nothing about these notes seem similar to me. You could play pretty much any sequence of rising notes and (falsely) claim they're the "same note" and I'd believe it. This is one reason I've always had trouble learning music.

> √2 the awkward one -> 311.13Hz

That one doesn't sound particularly awkward to me. Again, I blame my inability to distinguish pitch.

The only instrument I was able to pick up pretty easily was drums.

raulparada - 2 hours ago

If you’re a programmer interested in music, do check out Strudel, at least the examples at https://strudel.cc/examples. If you like those (I love them, so much art in a few lines of code), the docs _will_ get you started. Enjoy!

ahmedhossamdev - 39 minutes ago

Website is down I think..

hypfer - 2 hours ago

This is clearly interesting and contributing value, but it's also painfully AI prose to the point where it is hard to not dismiss it as likely false information.

Fun interactive examples though. With another human pass, this could be great.

- 3 hours ago
[deleted]
altmanaltman - 4 hours ago

I learned to play guitar by my own when I was around 12. You don't really even need to know music theory to play guitar, as long as you understand the shapes etc.

Over time, I developed shorthands for understanding theory like i can easily look at a fretboard and know which note it is.

But what bugged me is that you seem to imply the reason why you couldn't learn a instrument was because you did not understand the why. That makes very little sense to me. I know several professional musicians who don't even know what a mode is or what formal notation is. One of them has pitch perfect ear, he can literally hear anything and tranpose that on his guitar. He has no idea how notes work and just writes tabs.

So while this is very nicely from a programmer point of view and an objective explanation of things but learning all this will not make you a better musician is the point.

Practice above all. Dont try to fit all theory into the pratice but understand what you are practicing particulalry using the theory. Otherwise you end up with all theory and no practice experience of using that theory and creativity.

As a perosn who likes code, this is interesting. As a musician who also understands music theory, this is kind of alienating in terms of how it presented. Like if someone just read this article and thought they understood music theory now, they would be pretty unsufferable to actual musicians.

yuumei - 2 hours ago

> Two things fall straight out of that.

Hi Claude

JonathanRaines - 3 days ago

Fantastic post. You took a subject that never made sense to me and made it seem simple.

Fannon - 4 hours ago

Very nice, thanks for creating this!

> The system we want, where the octave is pure and the fifths are pure and everything closes into a neat loop, does not exist and never has. Every tuning system in history is a different choice about where to dump the error.

aidio - 2 hours ago

[dead]