Live data from Hacker News

Basic Music Theory in ~200 Lines of Python

mvanga.com

61–70 of 192 posts

Re: Basic Music Theory in ~200 Lines of Python

#61

Does any programmer suffer with music theory as well, just based on the fact that an exact thing could be called in many different ways, depends on its position, function..etc? my brain kind of cannot accept this fact and I struggle with it

I've been programming for 40 years and playing music for 50. My original background was classical and I play jazz today. I'm a fluent reader.

I think that historically, people were already familiar with "standard" notation and terminology before they learned theory, so it wasn't a major hurdle. Not only do theory students (i.e., at the college level) know how to read, but they are also required to learn keyboard. I've heard people say: Don't try to learn theory without a keyboard in front of you.

Music instrumentation and notation are technologies and as such they are replete with historical baggage. I have an unorthodox view, which is that if someone is not already usefully reading standard music notation by adulthood, then they have no reason to learn it. Explanation of theory for non readers would be better served by using an invented notation that sidesteps the historical naming problems.

One such notation is the Nashville number system. It's not nearly universal, but for the purposes of just enjoying a wide swath of popular and folk music, it actually works. It's fun to see how many different songs boil down to a few basic patterns.

A computerized tutorial could show both notations. There is a lot of instructional material for guitar, that shows conventional notation in parallel with a notation based on a diagram of the fingerboard.

Programming would be just as bad if we were stuck with a 400 year old language. Fortunately we develop new languages, but that's because old programs just get thrown away, and it's easy to teach a computer to read a new language. We also teach programmers not only how to read, but how to create better notation themselves.

Re: Basic Music Theory in ~200 Lines of Python

#62

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…

> Figuring out what it means to have a chromatic scale "for a given key" is advanced music theory

Interesting... Do you have any links for learning more about this - maybe some analyses?

My take on chromatic scales (in the context of this post) is that the very existence of a(n equally tempered 12 tone) chromatic scale is the axiom the OP is using but not stated - hence a comment further up/down about P5s not necessarily being equivalent to d6 in other tunings.

My take on chromatic scales (outside the context of this post) is that there is only one, like there are only two whole-tone scales, etc, and that it wouldn't necessarily make sense to say "the E chromatic scale" - instead you'd say "playing a chromatic scale over an E major harmony" (for example).

However, if there are cases where it's useful to be more specific I'd be really keen to go deeper.

Re: Basic Music Theory in ~200 Lines of Python

#63
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?

You basically can look up just intonation versus equal temperament for the basics. https://pages.mtu.edu/~suits/scales.html gives the mathematical answer but doesn't get into the history.

A clause that says "assuming twelve-tone equal temperament" would be sufficient here, but you can really go down the rabbit hole if you start digging into scales (see microtonal), and your page is meant to be more basic.

Re: Basic Music Theory in ~200 Lines of Python

#65
post #44

> For historical reasons, there are no sharps or flats between the notes B/C, and E/F. Come on, that is not for "historical reasons", that is because those notes are only one semitone apart!

The idea of a semitone in Western classical music is historical not (just) tonal.

True, but that does not mean you can just space notes in a scale randomly.

Re: Basic Music Theory in ~200 Lines of Python

#66
post #35

Earlier quoted context omitted.

Every rigid object has a fundamental frequency, regardless of whether you put it on a graph.

Sure. But the other frequencies need not be integer multiples of the fundamental.

They don't have to, but usually those integer multiples will be present as well. Whether they are dominant or not is another matter but it is quite hard to design something in such a way that if it has a natural resonance at a certain frequency that integer multiples will not be present in the response spectrum.

A typical object will have multiple modes of resonance as well.

Re: Basic Music Theory in ~200 Lines of Python

#68

Unreadable code,considering the subject should have been written in either in c, c#, d, f or f#.

Interesting that there are no languages with "flat" names. I can think of two reasons: - the word "sharp" has more positive connotations - if you're limited to the keys on a usual keyboard "flat" would be denoted by "b".

Re: Basic Music Theory in ~200 Lines of Python

#69

This is great but if we could go back in time and influence the naming conventions so that the 12 semitones were called A-L or just numbered 1 to 12, and if the intervals were named after the actual semitone distance (a 'fifth' is actually seven semitones) the whole thing would be soooo much less jargonny. With all that bumf removed, the patterns of the 'scales' and 'chords' would be foregrounded and thats the actual…

I'm too excited not to comment on here specifically, although I have another comment in this thread already. I made a proposal for this in my book which isn't out yet but basically I'm using only consonants for these.. so that I can link a vowel for a separate encoding.. so in order of notes where their set notation is 0 1 2 3 4 5 6 7 8 9 10 11, B D F G J K L M N P R S. It's an idea, and possibly somewhat arbitrary,…

I've been working on a fixed chromatic solfege system (MaNePu) for a while as well. It uses a repeating vowel pattern which I find produces some really interesting effects. In MaNePu, the chromatic scale is ma - ne - pu - qa - re - su - ta - ve - wu - xa - ye - zu. In other words, consonants starting with M til the end of the alphabet, and rotating through the vowel sounds "ah", "ee", and "ooh". What's neat about this is that the pattern repeats every minor third, so that means every diminished scale internally rhymes! Similarly, transposing any melody by a minor third will also result in a melody that rhymes with the former. Likewise, either whole tone scale will result in a reversal of the vowel pattern. There are other fixed chromatic solfege systems that use an alternating vowel pattern, but MaNePu is the only one that uses a minor third rotation (the others I've seen typically alternate by whole tone), and I think it opens up some interesting avenues for music education.

I like your shortened chord quality convention, though MaNePu takes a different tack. Instead, it favors what I call "descriptive chord naming". Instead of being prescriptive about the quality, a chord is simply described by appending the notes contained within it. This is great because it also removes ambiguity in the cases where a chord might include certain notes or exclude certain notes implicitly. So Dmaj7 would be PuTaXaNe ("Xa" is pronounced like a "j"/"sh" sound sort of like in Pinyin). It also typically reduces the number of syllables spoken, like your system.

The superimposition of 7 on 12 as you put it, is indeed a problem, but there's also an issue with intervallic favoritism (of half and whole tones). After all, there are 7 note scales with minor third intervals, and so on—imagine a world where one of those scales was the basis for diatonicism. Representing that on a keyboard, and the subsequent accidentals would be a nightmare.

Notation is the big unsolved problem, I think, but I'm aware of some work being done in the area if you're interested. As far as the public facing projects I'm aware of, Dodeka is likely the most promising.

Re: Basic Music Theory in ~200 Lines of Python

#70
post #8

“ For historical reasons, there are no sharps or flats between the notes B/C, and E/F.” Mmmm yes, and that’s also a bit confusing because it dodges around why the scale was and is 7 notes to begin with.

Coincidentally there are no commonly used scales or modes with two consecutive semitones. The semitone gaps are always spaced out. With 11 notes (excluding the octave), that only leaves 4 possibilities for a 7 note scale if you remove rotations. These correspond to major, harmonic minor, melodic minor and harmonic major. It’s easy to prove with pencil and paper concentrating on c to c

> Coincidentally there are no commonly used scales or modes with two consecutive semitones.

It's common in Bebop to add a passing tone to otherwise heptatonic scales. Consecutive semitones are also a common feature in blues.

Post reply on HN