Live data from Hacker News

Basic Music Theory in ~200 Lines of Python

mvanga.com

91–100 of 192 posts

Re: Basic Music Theory in ~200 Lines of Python

#91

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. 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…

Heh, I understood your first paragraph. I understood literally nothing in the following two paragraphs. Is this what it is like when I talk to people who don’t know anything about programming about my work? Pure gibberish?

Re: Basic Music Theory in ~200 Lines of Python

#92

A perfect 5th is not the same as a diminished 6th unless we assume equal temperament tuning. Granted it is the dominant tuning, but it irks me when this is just silently assumed. Plenty of music around that is recorded using actual perfect intervals, so why muddy the waters?

I think going out of equal temperament into other modes of tuning/intonation would definitely be considered outside of "basic music theory". It feels like grumping about some inaccuracies/glossing over in elementary school mathematics because of the existence of imaginary numbers.

I firmly disagree. I learned about staying "in tune" with those that I was playing with in an ensemble long before I learned about equal-temperament and its concessions to multi-key harmony.

I'd say removing the beats from your partials is way more fundamental to both music making and music theory than chromaticism. Chromaticism is the next step, beyond basic music theory.

Re: Basic Music Theory in ~200 Lines of Python

#93

Earlier quoted context omitted.

> If you hear a sound of frequency f and others of frequency 2f, 3f, etc then there's a good chance these sounds come from the same object, due to the physical principle of resonance. And so our perception of sound evolved to reflect this... Wow that's interesting enough to share as a standalone post, so I took the liberty! Thanks for the link!

The quoted sentence seems false to me. Most physical objects do not have naturally harmonic vibration spectra. The vibration modes are not integer multiples ofthe fundamental (except for a vibrating string). Only the finely tuned western instruments do. So this is a somewhat backwards argument.

The code itself also contradicts that sentence. Notice that the first roughness graph doesn't have any local minima at rational numbers. It's only when the overtones are added to the notes (at integer multiples of the fundamental frequency) that the minima appear.

So the code thinks that human ears don't detect integer multiples specifically, they just detect sounds whose overtones line up with each other.

Re: Basic Music Theory in ~200 Lines of Python

#94

Earlier quoted context omitted.

> If you hear a sound of frequency f and others of frequency 2f, 3f, etc then there's a good chance these sounds come from the same object, due to the physical principle of resonance. And so our perception of sound evolved to reflect this... Wow that's interesting enough to share as a standalone post, so I took the liberty! Thanks for the link!

The quoted sentence seems false to me. Most physical objects do not have naturally harmonic vibration spectra. The vibration modes are not integer multiples ofthe fundamental (except for a vibrating string). Only the finely tuned western instruments do. So this is a somewhat backwards argument.

I don't think so. If a sound persists long enough to hear its continuation, then its partials are generally going to be harmonic. Non-resonant frequencies will have a tendency to dissipate very quickly, unless they are explicitly designed to warble between resonances (like a gong or similar).

Re: Basic Music Theory in ~200 Lines of Python

#95

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. 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…

Heh, I understood your first paragraph. I understood literally nothing in the following two paragraphs. Is this what it is like when I talk to people who don’t know anything about programming about my work? Pure gibberish?

Yup!

Re: Basic Music Theory in ~200 Lines of Python

#96
post #54

A perfect 5th is not the same as a diminished 6th unless we assume equal temperament tuning. Granted it is the dominant tuning, but it irks me when this is just silently assumed. Plenty of music around that is recorded using actual perfect intervals, so why muddy the waters?

Interesting. Do you have some reference or link where I can learn more?

The wikipedia page is pretty good https://en.wikipedia.org/wiki/Equal_temperament#Comparison_w...

A fifth might even sound off key if you're very used to equal temperament (it's about 2 cents below an equal temperament). You know it by there being no or less "wobbling" between the tones.

For listening tips, look for vocalist groups where there's "One Voice Per Part" (OVPP). Voces8, Vox Luminis, etc. When there's only one voice, you don't get the inherent wobbling happening when two instruments/voices play in unison.

Not all genres are possible to have just (jazz chord colors would sound rubbish).

Re: Basic Music Theory in ~200 Lines of Python

#97

> Modes are essentially left-rotations of a scale. While true, I find this interpretation harmful to the understanding of modes. It didn't provide me with any insight and instead it seemed irregular to the other theoretical constructs we have and thus deterred and misled me in the beginning. To me, it all clicked when I took all the modes, except Lydian, and constructed them by putting down the augmentations to the m…

One way to make that ordering work with Lydian is to start with Lydian and flatten one note each time. So say we start in C. C lydian, flatten the F# we have C Ionian, flatten the b we have C mixolydian, flatten the e we have C dorian, flatten the A we have C aeolian, flatten the d we have C phrygian, flatten the g we have C locrian

Now we flatten the C (after all this is the next note in the cycle of fifths) and we have.... B lydian. And the whole thing starts again.

In this way you can understand how all the modes and keys relate. You can do a similar thing with the other 3 similar modes of limited transposition in this order (melodic minor, harmonic minor and harmonic major).

Have fun.

Re: Basic Music Theory in ~200 Lines of Python

#98

It can be tricky to deal with the intersection of music and programming. For example: > The chromatic scale is the easiest scale possible So far so good-- in both programming and music we're just stepping through the smallest values (half step for music, the integer "1" in programming). So "easy" definitely applies to both domains. > We can generate a chromatic scale for any given key very easily For programming, sur…

I don't think this is really anything to do with music vs programming. The author just used the wrong words... it's pretty clear they meant "generate a chromatic scale starting at any note" ;)

Thanks for bringing up the connection with symmetric scales -- these are really interesting!

Re: Basic Music Theory in ~200 Lines of Python

#99

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. 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…

Heh, I understood your first paragraph. I understood literally nothing in the following two paragraphs. Is this what it is like when I talk to people who don’t know anything about programming about my work? Pure gibberish?

Add on top the time signature grid and then you got some real giberrish! ‘The 6th hits on the ah of 3 ok!’

Re: Basic Music Theory in ~200 Lines of Python

#100

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. 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…

Heh, I understood your first paragraph. I understood literally nothing in the following two paragraphs. Is this what it is like when I talk to people who don’t know anything about programming about my work? Pure gibberish?

Yes, it is! Music and programming both have a lot of notation, syntax, and terminology.

I am not really a programmer, but the thing I always wanted wasn't a "how to program guide" but "what is all this syntax" guide.

It is funny, but when you learn a written language, you spend a lot of time learning grammar and punctuation, but when you go to learn programming it all seems conceptual. there are lots of demonstrations of grammar and punctuation, but I rarely see nice, succinct lists of all the syntax you might encounter.

Post reply on HN