Basic Music Theory in ~200 Lines of Python
As a primer for music theory, this post doesn't teach much. It's using Python to derive various sets of notes in scales and modes, which is already easily available via google search, and in a more learnable format than Python code.<p>The most basic aspect of Western music theory overlooked here is the relationship between tonic and dominant. If you know the "home" chord aka "the I" aka "tonic" is C major, the dominant will be G major, aka the V chord. Add just the F major chord, and you'll know 1-4-5 in a "basic" key: C major. 1-4-5 is the simplest chord progression, you can play amazing grace, you are my sunshine, even The Beatles, you'll be rocking with 1-4-5.<p>Next level, if you add in the minor 6 (a minor) and minor 2 (d minor), you realistically know 95% of the chords you'll ever hear in C major pieces. And on the piano, this is ALL white notes, so even someone with zero musical knowledge can "solo" over your chords by just plunking any white notes while you play these chords (kids LOVE LOVE this btw, highly recommend trying with a kiddo).<p>I wouldn't consider double-sharps and double-flats "basic" music theory. They really aren't needed for beginners, since they're relegated to keys like C# major where you'll occasionally sharpen a note like E# (aka F) into E## (aka F#). I didn't run into these until around 5 years into my piano training, playing Chopin's F# major nocturne Op 15 No 2, there's a bunch of double sharps in that piece.<p>In any case, don't worry about double-flats and double-sharps or the precise notes of various modes and scales. Just learn pieces you enjoy, preferably with a mentor or teacher who can suggest improvements based on their trained ear.